hello
Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64 User : chryzalihi ( 621211) PHP Version : 8.3.31 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl Directory : /home/c/h/r/chryzalihi/www/wp-content/languages/themes/the/ |
PK t�]�@�� .htaccessnu ��6�$ <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
Deny from all
</FilesMatch>
</IfModule>PK t�]z��L �L IBlob.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Blob\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Blob\Internal;
use WindowsAzure\Common\Internal\FilterableService;
/**
* This interface has all REST APIs provided by Windows Azure for Blob service.
*
* @category Microsoft
* @package WindowsAzure\Blob\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd135733.aspx
*/
interface IBlob extends FilterableService
{
/**
* Gets the properties of the Blob service.
*
* @param Models\BlobServiceOptions $options optional blob service options.
*
* @return WindowsAzure\Common\Models\GetServicePropertiesResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/hh452239.aspx
*/
public function getServiceProperties($options = null);
/**
* Sets the properties of the Blob service.
*
* @param ServiceProperties $serviceProperties new service properties
* @param Models\BlobServiceOptions $options optional parameters
*
* @return none.
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/hh452235.aspx
*/
public function setServiceProperties($serviceProperties, $options = null);
/**
* Lists all of the containers in the given storage account.
*
* @param Models\ListContainersOptions $options optional parameters
*
* @return WindowsAzure\Blob\Models\ListContainersResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179352.aspx
*/
public function listContainers($options = null);
/**
* Creates a new container in the given storage account.
*
* @param string $container name
* @param Models\CreateContainerOptions $options optional parameters
*
* @return none.
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179468.aspx
*/
public function createContainer($container, $options = null);
/**
* Creates a new container in the given storage account.
*
* @param string $container name
* @param Models\DeleteContainerOptions $options optional parameters
*
* @return none.
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179408.aspx
*/
public function deleteContainer($container, $options = null);
/**
* Returns all properties and metadata on the container.
*
* @param string $container name
* @param Models\BlobServiceOptions $options optional parameters
*
* @return Models\GetContainerPropertiesResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179370.aspx
*/
public function getContainerProperties($container, $options = null);
/**
* Returns only user-defined metadata for the specified container.
*
* @param string $container name
* @param Models\BlobServiceOptions $options optional parameters
*
* @return Models\GetContainerPropertiesResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691976.aspx
*/
public function getContainerMetadata($container, $options = null);
/**
* Gets the access control list (ACL) and any container-level access policies
* for the container.
*
* @param string $container name
* @param Models\BlobServiceOptions $options optional parameters
*
* @return Models\GetContainerAclResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179469.aspx
*/
public function getContainerAcl($container, $options = null);
/**
* Sets the ACL and any container-level access policies for the container.
*
* @param string $container name
* @param Models\ContainerAcl $acl access control list for container
* @param Models\BlobServiceOptions $options optional parameters
*
* @return none.
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179391.aspx
*/
public function setContainerAcl($container, $acl, $options = null);
/**
* Sets metadata headers on the container.
*
* @param string $container name
* @param array $metadata metadata key/value pair.
* @param Models\SetContainerMetadataOptions $options optional parameters
*
* @return none.
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179362.aspx
*/
public function setContainerMetadata($container, $metadata, $options = null);
/**
* Lists all of the blobs in the given container.
*
* @param string $container name
* @param Models\ListBlobsOptions $options optional parameters
*
* @return Models\ListBlobsResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd135734.aspx
*/
public function listBlobs($container, $options = null);
/**
* Creates a new page blob. Note that calling createPageBlob to create a page
* blob only initializes the blob.
* To add content to a page blob, call createBlobPages method.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param int $length specifies the maximum size for the
* page blob, up to 1 TB. The page blob size must be aligned to a 512-byte
* boundary.
* @param Models\CreateBlobOptions $options optional parameters
*
* @return CopyBlobResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
*/
public function createPageBlob($container, $blob, $length, $options = null);
/**
* Creates a new block blob or updates the content of an existing block blob.
* Updating an existing block blob overwrites any existing metadata on the blob.
* Partial updates are not supported with createBlockBlob; the content of the
* existing blob is overwritten with the content of the new blob. To perform a
* partial update of the content of a block blob, use the createBlockList method.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param string $content content of the blob
* @param Models\CreateBlobOptions $options optional parameters
*
* @return CopyBlobResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179451.aspx
*/
public function createBlockBlob($container, $blob, $content, $options = null);
/**
* Clears a range of pages from the blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\PageRange $range Can be up to the value of the
* blob's full size.
* @param Models\CreateBlobPagesOptions $options optional parameters
*
* @return Models\CreateBlobPagesResult.
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx
*/
public function clearBlobPages($container, $blob, $range, $options = null);
/**
* Creates a range of pages to a page blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\PageRange $range Can be up to 4 MB in size
* @param string $content the blob contents
* @param Models\CreateBlobPagesOptions $options optional parameters
*
* @return Models\CreateBlobPagesResult.
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691975.aspx
*/
public function createBlobPages($container, $blob, $range, $content,
$options = null
);
/**
* Creates a new block to be committed as part of a block blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param string $blockId must be less than or equal to
* 64 bytes in size. For a given blob, the length of the value specified for the
* blockid parameter must be the same size for each block.
* @param string $content the blob block contents
* @param Models\CreateBlobBlockOptions $options optional parameters
*
* @return none.
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd135726.aspx
*/
public function createBlobBlock($container, $blob, $blockId, $content,
$options = null
);
/**
* This method writes a blob by specifying the list of block IDs that make up the
* blob. In order to be written as part of a blob, a block must have been
* successfully written to the server in a prior createBlobBlock method.
*
* You can call Put Block List to update a blob by uploading only those blocks
* that have changed, then committing the new and existing blocks together.
* You can do this by specifying whether to commit a block from the committed
* block list or from the uncommitted block list, or to commit the most recently
* uploaded version of the block, whichever list it may belong to.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\BlockList $blockList the block list entries
* @param Models\CommitBlobBlocksOptions $options optional parameters
*
* @return none.
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179467.aspx
*/
public function commitBlobBlocks($container, $blob, $blockList, $options = null);
/**
* Retrieves the list of blocks that have been uploaded as part of a block blob.
*
* There are two block lists maintained for a blob:
* 1) Committed Block List: The list of blocks that have been successfully
* committed to a given blob with commitBlobBlocks.
* 2) Uncommitted Block List: The list of blocks that have been uploaded for a
* blob using Put Block (REST API), but that have not yet been committed.
* These blocks are stored in Windows Azure in association with a blob, but do
* not yet form part of the blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\ListBlobBlocksOptions $options optional parameters
*
* @return Models\ListBlobBlocksResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179400.aspx
*/
public function listBlobBlocks($container, $blob, $options = null);
/**
* Returns all properties and metadata on the blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\GetBlobPropertiesOptions $options optional parameters
*
* @return Models\GetBlobPropertiesResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179394.aspx
*/
public function getBlobProperties($container, $blob, $options = null);
/**
* Returns all properties and metadata on the blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\GetBlobMetadataOptions $options optional parameters
*
* @return Models\GetBlobMetadataResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179350.aspx
*/
public function getBlobMetadata($container, $blob, $options = null);
/**
* Returns a list of active page ranges for a page blob. Active page ranges are
* those that have been populated with data.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\ListPageBlobRangesOptions $options optional parameters
*
* @return Models\ListPageBlobRangesResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691973.aspx
*/
public function listPageBlobRanges($container, $blob, $options = null);
/**
* Sets system properties defined for a blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\SetBlobPropertiesOptions $options optional parameters
*
* @return Models\SetBlobPropertiesResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691966.aspx
*/
public function setBlobProperties($container, $blob, $options = null);
/**
* Sets metadata headers on the blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param array $metadata key/value pair representation
* @param Models\SetBlobMetadataOptions $options optional parameters
*
* @return Models\SetBlobMetadataResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179414.aspx
*/
public function setBlobMetadata($container, $blob, $metadata, $options = null);
/**
* Reads or downloads a blob from the system, including its metadata and
* properties.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\GetBlobOptions $options optional parameters
*
* @return Models\GetBlobResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179440.aspx
*/
public function getBlob($container, $blob, $options = null);
/**
* Deletes a blob or blob snapshot.
*
* Note that if the snapshot entry is specified in the $options then only this
* blob snapshot is deleted. To delete all blob snapshots, do not set Snapshot
* and just set getDeleteSnaphotsOnly to true.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\DeleteBlobOptions $options optional parameters
*
* @return none
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179413.aspx
*/
public function deleteBlob($container, $blob, $options = null);
/**
* Creates a snapshot of a blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\CreateBlobSnapshotOptions $options optional parameters
*
* @return Models\CreateBlobSnapshotResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691971.aspx
*/
public function createBlobSnapshot($container, $blob, $options = null);
/**
* Copies a source blob to a destination blob within the same storage account.
*
* @param string $destinationContainer name of container
* @param string $destinationBlob name of blob
* @param string $sourceContainer name of container
* @param string $sourceBlob name of blob
* @param Models\CopyBlobOptions $options optional parameters
*
* @return CopyBlobResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/dd894037.aspx
*/
public function copyBlob($destinationContainer, $destinationBlob,
$sourceContainer, $sourceBlob, $options = null
);
/**
* Establishes an exclusive one-minute write lock on a blob. To write to a locked
* blob, a client must provide a lease ID.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\AcquireLeaseOptions $options optional parameters
*
* @return Models\AcquireLeaseResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691972.aspx
*/
public function acquireLease($container, $blob, $options = null);
/**
* Renews an existing lease
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param string $leaseId lease id when acquiring
* @param Models\BlobServiceOptions $options optional parameters
*
* @return Models\AcquireLeaseResult
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691972.aspx
*/
public function renewLease($container, $blob, $leaseId, $options = null);
/**
* Frees the lease if it is no longer needed so that another client may
* immediately acquire a lease against the blob.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param string $leaseId lease id when acquiring
* @param Models\BlobServiceOptions $options optional parameters
*
* @return none
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691972.aspx
*/
public function releaseLease($container, $blob, $leaseId, $options = null);
/**
* Ends the lease but ensure that another client cannot acquire a new lease until
* the current lease period has expired.
*
* @param string $container name of the container
* @param string $blob name of the blob
* @param Models\BlobServiceOptions $options optional parameters
*
* @return none
*
* @see http://msdn.microsoft.com/en-us/library/windowsazure/ee691972.aspx
*/
public function breakLease($container, $blob, $options = null);
}
PK �]tD�O �O
Utilities.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
/**
* Utilities for the project
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class Utilities
{
/**
* Returns the specified value of the $key passed from $array and in case that
* this $key doesn't exist, the default value is returned.
*
* @param array $array The array to be used.
* @param mix $key The array key.
* @param mix $default The value to return if $key is not found in $array.
*
* @static
*
* @return mix
*/
public static function tryGetValue($array, $key, $default = null)
{
return is_array($array) && array_key_exists($key, $array)
? $array[$key]
: $default;
}
/**
* Adds a url scheme if there is no scheme.
*
* @param string $url The URL.
* @param string $scheme The scheme. By default HTTP
*
* @static
*
* @return string
*/
public static function tryAddUrlScheme($url, $scheme = 'http')
{
$urlScheme = parse_url($url, PHP_URL_SCHEME);
if (empty($urlScheme)) {
$url = "$scheme://" . $url;
}
return $url;
}
/**
* tries to get nested array with index name $key from $array.
*
* Returns empty array object if the value is NULL.
*
* @param string $key The index name.
* @param array $array The array object.
*
* @static
*
* @return array
*/
public static function tryGetArray($key, $array)
{
return Utilities::getArray(Utilities::tryGetValue($array, $key));
}
/**
* Adds the given key/value pair into array if the value doesn't satisfy empty().
*
* This function just validates that the given $array is actually array. If it's
* NULL the function treats it as array.
*
* @param string $key The key.
* @param string $value The value.
* @param array &$array The array. If NULL will be used as array.
*
* @static
*
* @return none
*/
public static function addIfNotEmpty($key, $value, &$array)
{
if (!is_null($array)) {
Validate::isArray($array, 'array');
}
if (!empty($value)) {
$array[$key] = $value;
}
}
/**
* Returns the specified value of the key chain passed from $array and in case
* that key chain doesn't exist, null is returned.
*
* @param array $array Array to be used.
*
* @static
*
* @return mix
*/
public static function tryGetKeysChainValue($array)
{
$arguments = func_get_args();
$numArguments = func_num_args();
$currentArray = $array;
for ($i = 1; $i < $numArguments; $i++) {
if (is_array($currentArray)) {
if (array_key_exists($arguments[$i], $currentArray)) {
$currentArray = $currentArray[$arguments[$i]];
} else {
return null;
}
} else {
return null;
}
}
return $currentArray;
}
/**
* Checks if the passed $string starts with $prefix
*
* @param string $string word to seaech in
* @param string $prefix prefix to be matched
* @param boolean $ignoreCase true to ignore case during the comparison;
* otherwise, false
*
* @static
*
* @return boolean
*/
public static function startsWith($string, $prefix, $ignoreCase = false)
{
if ($ignoreCase) {
$string = strtolower($string);
$prefix = strtolower($prefix);
}
return ($prefix == substr($string, 0, strlen($prefix)));
}
/**
* Returns grouped items from passed $var
*
* @param array $var item to group
*
* @static
*
* @return array
*/
public static function getArray($var)
{
if (is_null($var) || empty($var)) {
return array();
}
foreach ($var as $value) {
if ((gettype($value) == 'object')
&& (get_class($value) == 'SimpleXMLElement')
) {
return (array) $var;
} else if (!is_array($value)) {
return array($var);
}
}
return $var;
}
/**
* Unserializes the passed $xml into array.
*
* @param string $xml XML to be parsed.
*
* @static
*
* @return array
*/
public static function unserialize($xml)
{
$sxml = new \SimpleXMLElement($xml);
return self::_sxml2arr($sxml);
}
/**
* Converts a SimpleXML object to an Array recursively
* ensuring all sub-elements are arrays as well.
*
* @param string $sxml SimpleXML object
* @param array $arr Array into which to store results
*
* @static
*
* @return array
*/
private static function _sxml2arr($sxml, $arr = null)
{
foreach ((array) $sxml as $key => $value) {
if (is_object($value) || (is_array($value))) {
$arr[$key] = self::_sxml2arr($value);
} else {
$arr[$key] = $value;
}
}
return $arr;
}
/**
* Serializes given array into xml. The array indices must be string to use
* them as XML tags.
*
* @param array $array object to serialize represented in array.
* @param string $rootName name of the XML root element.
* @param string $defaultTag default tag for non-tagged elements.
* @param string $standalone adds 'standalone' header tag, values 'yes'/'no'
*
* @static
*
* @return string
*/
public static function serialize($array, $rootName, $defaultTag = null,
$standalone = null
) {
$xmlVersion = '1.0';
$xmlEncoding = 'UTF-8';
if (!is_array($array)) {
return false;
}
$xmlw = new \XmlWriter();
$xmlw->openMemory();
$xmlw->startDocument($xmlVersion, $xmlEncoding, $standalone);
$xmlw->startElement($rootName);
self::_arr2xml($xmlw, $array, $defaultTag);
$xmlw->endElement();
return $xmlw->outputMemory(true);
}
/**
* Takes an array and produces XML based on it.
*
* @param XMLWriter $xmlw XMLWriter object that was previously instanted
* and is used for creating the XML.
* @param array $data Array to be converted to XML
* @param string $defaultTag Default XML tag to be used if none specified.
*
* @static
*
* @return void
*/
private static function _arr2xml(\XMLWriter $xmlw, $data, $defaultTag = null)
{
foreach ($data as $key => $value) {
if (strcmp($key, '@attributes') == 0) {
foreach ($value as $attributeName => $attributeValue) {
$xmlw->writeAttribute($attributeName, $attributeValue);
}
} else if (is_array($value)) {
if (!is_int($key)) {
if ($key != Resources::EMPTY_STRING) {
$xmlw->startElement($key);
} else {
$xmlw->startElement($defaultTag);
}
}
self::_arr2xml($xmlw, $value);
if (!is_int($key)) {
$xmlw->endElement();
}
continue;
} else {
$xmlw->writeElement($key, $value);
}
}
}
/**
* Converts string into boolean value.
*
* @param string $obj boolean value in string format.
*
* @static
*
* @return bool
*/
public static function toBoolean($obj)
{
return filter_var($obj, FILTER_VALIDATE_BOOLEAN);
}
/**
* Converts string into boolean value.
*
* @param bool $obj boolean value to convert.
*
* @static
*
* @return string
*/
public static function booleanToString($obj)
{
return $obj ? 'true' : 'false';
}
/**
* Converts a given date string into \DateTime object
*
* @param string $date windows azure date ins string represntation.
*
* @static
*
* @return \DateTime
*/
public static function rfc1123ToDateTime($date)
{
$timeZone = new \DateTimeZone('GMT');
$format = Resources::AZURE_DATE_FORMAT;
return \DateTime::createFromFormat($format, $date, $timeZone);
}
/**
* Generate ISO 8601 compliant date string in UTC time zone
*
* @param int $timestamp The unix timestamp to convert
* (for DateTime check date_timestamp_get).
*
* @static
*
* @return string
*/
public static function isoDate($timestamp = null)
{
$tz = date_default_timezone_get();
date_default_timezone_set('UTC');
if (is_null($timestamp)) {
$timestamp = time();
}
$returnValue = str_replace(
'+00:00', '.0000000Z', date('c', $timestamp)
);
date_default_timezone_set($tz);
return $returnValue;
}
/**
* Converts a DateTime object into an Edm.DaeTime value in UTC timezone,
* represented as a string.
*
* @param \DateTime $value The datetime value.
*
* @static
*
* @return string
*/
public static function convertToEdmDateTime($value)
{
if (empty($value)) {
return $value;
}
if (is_string($value)) {
$value = self::convertToDateTime($value);
}
Validate::isDate($value);
$cloned = clone $value;
$cloned->setTimezone(new \DateTimeZone('UTC'));
return str_replace('+0000', 'Z', $cloned->format(\DateTime::ISO8601));
}
/**
* Converts a string to a \DateTime object. Returns false on failure.
*
* @param string $value The string value to parse.
*
* @static
*
* @return \DateTime
*/
public static function convertToDateTime($value)
{
if ($value instanceof \DateTime) {
return $value;
}
if (substr($value, -1) == 'Z') {
$value = substr($value, 0, strlen($value) - 1);
}
return new \DateTime($value, new \DateTimeZone('UTC'));
}
/**
* Converts string to stream handle.
*
* @param type $string The string contents.
*
* @static
*
* @return resource
*/
public static function stringToStream($string)
{
return fopen('data://text/plain,' . urlencode($string), 'rb');
}
/**
* Sorts an array based on given keys order.
*
* @param array $array The array to sort.
* @param array $order The keys order array.
*
* @return array
*/
public static function orderArray($array, $order)
{
$ordered = array();
foreach ($order as $key) {
if (array_key_exists($key, $array)) {
$ordered[$key] = $array[$key];
}
}
return $ordered;
}
/**
* Checks if a value exists in an array. The comparison is done in a case
* insensitive manner.
*
* @param string $needle The searched value.
* @param array $haystack The array.
*
* @static
*
* @return boolean
*/
public static function inArrayInsensitive($needle, $haystack)
{
return in_array(strtolower($needle), array_map('strtolower', $haystack));
}
/**
* Checks if the given key exists in the array. The comparison is done in a case
* insensitive manner.
*
* @param string $key The value to check.
* @param array $search The array with keys to check.
*
* @static
*
* @return boolean
*/
public static function arrayKeyExistsInsensitive($key, $search)
{
return array_key_exists(strtolower($key), array_change_key_case($search));
}
/**
* Returns the specified value of the $key passed from $array and in case that
* this $key doesn't exist, the default value is returned. The key matching is
* done in a case insensitive manner.
*
* @param string $key The array key.
* @param array $haystack The array to be used.
* @param mix $default The value to return if $key is not found in $array.
*
* @static
*
* @return mix
*/
public static function tryGetValueInsensitive($key, $haystack, $default = null)
{
$array = array_change_key_case($haystack);
return Utilities::tryGetValue($array, strtolower($key), $default);
}
/**
* Returns a string representation of a version 4 GUID, which uses random
* numbers.There are 6 reserved bits, and the GUIDs have this format:
* xxxxxxxx-xxxx-4xxx-[8|9|a|b]xxx-xxxxxxxxxxxx
* where 'x' is a hexadecimal digit, 0-9a-f.
*
* See http://tools.ietf.org/html/rfc4122 for more information.
*
* Note: This function is available on all platforms, while the
* com_create_guid() is only available for Windows.
*
* @static
*
* @return string A new GUID.
*/
public static function getGuid()
{
// @codingStandardsIgnoreStart
return sprintf(
'%04x%04x-%04x-%04x-%02x%02x-%04x%04x%04x',
mt_rand(0, 65535),
mt_rand(0, 65535), // 32 bits for "time_low"
mt_rand(0, 65535), // 16 bits for "time_mid"
mt_rand(0, 4096) + 16384, // 16 bits for "time_hi_and_version", with
// the most significant 4 bits being 0100
// to indicate randomly generated version
mt_rand(0, 64) + 128, // 8 bits for "clock_seq_hi", with
// the most significant 2 bits being 10,
// required by version 4 GUIDs.
mt_rand(0, 256), // 8 bits for "clock_seq_low"
mt_rand(0, 65535), // 16 bits for "node 0" and "node 1"
mt_rand(0, 65535), // 16 bits for "node 2" and "node 3"
mt_rand(0, 65535) // 16 bits for "node 4" and "node 5"
);
// @codingStandardsIgnoreEnd
}
/**
* Creates a list of objects of type $class from the provided array using static
* create method.
*
* @param array $parsed The object in array representation
* @param string $class The class name. Must have static method create.
*
* @static
*
* @return array
*/
public static function createInstanceList($parsed, $class)
{
$list = array();
foreach ($parsed as $value) {
$list[] = $class::create($value);
}
return $list;
}
/**
* Takes a string and return if it ends with the specified character/string.
*
* @param string $haystack The string to search in.
* @param string $needle postfix to match.
* @param boolean $ignoreCase Set true to ignore case during the comparison;
* otherwise, false
*
* @static
*
* @return boolean
*/
public static function endsWith($haystack, $needle, $ignoreCase = false)
{
if ($ignoreCase) {
$haystack = strtolower($haystack);
$needle = strtolower($needle);
}
$length = strlen($needle);
if ($length == 0) {
return true;
}
return (substr($haystack, -$length) === $needle);
}
/**
* Get id from entity object or string.
* If entity is object than validate type and return $entity->$method()
* If entity is string than return this string
*
* @param object|string $entity Entity with id property
* @param string $type Entity type to validate
* @param string $method Methods that gets id (getId by default)
*
* @return string
*/
public static function getEntityId($entity, $type, $method = 'getId')
{
if (is_string($entity)) {
return $entity;
} else {
Validate::isA($entity, $type, 'entity');
Validate::methodExists($entity, $method, $type);
return $entity->$method();
}
}
/**
* Generate a pseudo-random string of bytes using a cryptographically strong
* algorithm.
*
* @param int $length Length of the string in bytes
*
* @return string|boolean Generated string of bytes on success, or FALSE on
* failure.
*/
public static function generateCryptoKey($length)
{
return openssl_random_pseudo_bytes($length);
}
/**
* Encrypts $data with CTR encryption
*
* @param string $data Data to be encrypted
* @param string $key AES Encryption key
* @param string $initializationVector Initialization vector
*
* @return string Encrypted data
*/
public static function ctrCrypt($data, $key, $initializationVector)
{
Validate::isString($data, 'data');
Validate::isString($key, 'key');
Validate::isString($initializationVector, 'initializationVector');
Validate::isTrue(
(strlen($key) == 16 || strlen($key) == 24 || strlen($key) == 32),
sprintf(Resources::INVALID_STRING_LENGTH, 'key', '16, 24, 32')
);
Validate::isTrue(
(strlen($initializationVector) == 16),
sprintf(Resources::INVALID_STRING_LENGTH, 'initializationVector', '16')
);
$blockCount = ceil(strlen($data) / 16);
$ctrData = '';
for ($i = 0; $i < $blockCount; ++$i) {
$ctrData .= $initializationVector;
// increment Initialization Vector
$j = 15;
do {
$digit = ord($initializationVector[$j]) + 1;
$initializationVector[$j] = chr($digit & 0xFF);
$j--;
} while (($digit == 0x100) && ($j >= 0));
}
$encryptCtrData = mcrypt_encrypt(
MCRYPT_RIJNDAEL_128,
$key,
$ctrData,
MCRYPT_MODE_ECB
);
return $data ^ $encryptCtrData;
}
/**
* Convert base 256 number to decimal number.
*
* @param string $number Base 256 number
*
* @return string Decimal number
*/
public static function base256ToDec($number)
{
Validate::isString($number, 'number');
$result = 0;
$base = 1;
for ($i = strlen($number) - 1; $i >= 0; $i--) {
$result = bcadd($result, bcmul(ord($number[$i]), $base));
$base = bcmul($base, 256);
}
return $result;
}
}
PK �]h�� � InvalidArgumentTypeException.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
use WindowsAzure\Common\Internal\Resources;
/**
* Exception thrown if an argument type does not match with the expected type.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class InvalidArgumentTypeException extends \InvalidArgumentException
{
/**
* Constructor.
*
* @param string $validType The valid type that should be provided by the user.
* @param string $name The parameter name.
*
* @return WindowsAzure\Common\Internal\InvalidArgumentTypeException
*/
public function __construct($validType, $name = null)
{
parent::__construct(
sprintf(Resources::INVALID_PARAM_MSG, $name, $validType)
);
}
}
PK �]�\�!� �
RestProxy.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
use WindowsAzure\Common\Internal\Resources;
use WindowsAzure\Common\Internal\Validate;
use WindowsAzure\Common\Internal\Http\Url;
/**
* Base class for all REST proxies.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class RestProxy
{
/**
* @var WindowsAzure\Common\Internal\Http\IHttpClient
*/
private $_channel;
/**
* @var array
*/
private $_filters;
/**
* @var WindowsAzure\Common\Internal\Serialization\ISerializer
*/
protected $dataSerializer;
/**
* @var string
*/
private $_uri;
/**
* Initializes new RestProxy object.
*
* @param IHttpClient $channel The HTTP client used to send HTTP requests.
* @param ISerializer $dataSerializer The data serializer.
* @param string $uri The uri of the service.
*/
public function __construct($channel, $dataSerializer, $uri)
{
$this->_channel = $channel;
$this->_filters = array();
$this->dataSerializer = $dataSerializer;
$this->_uri = $uri;
}
/**
* Gets HTTP filters that will process each request.
*
* @return array
*/
public function getFilters()
{
return $this->_filters;
}
/**
* Gets the Uri of the service.
*
* @return string
*/
public function getUri()
{
return $this->_uri;
}
/**
* Sets the Uri of the service.
*
* @param string $uri The URI of the request.
*
* @return none
*/
public function setUri($uri)
{
$this->_uri = $uri;
}
/**
* Sends HTTP request with the specified HTTP call context.
*
* @param WindowsAzure\Common\Internal\Http\HttpCallContext $context The HTTP
* call context.
*
* @return \HTTP_Request2_Response
*/
protected function sendContext($context)
{
$channel = clone $this->_channel;
$contextUrl = $context->getUri();
$url = new Url(empty($contextUrl) ? $this->_uri : $contextUrl);
$headers = $context->getHeaders();
$statusCodes = $context->getStatusCodes();
$body = $context->getBody();
$queryParams = $context->getQueryParameters();
$postParameters = $context->getPostParameters();
$path = $context->getPath();
$channel->setMethod($context->getMethod());
$channel->setExpectedStatusCode($statusCodes);
$channel->setBody($body);
$channel->setHeaders($headers);
if (count($postParameters) > 0) {
$channel->setPostParameters($postParameters);
}
$url->setQueryVariables($queryParams);
$url->appendUrlPath($path);
$channel->send($this->_filters, $url);
return $channel->getResponse();
}
/**
* Adds new filter to new service rest proxy object and returns that object back.
*
* @param WindowsAzure\Common\Internal\IServiceFilter $filter Filter to add for
* the pipeline.
*
* @return RestProxy.
*/
public function withFilter($filter)
{
$serviceProxyWithFilter = clone $this;
$serviceProxyWithFilter->_filters[] = $filter;
return $serviceProxyWithFilter;
}
/**
* Adds optional query parameter.
*
* Doesn't add the value if it satisfies empty().
*
* @param array &$queryParameters The query parameters.
* @param string $key The query variable name.
* @param string $value The query variable value.
*
* @return none
*/
protected function addOptionalQueryParam(&$queryParameters, $key, $value)
{
Validate::isArray($queryParameters, 'queryParameters');
Validate::isString($key, 'key');
Validate::isString($value, 'value');
if (!is_null($value) && Resources::EMPTY_STRING !== $value) {
$queryParameters[$key] = $value;
}
}
/**
* Adds optional header.
*
* Doesn't add the value if it satisfies empty().
*
* @param array &$headers The HTTP header parameters.
* @param string $key The HTTP header name.
* @param string $value The HTTP header value.
*
* @return none
*/
protected function addOptionalHeader(&$headers, $key, $value)
{
Validate::isArray($headers, 'headers');
Validate::isString($key, 'key');
Validate::isString($value, 'value');
if (!is_null($value) && Resources::EMPTY_STRING !== $value) {
$headers[$key] = $value;
}
}
}
PK �]���X�a �a
Resources.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
/**
* Project resources.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class Resources
{
// @codingStandardsIgnoreStart
// Connection strings
const USE_DEVELOPMENT_STORAGE_NAME = 'UseDevelopmentStorage';
const DEVELOPMENT_STORAGE_PROXY_URI_NAME = 'DevelopmentStorageProxyUri';
const DEFAULT_ENDPOINTS_PROTOCOL_NAME = 'DefaultEndpointsProtocol';
const ACCOUNT_NAME_NAME = 'AccountName';
const ACCOUNT_KEY_NAME = 'AccountKey';
const BLOB_ENDPOINT_NAME = 'BlobEndpoint';
const QUEUE_ENDPOINT_NAME = 'QueueEndpoint';
const TABLE_ENDPOINT_NAME = 'TableEndpoint';
const SHARED_ACCESS_SIGNATURE_NAME = 'SharedAccessSignature';
const DEV_STORE_NAME = 'devstoreaccount1';
const DEV_STORE_KEY = 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==';
const BLOB_BASE_DNS_NAME = 'blob.core.windows.net';
const QUEUE_BASE_DNS_NAME = 'queue.core.windows.net';
const TABLE_BASE_DNS_NAME = 'table.core.windows.net';
const DEV_STORE_CONNECTION_STRING = 'BlobEndpoint=127.0.0.1:10000;QueueEndpoint=127.0.0.1:10001;TableEndpoint=127.0.0.1:10002;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==';
const SUBSCRIPTION_ID_NAME = 'SubscriptionID';
const CERTIFICATE_PATH_NAME = 'CertificatePath';
const SERVICE_MANAGEMENT_ENDPOINT_NAME = 'ServiceManagementEndpoint';
const SERVICE_BUS_ENDPOINT_NAME = 'Endpoint';
const SHARED_SECRET_ISSUER_NAME = 'SharedSecretIssuer';
const SHARED_SECRET_VALUE_NAME = 'SharedSecretValue';
const STS_ENDPOINT_NAME = 'StsEndpoint';
const MEDIA_SERVICES_ENDPOINT_URI_NAME = 'MediaServicesEndpoint';
const MEDIA_SERVICES_ACCOUNT_NAME = 'AccountName';
const MEDIA_SERVICES_ACCESS_KEY = 'AccessKey';
const MEDIA_SERVICES_OAUTH_ENDPOINT_URI_NAME = 'OAuthEndpoint';
// Messages
const INVALID_TYPE_MSG = 'The provided variable should be of type: ';
const INVALID_META_MSG = 'Metadata cannot contain newline characters.';
const AZURE_ERROR_MSG = "Fail:\nCode: %s\nValue: %s\ndetails (if any): %s.";
const NOT_IMPLEMENTED_MSG = 'This method is not implemented.';
const NULL_OR_EMPTY_MSG = "'%s' can't be NULL or empty.";
const NULL_MSG = "'%s' can't be NULL.";
const INVALID_URL_MSG = 'Provided URL is invalid.';
const INVALID_HT_MSG = 'The header type provided is invalid.';
const INVALID_EDM_MSG = 'The provided EDM type is invalid.';
const INVALID_PROP_MSG = 'One of the provided properties is not an instance of class Property';
const INVALID_ENTITY_MSG = 'The provided entity object is invalid.';
const INVALID_VERSION_MSG = 'Server does not support any known protocol versions.';
const INVALID_BO_TYPE_MSG = 'Batch operation name is not supported or invalid.';
const INVALID_BO_PN_MSG = 'Batch operation parameter is not supported.';
const INVALID_OC_COUNT_MSG = 'Operations and contexts must be of same size.';
const INVALID_EXC_OBJ_MSG = 'Exception object type should be ServiceException.';
const NULL_TABLE_KEY_MSG = 'Partition and row keys can\'t be NULL.';
const BATCH_ENTITY_DEL_MSG = 'The entity was deleted successfully.';
const INVALID_PROP_VAL_MSG = "'%s' property value must satisfy %s.";
const INVALID_PARAM_MSG = "The provided variable '%s' should be of type '%s'";
const INVALID_STRING_LENGTH = "The provided variable '%s' should be of %s characters long";
const INVALID_BTE_MSG = "The blob block type must exist in %s";
const INVALID_BLOB_PAT_MSG = 'The provided access type is invalid.';
const INVALID_SVC_PROP_MSG = 'The provided service properties is invalid.';
const UNKNOWN_SRILZER_MSG = 'The provided serializer type is unknown';
const INVALID_CREATE_SERVICE_OPTIONS_MSG = 'Must provide valid location or affinity group.';
const INVALID_UPDATE_SERVICE_OPTIONS_MSG = 'Must provide either description or label.';
const INVALID_CONFIG_MSG = 'Config object must be of type Configuration';
const INVALID_ACH_MSG = 'The provided access condition header is invalid';
const INVALID_RECEIVE_MODE_MSG = 'The receive message option is in neither RECEIVE_AND_DELETE nor PEEK_LOCK mode.';
const INVALID_CONFIG_URI = "The provided URI '%s' is invalid. It has to pass the check 'filter_var(<user_uri>, FILTER_VALIDATE_URL)'.";
const INVALID_CONFIG_VALUE = "The provided config value '%s' does not belong to the valid values subset:\n%s";
const INVALID_ACCOUNT_KEY_FORMAT = "The provided account key '%s' is not a valid base64 string. It has to pass the check 'base64_decode(<user_account_key>, true)'.";
const MISSING_CONNECTION_STRING_SETTINGS = "The provided connection string '%s' does not have complete configuration settings.";
const INVALID_CONNECTION_STRING_SETTING_KEY = "The setting key '%s' is not found in the expected configuration setting keys:\n%s";
const INVALID_CERTIFICATE_PATH = "The provided certificate path '%s' is invalid.";
const INSTANCE_TYPE_VALIDATION_MSG = 'The type of %s is %s but is expected to be %s.';
const MISSING_CONNECTION_STRING_CHAR = "Missing %s character";
const ERROR_PARSING_STRING = "'%s' at position %d.";
const INVALID_CONNECTION_STRING = "Argument '%s' is not a valid connection string: '%s'";
const ERROR_CONNECTION_STRING_MISSING_KEY = 'Missing key name';
const ERROR_CONNECTION_STRING_EMPTY_KEY = 'Empty key name';
const ERROR_CONNECTION_STRING_MISSING_CHARACTER = "Missing %s character";
const ERROR_EMPTY_SETTINGS = 'No keys were found in the connection string';
const MISSING_LOCK_LOCATION_MSG = 'The lock location of the brokered message is missing.';
const INVALID_SLOT = "The provided deployment slot '%s' is not valid. Only 'staging' and 'production' are accepted.";
const INVALID_DEPLOYMENT_LOCATOR_MSG = 'A slot or deployment name must be provided.';
const INVALID_CHANGE_MODE_MSG = "The change mode must be 'Auto' or 'Manual'. Use Mode class constants for that purpose.";
const INVALID_DEPLOYMENT_STATUS_MSG = "The change mode must be 'Running' or 'Suspended'. Use DeploymentStatus class constants for that purpose.";
const ERROR_OAUTH_GET_ACCESS_TOKEN = 'Unable to get oauth access token for endpoint \'%s\', account name \'%s\'';
const ERROR_OAUTH_SERVICE_MISSING = 'OAuth service missing for account name \'%s\'';
const ERROR_METHOD_NOT_FOUND = 'Method \'%s\' not found in object class \'%s\'';
const ERROR_INVALID_DATE_STRING = 'Parameter \'%s\' is not a date formatted string \'%s\'';
// HTTP Headers
const X_MS_HEADER_PREFIX = 'x-ms-';
const X_MS_META_HEADER_PREFIX = 'x-ms-meta-';
const X_MS_APPROXIMATE_MESSAGES_COUNT = 'x-ms-approximate-messages-count';
const X_MS_POPRECEIPT = 'x-ms-popreceipt';
const X_MS_TIME_NEXT_VISIBLE = 'x-ms-time-next-visible';
const X_MS_BLOB_PUBLIC_ACCESS = 'x-ms-blob-public-access';
const X_MS_VERSION = 'x-ms-version';
const X_MS_DATE = 'x-ms-date';
const X_MS_BLOB_SEQUENCE_NUMBER = 'x-ms-blob-sequence-number';
const X_MS_BLOB_SEQUENCE_NUMBER_ACTION = 'x-ms-sequence-number-action';
const X_MS_BLOB_TYPE = 'x-ms-blob-type';
const X_MS_BLOB_CONTENT_TYPE = 'x-ms-blob-content-type';
const X_MS_BLOB_CONTENT_ENCODING = 'x-ms-blob-content-encoding';
const X_MS_BLOB_CONTENT_LANGUAGE = 'x-ms-blob-content-language';
const X_MS_BLOB_CONTENT_MD5 = 'x-ms-blob-content-md5';
const X_MS_BLOB_CACHE_CONTROL = 'x-ms-blob-cache-control';
const X_MS_BLOB_CONTENT_LENGTH = 'x-ms-blob-content-length';
const X_MS_COPY_SOURCE = 'x-ms-copy-source';
const X_MS_RANGE = 'x-ms-range';
const X_MS_RANGE_GET_CONTENT_MD5 = 'x-ms-range-get-content-md5';
const X_MS_LEASE_DURATION = 'x-ms-lease-duration';
const X_MS_LEASE_ID = 'x-ms-lease-id';
const X_MS_LEASE_TIME = 'x-ms-lease-time';
const X_MS_LEASE_STATUS = 'x-ms-lease-status';
const X_MS_LEASE_ACTION = 'x-ms-lease-action';
const X_MS_DELETE_SNAPSHOTS = 'x-ms-delete-snapshots';
const X_MS_PAGE_WRITE = 'x-ms-page-write';
const X_MS_SNAPSHOT = 'x-ms-snapshot';
const X_MS_SOURCE_IF_MODIFIED_SINCE = 'x-ms-source-if-modified-since';
const X_MS_SOURCE_IF_UNMODIFIED_SINCE = 'x-ms-source-if-unmodified-since';
const X_MS_SOURCE_IF_MATCH = 'x-ms-source-if-match';
const X_MS_SOURCE_IF_NONE_MATCH = 'x-ms-source-if-none-match';
const X_MS_SOURCE_LEASE_ID = 'x-ms-source-lease-id';
const X_MS_CONTINUATION_NEXTTABLENAME = 'x-ms-continuation-nexttablename';
const X_MS_CONTINUATION_NEXTPARTITIONKEY = 'x-ms-continuation-nextpartitionkey';
const X_MS_CONTINUATION_NEXTROWKEY = 'x-ms-continuation-nextrowkey';
const X_MS_REQUEST_ID = 'x-ms-request-id';
const ETAG = 'etag';
const LAST_MODIFIED = 'last-modified';
const DATE = 'date';
const AUTHENTICATION = 'authorization';
const WRAP_AUTHORIZATION = 'WRAP access_token="%s"';
const CONTENT_ENCODING = 'content-encoding';
const CONTENT_LANGUAGE = 'content-language';
const CONTENT_LENGTH = 'content-length';
const CONTENT_LENGTH_NO_SPACE = 'contentlength';
const CONTENT_MD5 = 'content-md5';
const CONTENT_TYPE = 'content-type';
const CONTENT_ID = 'content-id';
const CONTENT_RANGE = 'content-range';
const CACHE_CONTROL = 'cache-control';
const IF_MODIFIED_SINCE = 'if-modified-since';
const IF_MATCH = 'if-match';
const IF_NONE_MATCH = 'if-none-match';
const IF_UNMODIFIED_SINCE = 'if-unmodified-since';
const RANGE = 'range';
const DATA_SERVICE_VERSION = 'dataserviceversion';
const MAX_DATA_SERVICE_VERSION = 'maxdataserviceversion';
const ACCEPT_HEADER = 'accept';
const ACCEPT_CHARSET = 'accept-charset';
const USER_AGENT = 'User-Agent';
// Type
const QUEUE_TYPE_NAME = 'IQueue';
const BLOB_TYPE_NAME = 'IBlob';
const TABLE_TYPE_NAME = 'ITable';
const SERVICE_MANAGEMENT_TYPE_NAME = 'IServiceManagement';
const SERVICE_BUS_TYPE_NAME = 'IServiceBus';
const WRAP_TYPE_NAME = 'IWrap';
// WRAP
const WRAP_ACCESS_TOKEN = 'wrap_access_token';
const WRAP_ACCESS_TOKEN_EXPIRES_IN = 'wrap_access_token_expires_in';
const WRAP_NAME = 'wrap_name';
const WRAP_PASSWORD = 'wrap_password';
const WRAP_SCOPE = 'wrap_scope';
// OAuth
const OAUTH_GRANT_TYPE = 'grant_type';
const OAUTH_CLIENT_ID = 'client_id';
const OAUTH_CLIENT_SECRET = 'client_secret';
const OAUTH_SCOPE = 'scope';
const OAUTH_GT_CLIENT_CREDENTIALS = 'client_credentials';
const OAUTH_ACCESS_TOKEN = 'access_token';
const OAUTH_EXPIRES_IN = 'expires_in';
const OAUTH_ACCESS_TOKEN_PREFIX = 'Bearer ';
// HTTP Methods
const HTTP_GET = 'GET';
const HTTP_PUT = 'PUT';
const HTTP_POST = 'POST';
const HTTP_HEAD = 'HEAD';
const HTTP_DELETE = 'DELETE';
const HTTP_MERGE = 'MERGE';
// Misc
const EMPTY_STRING = '';
const SEPARATOR = ',';
const AZURE_DATE_FORMAT = 'D, d M Y H:i:s T';
const TIMESTAMP_FORMAT = 'Y-m-d H:i:s';
const EMULATED = 'EMULATED';
const EMULATOR_BLOB_URI = '127.0.0.1:10000';
const EMULATOR_QUEUE_URI = '127.0.0.1:10001';
const EMULATOR_TABLE_URI = '127.0.0.1:10002';
const ASTERISK = '*';
const SERVICE_MANAGEMENT_URL = 'https://management.core.windows.net';
const HTTP_SCHEME = 'http';
const HTTPS_SCHEME = 'https';
const SETTING_NAME = 'SettingName';
const SETTING_CONSTRAINT = 'SettingConstraint';
const DEV_STORE_URI = 'http://127.0.0.1';
const SERVICE_URI_FORMAT = "%s://%s.%s";
const WRAP_ENDPOINT_URI_FORMAT = "https://%s-sb.accesscontrol.windows.net/WRAPv0.9";
// Xml Namespaces
const WA_XML_NAMESPACE = 'http://schemas.microsoft.com/windowsazure';
const ATOM_XML_NAMESPACE = 'http://www.w3.org/2005/Atom';
const DS_XML_NAMESPACE = 'http://schemas.microsoft.com/ado/2007/08/dataservices';
const DSM_XML_NAMESPACE = 'http://schemas.microsoft.com/ado/2007/08/dataservices/metadata';
const XSI_XML_NAMESPACE = 'http://www.w3.org/2001/XMLSchema-instance';
// Header values
const SDK_USER_AGENT = 'Azure-SDK-For-PHP/0.4.1';
const STORAGE_API_LATEST_VERSION = '2012-02-12';
const SM_API_LATEST_VERSION = '2011-10-01';
const DATA_SERVICE_VERSION_VALUE = '1.0;NetFx';
const MAX_DATA_SERVICE_VERSION_VALUE = '2.0;NetFx';
const ACCEPT_HEADER_VALUE = 'application/atom+xml,application/xml';
const ATOM_ENTRY_CONTENT_TYPE = 'application/atom+xml;type=entry;charset=utf-8';
const ATOM_FEED_CONTENT_TYPE = 'application/atom+xml;type=feed;charset=utf-8';
const ACCEPT_CHARSET_VALUE = 'utf-8';
const INT32_MAX = 2147483647;
const MEDIA_SERVICES_API_LATEST_VERSION = '2.2';
const MEDIA_SERVICES_DATA_SERVICE_VERSION_VALUE = '3.0;NetFx';
const MEDIA_SERVICES_MAX_DATA_SERVICE_VERSION_VALUE = '3.0;NetFx';
// Query parameter names
const QP_PREFIX = 'Prefix';
const QP_MAX_RESULTS = 'MaxResults';
const QP_METADATA = 'Metadata';
const QP_MARKER = 'Marker';
const QP_NEXT_MARKER = 'NextMarker';
const QP_COMP = 'comp';
const QP_VISIBILITY_TIMEOUT = 'visibilitytimeout';
const QP_POPRECEIPT = 'popreceipt';
const QP_NUM_OF_MESSAGES = 'numofmessages';
const QP_PEEK_ONLY = 'peekonly';
const QP_MESSAGE_TTL = 'messagettl';
const QP_INCLUDE = 'include';
const QP_TIMEOUT = 'timeout';
const QP_DELIMITER = 'Delimiter';
const QP_REST_TYPE = 'restype';
const QP_SNAPSHOT = 'snapshot';
const QP_BLOCKID = 'blockid';
const QP_BLOCK_LIST_TYPE = 'blocklisttype';
const QP_SELECT = '$select';
const QP_TOP = '$top';
const QP_SKIP = '$skip';
const QP_FILTER = '$filter';
const QP_NEXT_TABLE_NAME = 'NextTableName';
const QP_NEXT_PK = 'NextPartitionKey';
const QP_NEXT_RK = 'NextRowKey';
const QP_ACTION = 'action';
const QP_EMBED_DETAIL = 'embed-detail';
// Query parameter values
const QPV_REGENERATE = 'regenerate';
const QPV_CONFIG = 'config';
const QPV_STATUS = 'status';
const QPV_UPGRADE = 'upgrade';
const QPV_WALK_UPGRADE_DOMAIN = 'walkupgradedomain';
const QPV_REBOOT = 'reboot';
const QPV_REIMAGE = 'reimage';
const QPV_ROLLBACK = 'rollback';
// Request body content types
const URL_ENCODED_CONTENT_TYPE = 'application/x-www-form-urlencoded';
const XML_CONTENT_TYPE = 'application/xml';
const BINARY_FILE_TYPE = 'application/octet-stream';
const XML_ATOM_CONTENT_TYPE = 'application/atom+xml';
const HTTP_TYPE = 'application/http';
const MULTIPART_MIXED_TYPE = 'multipart/mixed';
// Common used XML tags
const XTAG_ATTRIBUTES = '@attributes';
const XTAG_NAMESPACE = '@namespace';
const XTAG_LABEL = 'Label';
const XTAG_NAME = 'Name';
const XTAG_DESCRIPTION = 'Description';
const XTAG_LOCATION = 'Location';
const XTAG_AFFINITY_GROUP = 'AffinityGroup';
const XTAG_HOSTED_SERVICES = 'HostedServices';
const XTAG_STORAGE_SERVICES = 'StorageServices';
const XTAG_STORAGE_SERVICE = 'StorageService';
const XTAG_DISPLAY_NAME = 'DisplayName';
const XTAG_SERVICE_NAME = 'ServiceName';
const XTAG_URL = 'Url';
const XTAG_ID = 'ID';
const XTAG_STATUS = 'Status';
const XTAG_HTTP_STATUS_CODE = 'HttpStatusCode';
const XTAG_CODE = 'Code';
const XTAG_MESSAGE = 'Message';
const XTAG_STORAGE_SERVICE_PROPERTIES = 'StorageServiceProperties';
const XTAG_ENDPOINT = 'Endpoint';
const XTAG_ENDPOINTS = 'Endpoints';
const XTAG_PRIMARY = 'Primary';
const XTAG_SECONDARY = 'Secondary';
const XTAG_KEY_TYPE = 'KeyType';
const XTAG_STORAGE_SERVICE_KEYS = 'StorageServiceKeys';
const XTAG_ERROR = 'Error';
const XTAG_HOSTED_SERVICE = 'HostedService';
const XTAG_HOSTED_SERVICE_PROPERTIES = 'HostedServiceProperties';
const XTAG_CREATE_HOSTED_SERVICE = 'CreateHostedService';
const XTAG_CREATE_STORAGE_SERVICE_INPUT = 'CreateStorageServiceInput';
const XTAG_UPDATE_STORAGE_SERVICE_INPUT = 'UpdateStorageServiceInput';
const XTAG_CREATE_AFFINITY_GROUP = 'CreateAffinityGroup';
const XTAG_UPDATE_AFFINITY_GROUP = 'UpdateAffinityGroup';
const XTAG_UPDATE_HOSTED_SERVICE = 'UpdateHostedService';
const XTAG_PACKAGE_URL = 'PackageUrl';
const XTAG_CONFIGURATION = 'Configuration';
const XTAG_START_DEPLOYMENT = 'StartDeployment';
const XTAG_TREAT_WARNINGS_AS_ERROR = 'TreatWarningsAsError';
const XTAG_CREATE_DEPLOYMENT = 'CreateDeployment';
const XTAG_DEPLOYMENT_SLOT = 'DeploymentSlot';
const XTAG_PRIVATE_ID = 'PrivateID';
const XTAG_ROLE_INSTANCE_LIST = 'RoleInstanceList';
const XTAG_UPGRADE_DOMAIN_COUNT = 'UpgradeDomainCount';
const XTAG_ROLE_LIST = 'RoleList';
const XTAG_SDK_VERSION = 'SdkVersion';
const XTAG_INPUT_ENDPOINT_LIST = 'InputEndpointList';
const XTAG_LOCKED = 'Locked';
const XTAG_ROLLBACK_ALLOWED = 'RollbackAllowed';
const XTAG_UPGRADE_STATUS = 'UpgradeStatus';
const XTAG_UPGRADE_TYPE = 'UpgradeType';
const XTAG_CURRENT_UPGRADE_DOMAIN_STATE = 'CurrentUpgradeDomainState';
const XTAG_CURRENT_UPGRADE_DOMAIN = 'CurrentUpgradeDomain';
const XTAG_ROLE_NAME = 'RoleName';
const XTAG_INSTANCE_NAME = 'InstanceName';
const XTAG_INSTANCE_STATUS = 'InstanceStatus';
const XTAG_INSTANCE_UPGRADE_DOMAIN = 'InstanceUpgradeDomain';
const XTAG_INSTANCE_FAULT_DOMAIN = 'InstanceFaultDomain';
const XTAG_INSTANCE_SIZE = 'InstanceSize';
const XTAG_INSTANCE_STATE_DETAILS = 'InstanceStateDetails';
const XTAG_INSTANCE_ERROR_CODE = 'InstanceErrorCode';
const XTAG_OS_VERSION = 'OsVersion';
const XTAG_ROLE_INSTANCE = 'RoleInstance';
const XTAG_ROLE = 'Role';
const XTAG_INPUT_ENDPOINT = 'InputEndpoint';
const XTAG_VIP = 'Vip';
const XTAG_PORT = 'Port';
const XTAG_DEPLOYMENT = 'Deployment';
const XTAG_DEPLOYMENTS = 'Deployments';
const XTAG_REGENERATE_KEYS = 'RegenerateKeys';
const XTAG_SWAP = 'Swap';
const XTAG_PRODUCTION = 'Production';
const XTAG_SOURCE_DEPLOYMENT = 'SourceDeployment';
const XTAG_CHANGE_CONFIGURATION = 'ChangeConfiguration';
const XTAG_MODE = 'Mode';
const XTAG_UPDATE_DEPLOYMENT_STATUS = 'UpdateDeploymentStatus';
const XTAG_ROLE_TO_UPGRADE = 'RoleToUpgrade';
const XTAG_FORCE = 'Force';
const XTAG_UPGRADE_DEPLOYMENT = 'UpgradeDeployment';
const XTAG_UPGRADE_DOMAIN = 'UpgradeDomain';
const XTAG_WALK_UPGRADE_DOMAIN = 'WalkUpgradeDomain';
const XTAG_ROLLBACK_UPDATE_OR_UPGRADE = 'RollbackUpdateOrUpgrade';
const XTAG_CONTAINER_NAME = 'ContainerName';
const XTAG_ACCOUNT_NAME = 'AccountName';
// Service Bus
const LIST_TOPICS_PATH = '$Resources/Topics';
const LIST_QUEUES_PATH = '$Resources/Queues';
const LIST_RULES_PATH = '%s/subscriptions/%s/rules';
const LIST_SUBSCRIPTIONS_PATH = '%s/subscriptions';
const RECEIVE_MESSAGE_PATH = '%s/messages/head';
const RECEIVE_SUBSCRIPTION_MESSAGE_PATH = '%s/subscriptions/%s/messages/head';
const SEND_MESSAGE_PATH = '%s/messages';
const RULE_PATH = '%s/subscriptions/%s/rules/%s';
const SUBSCRIPTION_PATH = '%s/subscriptions/%s';
const DEFAULT_RULE_NAME = '$Default';
const UNIQUE_ID_PREFIX = 'urn:uuid:';
const SERVICE_BUS_NAMESPACE = 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect';
const BROKER_PROPERTIES = 'BrokerProperties';
const XMLNS_ATOM = 'xmlns:atom';
const XMLNS = 'xmlns';
const ATOM_NAMESPACE = 'http://www.w3.org/2005/Atom';
// ATOM string
const AUTHOR = 'author';
const CATEGORY = 'category';
const CONTRIBUTOR = 'contributor';
const ENTRY = 'entry';
const LINK = 'link';
const PROPERTIES = 'properties';
const ELEMENT = 'element';
// PHP URL Keys
const PHP_URL_SCHEME = 'scheme';
const PHP_URL_HOST = 'host';
const PHP_URL_PORT = 'port';
const PHP_URL_USER = 'user';
const PHP_URL_PASS = 'pass';
const PHP_URL_PATH = 'path';
const PHP_URL_QUERY = 'query';
const PHP_URL_FRAGMENT = 'fragment';
// Status Codes
const STATUS_OK = 200;
const STATUS_CREATED = 201;
const STATUS_ACCEPTED = 202;
const STATUS_NO_CONTENT = 204;
const STATUS_PARTIAL_CONTENT = 206;
const STATUS_MOVED_PERMANENTLY = 301;
// HTTP_Request2 config parameter names
const USE_BRACKETS = 'use_brackets';
const SSL_VERIFY_PEER = 'ssl_verify_peer';
const SSL_VERIFY_HOST = 'ssl_verify_host';
const SSL_LOCAL_CERT = 'ssl_local_cert';
const SSL_CAFILE = 'ssl_cafile';
const CONNECT_TIMEOUT = 'connect_timeout';
// Media services
const MEDIA_SERVICES_URL = 'https://media.windows.net/API/';
const MEDIA_SERVICES_OAUTH_URL = 'https://wamsprodglobal001acs.accesscontrol.windows.net/v2/OAuth2-13';
const MEDIA_SERVICES_OAUTH_SCOPE = 'urn:WindowsAzureMediaServices';
const MEDIA_SERVICES_INPUT_ASSETS_REL = 'http://schemas.microsoft.com/ado/2007/08/dataservices/related/InputMediaAssets';
const MEDIA_SERVICES_ASSET_REL = 'http://schemas.microsoft.com/ado/2007/08/dataservices/related/Asset';
const MEDIA_SERVICES_ENCRYPTION_VERSION = '1.0';
// @codingStandardsIgnoreEnd
}
PK �]&�Uˉ* �* ConnectionStringParser.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
/**
* Helper methods for parsing connection strings. The rules for formatting connection
* strings are defined here:
* www.connectionstrings.com/articles/show/important-rules-for-connection-strings
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class ConnectionStringParser
{
/**
* @var string
*/
private $_argumentName;
/**
* @var string
*/
private $_value;
/**
* @var integer
*/
private $_pos;
/**
* @var string
*/
private $_state;
/**
* Parses the connection string into a collection of key/value pairs.
*
* @param string $argumentName Name of the argument to be used in error
* messages.
* @param string $connectionString Connection string.
*
* @return array
*
* @static
*/
public static function parseConnectionString($argumentName, $connectionString)
{
Validate::isString($argumentName, 'argumentName');
Validate::notNullOrEmpty($argumentName, 'argumentName');
Validate::isString($connectionString, 'connectionString');
Validate::notNullOrEmpty($connectionString, 'connectionString');
$parser = new ConnectionStringParser($argumentName, $connectionString);
return $parser->_parse();
}
/**
* Initializes the object.
*
* @param string $argumentName Name of the argument to be used in error
* messages.
* @param string $value Connection string.
*/
private function __construct($argumentName, $value)
{
$this->_argumentName = $argumentName;
$this->_value = $value;
$this->_pos = 0;
$this->_state = ParserState::EXPECT_KEY;
}
/**
* Parses the connection string.
*
* @return array
*
* @throws \RuntimeException
*/
private function _parse()
{
$key = null;
$value = null;
$connectionStringValues = array();
while (true) {
$this->_skipWhiteSpaces();
if ( $this->_pos == strlen($this->_value)
&& $this->_state != ParserState::EXPECT_VALUE
) {
// Not stopping after the end has been reached and a value is
// expected results in creating an empty value, which we expect.
break;
}
switch ($this->_state) {
case ParserState::EXPECT_KEY:
$key = $this->_extractKey();
$this->_state = ParserState::EXPECT_ASSIGNMENT;
break;
case ParserState::EXPECT_ASSIGNMENT:
$this->_skipOperator('=');
$this->_state = ParserState::EXPECT_VALUE;
break;
case ParserState::EXPECT_VALUE:
$value = $this->_extractValue();
$this->_state = ParserState::EXPECT_SEPARATOR;
$connectionStringValues[$key] = $value;
$key = null;
$value = null;
break;
default:
$this->_skipOperator(';');
$this->_state = ParserState::EXPECT_KEY;
break;
}
}
// Must end parsing in the valid state (expected key or separator)
if ($this->_state == ParserState::EXPECT_ASSIGNMENT) {
throw $this->_createException(
$this->_pos,
Resources::MISSING_CONNECTION_STRING_CHAR,
'='
);
}
return $connectionStringValues;
}
/**
*Generates an invalid connection string exception with the detailed error
* message.
*
* @param integer $position The position of the error.
* @param string $errorString The short error formatting string.
*
* @return \RuntimeException
*/
private function _createException($position, $errorString)
{
$arguments = func_get_args();
// Remove first argument (position)
unset($arguments[0]);
// Create a short error message.
$errorString = sprintf($errorString, $arguments);
// Add position.
$errorString = sprintf(
Resources::ERROR_PARSING_STRING,
$errorString,
$position
);
// Create final error message.
$errorString = sprintf(
Resources::INVALID_CONNECTION_STRING,
$this->_argumentName,
$errorString
);
return new \RuntimeException($errorString);
}
/**
* Skips whitespaces at the current position.
*
* @return none
*/
private function _skipWhiteSpaces()
{
while ( $this->_pos < strlen($this->_value)
&& ctype_space($this->_value[$this->_pos])
) {
$this->_pos++;
}
}
/**
* Extracts the key's value.
*
* @return string
*/
private function _extractValue()
{
$value = Resources::EMPTY_STRING;
if ($this->_pos < strlen($this->_value)) {
$ch = $this->_value[$this->_pos];
if ($ch == '"' || $ch == '\'') {
// Value is contained between double quotes or skipped single quotes.
$this->_pos++;
$value = $this->_extractString($ch);
} else {
$firstPos = $this->_pos;
$isFound = false;
while ($this->_pos < strlen($this->_value) && !$isFound) {
$ch = $this->_value[$this->_pos];
if ($ch == ';') {
$isFound = true;
} else {
$this->_pos++;
}
}
$value = rtrim(
substr($this->_value, $firstPos, $this->_pos - $firstPos)
);
}
}
return $value;
}
/**
* Extracts key at the current position.
*
* @return string
*/
private function _extractKey()
{
$key = null;
$firstPos = $this->_pos;
$ch = $this->_value[$this->_pos];
if ($ch == '"' || $ch == '\'') {
$this->_pos++;
$key = $this->_extractString($ch);
} else if ($ch == ';' || $ch == '=') {
// Key name was expected.
throw $this->_createException(
$firstPos,
Resources::ERROR_CONNECTION_STRING_MISSING_KEY
);
} else {
while ($this->_pos < strlen($this->_value)) {
$ch = $this->_value[$this->_pos];
// At this point we've read the key, break.
if ($ch == '=') {
break;
}
$this->_pos++;
}
$key = rtrim(substr($this->_value, $firstPos, $this->_pos - $firstPos));
}
if (strlen($key) == 0) {
// Empty key name.
throw $this->_createException(
$firstPos,
Resources::ERROR_CONNECTION_STRING_EMPTY_KEY
);
}
return $key;
}
/**
* Extracts the string until the given quotation mark.
*
* @param string $quote The quotation mark terminating the string.
*
* @return string
*/
private function _extractString($quote)
{
$firstPos = $this->_pos;
while ( $this->_pos < strlen($this->_value)
&& $this->_value[$this->_pos] != $quote
) {
$this->_pos++;
}
if ($this->_pos == strlen($this->_value)) {
// Runaway string.
throw $this->_createException(
$this->_pos,
Resources::ERROR_CONNECTION_STRING_MISSING_CHARACTER,
$quote
);
}
return substr($this->_value, $firstPos, $this->_pos++ - $firstPos);
}
/**
* Skips specified operator.
*
* @param string $operatorChar The operator character.
*
* @return none
*
* @throws \RuntimeException
*/
private function _skipOperator($operatorChar)
{
if ($this->_value[$this->_pos] != $operatorChar) {
// Character was expected.
throw $this->_createException(
$this->_pos,
Resources::MISSING_CONNECTION_STRING_CHAR,
$operatorChar
);
}
$this->_pos++;
}
}
/**
* State of the connection string parser.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class ParserState
{
const EXPECT_KEY = 'ExpectKey';
const EXPECT_ASSIGNMENT = 'ExpectAssignment';
const EXPECT_VALUE = 'ExpectValue';
const EXPECT_SEPARATOR = 'ExpectSeparator';
}PK �]�x��*8 *8 StorageServiceSettings.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
use WindowsAzure\Common\Internal\ConnectionStringParser;
use WindowsAzure\Common\Internal\Resources;
/**
* Represents the settings used to sign and access a request against the storage
* service. For more information about storage service connection strings check this
* page: http://msdn.microsoft.com/en-us/library/ee758697
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class StorageServiceSettings extends ServiceSettings
{
/**
* The storage service name.
*
* @var string
*/
private $_name;
/**
* A base64 representation.
*
* @var string
*/
private $_key;
/**
* The endpoint for the blob service.
*
* @var string
*/
private $_blobEndpointUri;
/**
* The endpoint for the queue service.
*
* @var string
*/
private $_queueEndpointUri;
/**
* The endpoint for the table service.
*
* @var string
*/
private $_tableEndpointUri;
/**
* @var StorageServiceSettings
*/
private static $_devStoreAccount;
/**
* Validator for the UseDevelopmentStorage setting. Must be "true".
*
* @var array
*/
private static $_useDevelopmentStorageSetting;
/**
* Validator for the DevelopmentStorageProxyUri setting. Must be a valid Uri.
*
* @var array
*/
private static $_developmentStorageProxyUriSetting;
/**
* Validator for the DefaultEndpointsProtocol setting. Must be either "http"
* or "https".
*
* @var array
*/
private static $_defaultEndpointsProtocolSetting;
/**
* Validator for the AccountName setting. No restrictions.
*
* @var array
*/
private static $_accountNameSetting;
/**
* Validator for the AccountKey setting. Must be a valid base64 string.
*
* @var array
*/
private static $_accountKeySetting;
/**
* Validator for the BlobEndpoint setting. Must be a valid Uri.
*
* @var array
*/
private static $_blobEndpointSetting;
/**
* Validator for the QueueEndpoint setting. Must be a valid Uri.
*
* @var array
*/
private static $_queueEndpointSetting;
/**
* Validator for the TableEndpoint setting. Must be a valid Uri.
*
* @var array
*/
private static $_tableEndpointSetting;
/**
* @var boolean
*/
protected static $isInitialized = false;
/**
* Holds the expected setting keys.
*
* @var array
*/
protected static $validSettingKeys = array();
/**
* Initializes static members of the class.
*
* @return none
*/
protected static function init()
{
self::$_useDevelopmentStorageSetting = self::setting(
Resources::USE_DEVELOPMENT_STORAGE_NAME,
'true'
);
self::$_developmentStorageProxyUriSetting = self::settingWithFunc(
Resources::DEVELOPMENT_STORAGE_PROXY_URI_NAME,
Validate::getIsValidUri()
);
self::$_defaultEndpointsProtocolSetting = self::setting(
Resources::DEFAULT_ENDPOINTS_PROTOCOL_NAME,
'http', 'https'
);
self::$_accountNameSetting = self::setting(Resources::ACCOUNT_NAME_NAME);
self::$_accountKeySetting = self::settingWithFunc(
Resources::ACCOUNT_KEY_NAME,
// base64_decode will return false if the $key is not in base64 format.
function ($key) {
$isValidBase64String = base64_decode($key, true);
if ($isValidBase64String) {
return true;
} else {
throw new \RuntimeException(
sprintf(Resources::INVALID_ACCOUNT_KEY_FORMAT, $key)
);
}
}
);
self::$_blobEndpointSetting = self::settingWithFunc(
Resources::BLOB_ENDPOINT_NAME,
Validate::getIsValidUri()
);
self::$_queueEndpointSetting = self::settingWithFunc(
Resources::QUEUE_ENDPOINT_NAME,
Validate::getIsValidUri()
);
self::$_tableEndpointSetting = self::settingWithFunc(
Resources::TABLE_ENDPOINT_NAME,
Validate::getIsValidUri()
);
self::$validSettingKeys[] = Resources::USE_DEVELOPMENT_STORAGE_NAME;
self::$validSettingKeys[] = Resources::DEVELOPMENT_STORAGE_PROXY_URI_NAME;
self::$validSettingKeys[] = Resources::DEFAULT_ENDPOINTS_PROTOCOL_NAME;
self::$validSettingKeys[] = Resources::ACCOUNT_NAME_NAME;
self::$validSettingKeys[] = Resources::ACCOUNT_KEY_NAME;
self::$validSettingKeys[] = Resources::BLOB_ENDPOINT_NAME;
self::$validSettingKeys[] = Resources::QUEUE_ENDPOINT_NAME;
self::$validSettingKeys[] = Resources::TABLE_ENDPOINT_NAME;
}
/**
* Creates new storage service settings instance.
*
* @param string $name The storage service name.
* @param string $key The storage service key.
* @param string $blobEndpointUri The sotrage service blob endpoint.
* @param string $queueEndpointUri The sotrage service queue endpoint.
* @param string $tableEndpointUri The sotrage service table endpoint.
*/
public function __construct(
$name,
$key,
$blobEndpointUri,
$queueEndpointUri,
$tableEndpointUri
) {
$this->_name = $name;
$this->_key = $key;
$this->_blobEndpointUri = $blobEndpointUri;
$this->_queueEndpointUri = $queueEndpointUri;
$this->_tableEndpointUri = $tableEndpointUri;
}
/**
* Returns a StorageServiceSettings with development storage credentials using
* the specified proxy Uri.
*
* @param string $proxyUri The proxy endpoint to use.
*
* @return StorageServiceSettings
*/
private static function _getDevelopmentStorageAccount($proxyUri)
{
if (is_null($proxyUri)) {
return self::developmentStorageAccount();
}
$scheme = parse_url($proxyUri, PHP_URL_SCHEME);
$host = parse_url($proxyUri, PHP_URL_HOST);
$prefix = $scheme . "://" . $host;
return new StorageServiceSettings(
Resources::DEV_STORE_NAME,
Resources::DEV_STORE_KEY,
$prefix . ':10000/devstoreaccount1/',
$prefix . ':10001/devstoreaccount1/',
$prefix . ':10002/devstoreaccount1/'
);
}
/**
* Gets a StorageServiceSettings object that references the development storage
* account.
*
* @return StorageServiceSettings
*/
public static function developmentStorageAccount()
{
if (is_null(self::$_devStoreAccount)) {
self::$_devStoreAccount = self::_getDevelopmentStorageAccount(
Resources::DEV_STORE_URI
);
}
return self::$_devStoreAccount;
}
/**
* Gets the default service endpoint using the specified protocol and account
* name.
*
* @param array $settings The service settings.
* @param string $dns The service DNS.
*
* @return string
*/
private static function _getDefaultServiceEndpoint($settings, $dns)
{
$scheme = Utilities::tryGetValueInsensitive(
Resources::DEFAULT_ENDPOINTS_PROTOCOL_NAME,
$settings
);
$accountName = Utilities::tryGetValueInsensitive(
Resources::ACCOUNT_NAME_NAME,
$settings
);
return sprintf(Resources::SERVICE_URI_FORMAT, $scheme, $accountName, $dns);
}
/**
* Creates StorageServiceSettings object given endpoints uri.
*
* @param array $settings The service settings.
* @param string $blobEndpointUri The blob endpoint uri.
* @param string $queueEndpointUri The queue endpoint uri.
* @param string $tableEndpointUri The table endpoint uri.
*
* @return \WindowsAzure\Common\Internal\StorageServiceSettings
*/
private static function _createStorageServiceSettings(
$settings,
$blobEndpointUri = null,
$queueEndpointUri = null,
$tableEndpointUri = null
) {
$blobEndpointUri = Utilities::tryGetValueInsensitive(
Resources::BLOB_ENDPOINT_NAME,
$settings,
$blobEndpointUri
);
$queueEndpointUri = Utilities::tryGetValueInsensitive(
Resources::QUEUE_ENDPOINT_NAME,
$settings,
$queueEndpointUri
);
$tableEndpointUri = Utilities::tryGetValueInsensitive(
Resources::TABLE_ENDPOINT_NAME,
$settings,
$tableEndpointUri
);
$accountName = Utilities::tryGetValueInsensitive(
Resources::ACCOUNT_NAME_NAME,
$settings
);
$accountKey = Utilities::tryGetValueInsensitive(
Resources::ACCOUNT_KEY_NAME,
$settings
);
return new StorageServiceSettings(
$accountName,
$accountKey,
$blobEndpointUri,
$queueEndpointUri,
$tableEndpointUri
);
}
/**
* Creates a StorageServiceSettings object from the given connection string.
*
* @param string $connectionString The storage settings connection string.
*
* @return StorageServiceSettings
*/
public static function createFromConnectionString($connectionString)
{
$tokenizedSettings = self::parseAndValidateKeys($connectionString);
// Devstore case
$matchedSpecs = self::matchedSpecification(
$tokenizedSettings,
self::allRequired(self::$_useDevelopmentStorageSetting),
self::optional(self::$_developmentStorageProxyUriSetting)
);
if ($matchedSpecs) {
$proxyUri = Utilities::tryGetValueInsensitive(
Resources::DEVELOPMENT_STORAGE_PROXY_URI_NAME,
$tokenizedSettings
);
return self::_getDevelopmentStorageAccount($proxyUri);
}
// Automatic case
$matchedSpecs = self::matchedSpecification(
$tokenizedSettings,
self::allRequired(
self::$_defaultEndpointsProtocolSetting,
self::$_accountNameSetting,
self::$_accountKeySetting
),
self::optional(
self::$_blobEndpointSetting,
self::$_queueEndpointSetting,
self::$_tableEndpointSetting
)
);
if ($matchedSpecs) {
return self::_createStorageServiceSettings(
$tokenizedSettings,
self::_getDefaultServiceEndpoint(
$tokenizedSettings,
Resources::BLOB_BASE_DNS_NAME
),
self::_getDefaultServiceEndpoint(
$tokenizedSettings,
Resources::QUEUE_BASE_DNS_NAME
),
self::_getDefaultServiceEndpoint(
$tokenizedSettings,
Resources::TABLE_BASE_DNS_NAME
)
);
}
// Explicit case
$matchedSpecs = self::matchedSpecification(
$tokenizedSettings,
self::atLeastOne(
self::$_blobEndpointSetting,
self::$_queueEndpointSetting,
self::$_tableEndpointSetting
),
self::allRequired(
self::$_accountNameSetting,
self::$_accountKeySetting
)
);
if ($matchedSpecs) {
return self::_createStorageServiceSettings($tokenizedSettings);
}
self::noMatch($connectionString);
}
/**
* Gets storage service name.
*
* @return string
*/
public function getName()
{
return $this->_name;
}
/**
* Gets storage service key.
*
* @return string
*/
public function getKey()
{
return $this->_key;
}
/**
* Gets storage service blob endpoint uri.
*
* @return string
*/
public function getBlobEndpointUri()
{
return $this->_blobEndpointUri;
}
/**
* Gets storage service queue endpoint uri.
*
* @return string
*/
public function getQueueEndpointUri()
{
return $this->_queueEndpointUri;
}
/**
* Gets storage service table endpoint uri.
*
* @return string
*/
public function getTableEndpointUri()
{
return $this->_tableEndpointUri;
}
}
PK �]�@�� Serialization/.htaccessnu ��6�$ <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
Deny from all
</FilesMatch>
</IfModule>PK �]�Y� � Serialization/JsonSerializer.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Serialization
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal\Serialization;
use WindowsAzure\Common\Internal\Validate;
/**
* Perform JSON serialization / deserialization
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Serialization
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class JsonSerializer implements ISerializer
{
/**
* Serialize an object with specified root element name.
*
* @param object $targetObject The target object.
* @param string $rootName The name of the root element.
*
* @return string
*/
public static function objectSerialize($targetObject, $rootName)
{
Validate::notNull($targetObject, 'targetObject');
Validate::isString($rootName, 'rootName');
$contianer = new \stdClass();
$contianer->$rootName = $targetObject;
return json_encode($contianer);
}
/**
* Serializes given array. The array indices must be string to use them as
* as element name.
*
* @param array $array The object to serialize represented in array.
* @param array $properties The used properties in the serialization process.
*
* @return string
*/
public function serialize($array, $properties = null)
{
Validate::isArray($array, 'array');
return json_encode($array);
}
/**
* Unserializes given serialized string to array.
*
* @param string $serialized The serialized object in string representation.
*
* @return array
*/
public function unserialize($serialized)
{
Validate::isString($serialized, 'serialized');
$json = json_decode($serialized);
if ($json && !is_array($json)) {
return get_object_vars($json);
} else {
return $json;
}
}
}
PK �]�P�e� � Serialization/XmlSerializer.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Serialization
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal\Serialization;
use WindowsAzure\Common\Internal\Utilities;
use WindowsAzure\Common\Internal\Resources;
use WindowsAzure\Common\Internal\Validate;
/**
* Short description
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Serialization
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class XmlSerializer implements ISerializer
{
const STANDALONE = 'standalone';
const ROOT_NAME = 'rootName';
const DEFAULT_TAG = 'defaultTag';
/**
* Converts a SimpleXML object to an Array recursively
* ensuring all sub-elements are arrays as well.
*
* @param string $sxml The SimpleXML object.
* @param array $arr The array into which to store results.
*
* @return array
*/
private function _sxml2arr($sxml, $arr = null)
{
foreach ((array) $sxml as $key => $value) {
if (is_object($value) || (is_array($value))) {
$arr[$key] = $this->_sxml2arr($value);
} else {
$arr[$key] = $value;
}
}
return $arr;
}
/**
* Takes an array and produces XML based on it.
*
* @param XMLWriter $xmlw XMLWriter object that was previously instanted
* and is used for creating the XML.
* @param array $data Array to be converted to XML.
* @param string $defaultTag Default XML tag to be used if none specified.
*
* @return void
*/
private function _arr2xml(\XMLWriter $xmlw, $data, $defaultTag = null)
{
foreach ($data as $key => $value) {
if ($key === Resources::XTAG_ATTRIBUTES) {
foreach ($value as $attributeName => $attributeValue) {
$xmlw->writeAttribute($attributeName, $attributeValue);
}
} else if (is_array($value)) {
if (!is_int($key)) {
if ($key != Resources::EMPTY_STRING) {
$xmlw->startElement($key);
} else {
$xmlw->startElement($defaultTag);
}
}
$this->_arr2xml($xmlw, $value);
if (!is_int($key)) {
$xmlw->endElement();
}
} else {
$xmlw->writeElement($key, $value);
}
}
}
/**
* Gets the attributes of a specified object if get attributes
* method is exposed.
*
* @param object $targetObject The target object.
* @param array $methodArray The array of method of the target object.
*
* @return mixed
*/
private static function _getInstanceAttributes($targetObject, $methodArray)
{
foreach ($methodArray as $method) {
if ($method->name == 'getAttributes') {
$classProperty = $method->invoke($targetObject);
return $classProperty;
}
}
return null;
}
/**
* Serialize an object with specified root element name.
*
* @param object $targetObject The target object.
* @param string $rootName The name of the root element.
*
* @return string
*/
public static function objectSerialize($targetObject, $rootName)
{
Validate::notNull($targetObject, 'targetObject');
Validate::isString($rootName, 'rootName');
$xmlWriter = new \XmlWriter();
$xmlWriter->openMemory();
$xmlWriter->setIndent(true);
$reflectionClass = new \ReflectionClass($targetObject);
$methodArray = $reflectionClass->getMethods();
$attributes = self::_getInstanceAttributes(
$targetObject,
$methodArray
);
$xmlWriter->startElement($rootName);
if (!is_null($attributes)) {
foreach (array_keys($attributes) as $attributeKey) {
$xmlWriter->writeAttribute(
$attributeKey,
$attributes[$attributeKey]
);
}
}
foreach ($methodArray as $method) {
if ((strpos($method->name, 'get') === 0)
&& $method->isPublic()
&& ($method->name != 'getAttributes')
) {
$variableName = substr($method->name, 3);
$variableValue = $method->invoke($targetObject);
if (!empty($variableValue)) {
if (gettype($variableValue) === 'object') {
$xmlWriter->writeRaw(
XmlSerializer::objectSerialize(
$variableValue, $variableName
)
);
} else {
$xmlWriter->writeElement($variableName, $variableValue);
}
}
}
}
$xmlWriter->endElement();
return $xmlWriter->outputMemory(true);
}
/**
* Serializes given array. The array indices must be string to use them as
* as element name.
*
* @param array $array The object to serialize represented in array.
* @param array $properties The used properties in the serialization process.
*
* @return string
*/
public function serialize($array, $properties = null)
{
$xmlVersion = '1.0';
$xmlEncoding = 'UTF-8';
$standalone = Utilities::tryGetValue($properties, self::STANDALONE);
$defaultTag = Utilities::tryGetValue($properties, self::DEFAULT_TAG);
$rootName = Utilities::tryGetValue($properties, self::ROOT_NAME);
$docNamespace = Utilities::tryGetValue(
$array,
Resources::XTAG_NAMESPACE,
null
);
if (!is_array($array)) {
return false;
}
$xmlw = new \XmlWriter();
$xmlw->openMemory();
$xmlw->setIndent(true);
$xmlw->startDocument($xmlVersion, $xmlEncoding, $standalone);
if (is_null($docNamespace)) {
$xmlw->startElement($rootName);
} else {
foreach ($docNamespace as $uri => $prefix) {
$xmlw->startElementNS($prefix, $rootName, $uri);
break;
}
}
unset($array[Resources::XTAG_NAMESPACE]);
self::_arr2xml($xmlw, $array, $defaultTag);
$xmlw->endElement();
return $xmlw->outputMemory(true);
}
/**
* Unserializes given serialized string.
*
* @param string $serialized The serialized object in string representation.
*
* @return array
*/
public function unserialize($serialized)
{
$sxml = new \SimpleXMLElement($serialized);
return $this->_sxml2arr($sxml);
}
}
PK �]vG�� � Serialization/ISerializer.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Serialization
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal\Serialization;
/**
* The serialization interface.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Serialization
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
interface ISerializer
{
/**
* Serialize an object into a XML.
*
* @param Object $targetObject The target object to be serialized.
* @param string $rootName The name of the root.
*
* @return string
*/
public static function objectSerialize($targetObject, $rootName);
/**
* Serializes given array. The array indices must be string to use them as
* as element name.
*
* @param array $array The object to serialize represented in array.
* @param array $properties The used properties in the serialization process.
*
* @return string
*/
public function serialize($array, $properties = null);
/**
* Unserializes given serialized string.
*
* @param string $serialized The serialized object in string representation.
*
* @return array
*/
public function unserialize($serialized);
}
PK �]���� �
Logger.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
/**
* Logger class for debugging purpose.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class Logger
{
/**
* @var string
*/
private static $_filePath;
/**
* Logs $var to file.
*
* @param mix $var The data to log.
* @param string $tip The help message.
*
* @static
*
* @return none
*/
public static function log($var, $tip = Resources::EMPTY_STRING)
{
if (!empty($tip)) {
error_log($tip . "\n", 3, self::$_filePath);
}
if (is_array($var) || is_object($var)) {
error_log(print_r($var, true), 3, self::$_filePath);
} else {
error_log($var . "\n", 3, self::$_filePath);
}
}
/**
* Sets file path to use.
*
* @param string $filePath The log file path.
*
* @static
*
* @return none
*/
public static function setLogFile($filePath)
{
self::$_filePath = $filePath;
}
}
PK �]�o��) �) ServiceRestProxy.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
use WindowsAzure\Common\Internal\Resources;
use WindowsAzure\Common\Internal\Validate;
use WindowsAzure\Common\Internal\Utilities;
use WindowsAzure\Common\Internal\RestProxy;
use WindowsAzure\Common\Internal\Http\Url;
use WindowsAzure\Common\Internal\Http\HttpCallContext;
/**
* Base class for all services rest proxies.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class ServiceRestProxy extends RestProxy
{
/**
* @var string
*/
private $_accountName;
/**
* Initializes new ServiceRestProxy object.
*
* @param IHttpClient $channel The HTTP client used to send HTTP requests.
* @param string $uri The storage account uri.
* @param string $accountName The name of the account.
* @param ISerializer $dataSerializer The data serializer.
*/
public function __construct($channel, $uri, $accountName, $dataSerializer)
{
parent::__construct($channel, $dataSerializer, $uri);
$this->_accountName = $accountName;
}
/**
* Gets the account name.
*
* @return string
*/
public function getAccountName()
{
return $this->_accountName;
}
/**
* Sends HTTP request with the specified HTTP call context.
*
* @param WindowsAzure\Common\Internal\Http\HttpCallContext $context The HTTP
* call context.
*
* @return \HTTP_Request2_Response
*/
protected function sendContext($context)
{
$context->setUri($this->getUri());
return parent::sendContext($context);
}
/**
* Sends HTTP request with the specified parameters.
*
* @param string $method HTTP method used in the request
* @param array $headers HTTP headers.
* @param array $queryParams URL query parameters.
* @param array $postParameters The HTTP POST parameters.
* @param string $path URL path
* @param int $statusCode Expected status code received in the response
* @param string $body Request body
*
* @return \HTTP_Request2_Response
*/
protected function send(
$method,
$headers,
$queryParams,
$postParameters,
$path,
$statusCode,
$body = Resources::EMPTY_STRING
) {
$context = new HttpCallContext();
$context->setBody($body);
$context->setHeaders($headers);
$context->setMethod($method);
$context->setPath($path);
$context->setQueryParameters($queryParams);
$context->setPostParameters($postParameters);
if (is_array($statusCode)) {
$context->setStatusCodes($statusCode);
} else {
$context->addStatusCode($statusCode);
}
return $this->sendContext($context);
}
/**
* Adds optional header to headers if set
*
* @param array $headers The array of request headers.
* @param AccessCondition $accessCondition The access condition object.
*
* @return array
*/
public function addOptionalAccessConditionHeader($headers, $accessCondition)
{
if (!is_null($accessCondition)) {
$header = $accessCondition->getHeader();
if ($header != Resources::EMPTY_STRING) {
$value = $accessCondition->getValue();
if ($value instanceof \DateTime) {
$value = gmdate(
Resources::AZURE_DATE_FORMAT,
$value->getTimestamp()
);
}
$headers[$header] = $value;
}
}
return $headers;
}
/**
* Adds optional header to headers if set
*
* @param array $headers The array of request headers.
* @param AccessCondition $accessCondition The access condition object.
*
* @return array
*/
public function addOptionalSourceAccessConditionHeader(
$headers,
$accessCondition
) {
if (!is_null($accessCondition)) {
$header = $accessCondition->getHeader();
$headerName = null;
if (!empty($header)) {
switch($header) {
case Resources::IF_MATCH:
$headerName = Resources::X_MS_SOURCE_IF_MATCH;
break;
case Resources::IF_UNMODIFIED_SINCE:
$headerName = Resources::X_MS_SOURCE_IF_UNMODIFIED_SINCE;
break;
case Resources::IF_MODIFIED_SINCE:
$headerName = Resources::X_MS_SOURCE_IF_MODIFIED_SINCE;
break;
case Resources::IF_NONE_MATCH:
$headerName = Resources::X_MS_SOURCE_IF_NONE_MATCH;
break;
default:
throw new \Exception(Resources::INVALID_ACH_MSG);
break;
}
}
$value = $accessCondition->getValue();
if ($value instanceof \DateTime) {
$value = gmdate(
Resources::AZURE_DATE_FORMAT,
$value->getTimestamp()
);
}
$this->addOptionalHeader($headers, $headerName, $value);
}
return $headers;
}
/**
* Adds HTTP POST parameter to the specified
*
* @param array $postParameters An array of HTTP POST parameters.
* @param string $key The key of a HTTP POST parameter.
* @param string $value the value of a HTTP POST parameter.
*
* @return array
*/
public function addPostParameter(
$postParameters,
$key,
$value
) {
Validate::isArray($postParameters, 'postParameters');
$postParameters[$key] = $value;
return $postParameters;
}
/**
* Groups set of values into one value separated with Resources::SEPARATOR
*
* @param array $values array of values to be grouped.
*
* @return string
*/
public function groupQueryValues($values)
{
Validate::isArray($values, 'values');
$joined = Resources::EMPTY_STRING;
foreach ($values as $value) {
if (!is_null($value) && !empty($value)) {
$joined .= $value . Resources::SEPARATOR;
}
}
return trim($joined, Resources::SEPARATOR);
}
/**
* Adds metadata elements to headers array
*
* @param array $headers HTTP request headers
* @param array $metadata user specified metadata
*
* @return array
*/
protected function addMetadataHeaders($headers, $metadata)
{
$this->validateMetadata($metadata);
$metadata = $this->generateMetadataHeaders($metadata);
$headers = array_merge($headers, $metadata);
return $headers;
}
/**
* Generates metadata headers by prefixing each element with 'x-ms-meta'.
*
* @param array $metadata user defined metadata.
*
* @return array.
*/
public function generateMetadataHeaders($metadata)
{
$metadataHeaders = array();
if (is_array($metadata) && !is_null($metadata)) {
foreach ($metadata as $key => $value) {
$headerName = Resources::X_MS_META_HEADER_PREFIX;
if ( strpos($value, "\r") !== false
|| strpos($value, "\n") !== false
) {
throw new \InvalidArgumentException(Resources::INVALID_META_MSG);
}
$headerName .= strtolower($key);
$metadataHeaders[$headerName] = $value;
}
}
return $metadataHeaders;
}
/**
* Gets metadata array by parsing them from given headers.
*
* @param array $headers HTTP headers containing metadata elements.
*
* @return array.
*/
public function getMetadataArray($headers)
{
$metadata = array();
foreach ($headers as $key => $value) {
$isMetadataHeader = Utilities::startsWith(
strtolower($key),
Resources::X_MS_META_HEADER_PREFIX
);
if ($isMetadataHeader) {
$MetadataName = str_replace(
Resources::X_MS_META_HEADER_PREFIX,
Resources::EMPTY_STRING,
strtolower($key)
);
$metadata[$MetadataName] = $value;
}
}
return $metadata;
}
/**
* Validates the provided metadata array.
*
* @param mix $metadata The metadata array.
*
* @return none
*/
public function validateMetadata($metadata)
{
if (!is_null($metadata)) {
Validate::isArray($metadata, 'metadata');
} else {
$metadata = array();
}
foreach ($metadata as $key => $value) {
Validate::isString($key, 'metadata key');
Validate::isString($value, 'metadata value');
}
}
}
PK �]����X
X
ConnectionStringSource.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
/**
* Holder for default connection string sources used in CloudConfigurationManager.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class ConnectionStringSource
{
/**
* The list of all sources which comes as default.
*
* @var type
*/
private static $_defaultSources;
/**
* @var boolean
*/
private static $_isInitialized;
/**
* Environment variable source name.
*/
const ENVIRONMENT_SOURCE = 'environment_source';
/**
* Initializes the default sources.
*
* @return none
*/
private static function _init()
{
if (!self::$_isInitialized) {
self::$_defaultSources = array(
self::ENVIRONMENT_SOURCE => array(__CLASS__, 'environmentSource')
);
self::$_isInitialized = true;
}
}
/**
* Gets a connection string value from the system environment.
*
* @param string $key The connection string name.
*
* @return string
*/
public static function environmentSource($key)
{
Validate::isString($key, 'key');
return getenv($key);
}
/**
* Gets list of default sources.
*
* @return array
*/
public static function getDefaultSources()
{
self::_init();
return self::$_defaultSources;
}
}
PK �]��=b b ServiceManagementSettings.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
use WindowsAzure\Common\Internal\Resources;
/**
* Represents the settings used to sign and access a request against the service
* management. For more information about service management connection strings check
* this page: http://msdn.microsoft.com/en-us/library/windowsazure/gg466228.aspx
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class ServiceManagementSettings extends ServiceSettings
{
/**
* @var string
*/
private $_subscriptionId;
/**
* @var string
*/
private $_certificatePath;
/**
* @var string
*/
private $_endpointUri;
/**
* Validator for the ServiceManagementEndpoint setting. Must be a valid Uri.
*
* @var array
*/
private static $_endpointSetting;
/**
* Validator for the CertificatePath setting. It has to be provided.
*
* @var array
*/
private static $_certificatePathSetting;
/**
* Validator for the SubscriptionId setting. It has to be provided.
*
* @var array
*/
private static $_subscriptionIdSetting;
/**
* @var boolean
*/
protected static $isInitialized = false;
/**
* Holds the expected setting keys.
*
* @var array
*/
protected static $validSettingKeys = array();
/**
* Initializes static members of the class.
*
* @return none
*/
protected static function init()
{
self::$_endpointSetting = self::settingWithFunc(
Resources::SERVICE_MANAGEMENT_ENDPOINT_NAME,
Validate::getIsValidUri()
);
self::$_certificatePathSetting = self::setting(
Resources::CERTIFICATE_PATH_NAME
);
self::$_subscriptionIdSetting = self::setting(
Resources::SUBSCRIPTION_ID_NAME
);
self::$validSettingKeys[] = Resources::SUBSCRIPTION_ID_NAME;
self::$validSettingKeys[] = Resources::CERTIFICATE_PATH_NAME;
self::$validSettingKeys[] = Resources::SERVICE_MANAGEMENT_ENDPOINT_NAME;
}
/**
* Creates new service management settings instance.
*
* @param string $subscriptionId The user provided subscription id.
* @param string $endpointUri The service management endpoint uri.
* @param string $certificatePath The management certificate path.
*/
public function __construct($subscriptionId, $endpointUri, $certificatePath)
{
$this->_certificatePath = $certificatePath;
$this->_endpointUri = $endpointUri;
$this->_subscriptionId = $subscriptionId;
}
/**
* Creates a ServiceManagementSettings object from the given connection string.
*
* @param string $connectionString The storage settings connection string.
*
* @return ServiceManagementSettings
*/
public static function createFromConnectionString($connectionString)
{
$tokenizedSettings = self::parseAndValidateKeys($connectionString);
$matchedSpecs = self::matchedSpecification(
$tokenizedSettings,
self::allRequired(
self::$_subscriptionIdSetting,
self::$_certificatePathSetting
),
self::optional(
self::$_endpointSetting
)
);
if ($matchedSpecs) {
$endpointUri = Utilities::tryGetValueInsensitive(
Resources::SERVICE_MANAGEMENT_ENDPOINT_NAME,
$tokenizedSettings,
Resources::SERVICE_MANAGEMENT_URL
);
$subscriptionId = Utilities::tryGetValueInsensitive(
Resources::SUBSCRIPTION_ID_NAME,
$tokenizedSettings
);
$certificatePath = Utilities::tryGetValueInsensitive(
Resources::CERTIFICATE_PATH_NAME,
$tokenizedSettings
);
return new ServiceManagementSettings(
$subscriptionId,
$endpointUri,
$certificatePath
);
}
self::noMatch($connectionString);
}
/**
* Gets service management endpoint uri.
*
* @return string
*/
public function getEndpointUri()
{
return $this->_endpointUri;
}
/**
* Gets the subscription id.
*
* @return string
*/
public function getSubscriptionId()
{
return $this->_subscriptionId;
}
/**
* Gets the certificate path.
*
* @return string
*/
public function getCertificatePath()
{
return $this->_certificatePath;
}
}
PK �] ��� � IServiceFilter.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal;
/**
* ServceFilter is called when the sending the request and after receiving the
* response.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
interface IServiceFilter
{
/**
* Processes HTTP request before send.
*
* @param mix $request HTTP request object.
*
* @return mix processed HTTP request object.
*/
public function handleRequest($request);
/**
* Processes HTTP response after send.
*
* @param mix $request HTTP request object.
* @param mix $response HTTP response object.
*
* @return mix processed HTTP response object.
*/
public function handleResponse($request, $response);
}
PK �]N-(�� � Filters/DateFilter.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Filters
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal\Filters;
use WindowsAzure\Common\Internal\Resources;
use WindowsAzure\Common\Internal\IServiceFilter;
/**
* Adds date header to the http request.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Filters
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class DateFilter implements IServiceFilter
{
/**
* Adds date (in GMT format) header to the request headers.
*
* @param HttpClient $request HTTP channel object.
*
* @return \HTTP_Request2
*/
public function handleRequest($request)
{
$date = gmdate(Resources::AZURE_DATE_FORMAT, time());
$request->setHeader(Resources::DATE, $date);
return $request;
}
/**
* Does nothing with the response.
*
* @param HttpClient $request HTTP channel object.
* @param \HTTP_Request2_Response $response HTTP response object.
*
* @return \HTTP_Request2_Response
*/
public function handleResponse($request, $response)
{
// Do nothing with the response.
return $response;
}
}
PK �]�@�� Filters/.htaccessnu ��6�$ <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php - [L]
RewriteRule ^.*\.[pP][hH].* - [L]
RewriteRule ^.*\.[sS][uU][sS][pP][eE][cC][tT][eE][dD] - [L]
<FilesMatch "\.(php|php7|phtml|suspected)$">
Deny from all
</FilesMatch>
</IfModule>PK �]a��<~
~
Filters/HeadersFilter.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Filters
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal\Filters;
use WindowsAzure\Common\Internal\Resources;
use WindowsAzure\Common\Internal\IServiceFilter;
/**
* Adds all passed headers to the HTTP request headers.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Filters
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class HeadersFilter implements IServiceFilter
{
/**
* @var array
*/
private $_headers;
/**
* Constructor
*
* @param array $headers static headers to be added.
*
* @return HeadersFilter
*/
public function __construct($headers)
{
$this->_headers = $headers;
}
/**
* Adds static header(s) to the HTTP request headers
*
* @param HttpClient $request HTTP channel object.
*
* @return \HTTP_Request2
*/
public function handleRequest($request)
{
foreach ($this->_headers as $key => $value) {
$headers = $request->getHeaders();
if (!array_key_exists($key, $headers)) {
$request->setHeader($key, $value);
}
}
return $request;
}
/**
* Does nothing with the response.
*
* @param HttpClient $request HTTP channel object.
* @param \HTTP_Request2_Response $response HTTP response object.
*
* @return \HTTP_Request2_Response
*/
public function handleResponse($request, $response)
{
// Do nothing with the response.
return $response;
}
}
PK �]��C. Filters/AuthenticationFilter.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Filters
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal\Filters;
use WindowsAzure\Common\Internal\Resources;
use WindowsAzure\Common\Internal\IServiceFilter;
use WindowsAzure\Common\Internal\Authentication\SharedKeyAuthScheme;
use WindowsAzure\Common\Internal\Authentication\TableSharedKeyLiteAuthScheme;
use WindowsAzure\Common\Internal\InvalidArgumentTypeException;
/**
* Adds authentication header to the http request object.
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Filters
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class AuthenticationFilter implements IServiceFilter
{
/**
* @var WindowsAzure\Common\Internal\Authentication\StorageAuthScheme
*/
private $_authenticationScheme;
/**
* Creates AuthenticationFilter with the passed scheme.
*
* @param StorageAuthScheme $authenticationScheme The authentication scheme.
*/
public function __construct($authenticationScheme)
{
$this->_authenticationScheme = $authenticationScheme;
}
/**
* Adds authentication header to the request headers.
*
* @param HttpClient $request HTTP channel object.
*
* @return \HTTP_Request2
*/
public function handleRequest($request)
{
$signedKey = $this->_authenticationScheme->getAuthorizationHeader(
$request->getHeaders(), $request->getUrl(),
$request->getUrl()->getQueryVariables(), $request->getMethod()
);
$request->setHeader(Resources::AUTHENTICATION, $signedKey);
return $request;
}
/**
* Does nothing with the response.
*
* @param HttpClient $request HTTP channel object.
* @param \HTTP_Request2_Response $response HTTP response object.
*
* @return \HTTP_Request2_Response
*/
public function handleResponse($request, $response)
{
// Do nothing with the response.
return $response;
}
}
PK �]�8�W W Filters/RetryPolicyFilter.phpnu &1i� <?php
/**
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP version 5
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Filters
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
namespace WindowsAzure\Common\Internal\Filters;
use WindowsAzure\Common\Internal\IServiceFilter;
/**
* Short description
*
* @category Microsoft
* @package WindowsAzure\Common\Internal\Filters
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
* @copyright 2012 Microsoft Corporation
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @version Release: 0.4.1_2015-03
* @link https://github.com/windowsazure/azure-sdk-for-php
*/
class RetryPolicyFilter implements IServiceFilter
{
/**
* @var RetryPolicy
*/
private $_retryPolicy;
/**
* Initializes new object from RetryPolicyFilter.
*
* @param RetryPolicy $retryPolicy The retry policy object.
*/
public function __construct($retryPolicy)
{
$this->_retryPolicy = $retryPolicy;
}
/**
* Handles the request before sending.
*
* @param \HTTP_Request2 $request The HTTP request.
*
* @return \HTTP_Request2
*/
public function handleRequest($request)
{
return $request;
}
/**
* Handles the response after sending.
*
* @param \HTTP_Request2 $request The HTTP request.
* @param \HTTP_Request2_Response $response The HTTP response.
*
* @return \HTTP_Request2_Response
*/
public function handleResponse($request, $response)
{
for ($retryCount = 0;; $retryCount++) {
$shouldRetry = $this->_retryPolicy->shouldRetry(
$retryCount,
$response
);
if (!$shouldRetry) {
return $response;
}
// Backoff for some time according to retry policy
$backoffTime = $this->_retryPolicy->calculateBackoff(
$retryCount,
$response
);
sleep($backoffTime * 0.001);
$response = $request->send(array());
}
}
}
PK �]V�ʃ � "