Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated comments and property declarations to remove all phpdoc generation errors #47

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
269 changes: 251 additions & 18 deletions S3.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,125 @@ class S3

const STORAGE_CLASS_STANDARD = 'STANDARD';
const STORAGE_CLASS_RRS = 'REDUCED_REDUNDANCY';

private static $__accessKey = null; // AWS Access key
private static $__secretKey = null; // AWS Secret key

/**
* The AWS Access key
*
* @var string
* @access private
* @static
*/
private static $__accessKey = null;

/**
* AWS Secret Key
*
* @var string
* @access private
* @static
*/
private static $__secretKey = null;

/**
* SSL Client key
*
* @var string
* @access private
* @static
*/
private static $__sslKey = null;


/**
* AWS URI
*
* @var string
* @acess public
* @static
*/
public static $endpoint = 's3.amazonaws.com';

/**
* Proxy information
*
* @var null|array
* @access public
* @static
*/
public static $proxy = null;


/**
* Connect using SSL?
*
* @var bool
* @access public
* @static
*/
public static $useSSL = false;

/**
* Use SSL validation?
*
* @var bool
* @access public
* @static
*/
public static $useSSLValidation = true;

/**
* Use PHP exceptions?
*
* @var bool
* @access public
* @static
*/
public static $useExceptions = false;

// SSL CURL SSL options - only needed if you are experiencing problems with your OpenSSL configuration

/**
* SSL client key
*
* @var bool
* @access public
* @static
*/
public static $sslKey = null;

/**
* SSL client certfificate
*
* @var string
* @acess public
* @static
*/
public static $sslCert = null;

/**
* SSL CA cert (only required if you are having problems with your system CA cert)
*
* @var string
* @access public
* @static
*/
public static $sslCACert = null;

private static $__signingKeyPairId = null; // AWS Key Pair ID
private static $__signingKeyResource = false; // Key resource, freeSigningKey() must be called to clear it from memory

/**
* AWS Key Pair ID
*
* @var string
* @access private
* @static
*/
private static $__signingKeyPairId = null;

/**
* Key resource, freeSigningKey() must be called to clear it from memory
*
* @var bool
* @access private
* @static
*/
private static $__signingKeyResource = false;


/**
Expand All @@ -71,6 +171,7 @@ class S3
* @param string $accessKey Access key
* @param string $secretKey Secret key
* @param boolean $useSSL Enable SSL
* @param string $endpoint Amazon URI
* @return void
*/
public function __construct($accessKey = null, $secretKey = null, $useSSL = false, $endpoint = 's3.amazonaws.com')
Expand All @@ -83,7 +184,7 @@ public function __construct($accessKey = null, $secretKey = null, $useSSL = fals


/**
* Set the sertvice endpoint
* Set the service endpoint
*
* @param string $host Hostname
* @return void
Expand Down Expand Up @@ -262,7 +363,7 @@ public static function listBuckets($detailed = false)
}


/*
/**
* Get contents for a bucket
*
* If maxKeys is null this method will loop through truncated result sets
Expand Down Expand Up @@ -634,8 +735,8 @@ public static function getObjectInfo($bucket, $uri, $returnInfo = true)
/**
* Copy an object
*
* @param string $bucket Source bucket name
* @param string $uri Source object URI
* @param string $srcBucket Source bucket name
* @param string $srcUri Source object URI
* @param string $bucket Destination bucket name
* @param string $uri Destination object URI
* @param constant $acl ACL constant
Expand Down Expand Up @@ -968,8 +1069,32 @@ public static function getAccessControlPolicy($bucket, $uri = '')
}
return $acp;
}



/**
* Generate a policy document
*
* @param array $args Policy document arguments
* @return string The encoded policy document
*/
public static function createPolicyDocument( $args )
{
$policy = base64_encode( json_encode( $args ) );

return $policy;
}

/**
* Sign a policy document
*
* @param string $secret AWS secret key
* @param string $policy Policy document
* @return string The signed policy document
*/
public static function getSignedPolicyDocument( $secret, $policy )
{
return base64_encode(hash_hmac('sha1', $policy, $secret, true));
}

/**
* Delete an object
*
Expand Down Expand Up @@ -1039,7 +1164,7 @@ public static function getSignedPolicyURL($policy)
/**
* Get a CloudFront canned policy URL
*
* @param string $string URL to sign
* @param string $url URL to sign
* @param integer $lifetime URL lifetime
* @return string
*/
Expand Down Expand Up @@ -1430,6 +1555,7 @@ public static function invalidateDistribution($distributionId, $paths)
*
* @internal Used to create XML in invalidateDistribution()
* @param array $paths Paths to objects to invalidateDistribution
* @param int $callerReference
* @return string
*/
private static function __getCloudFrontInvalidationBatchXML($paths, $callerReference = '0') {
Expand Down Expand Up @@ -1718,13 +1844,103 @@ private static function __getHash($string)

}

/**
* S3 Request class
*
* @link http://undesigned.org.za/2007/10/22/amazon-s3-php-class
* @version 0.5.0-dev
*/
final class S3Request
{
private $endpoint, $verb, $bucket, $uri, $resource = '', $parameters = array(),
$amzHeaders = array(), $headers = array(
/**
* AWS URI
*
* @var string
* @access pricate
*/
private $endpoint;

/**
* Verb
*
* @var string
* @access private
*/
private $verb;

/**
* S3 bucket name
*
* @var string
* @access private
*/
private $bucket;

/**
* Object URI
*
* @var string
* @access private
*/
private $uri;

/**
* Final object URI
*
* @var string
* @access private
*/
private $resource = '';

/**
* Additional request parameters
*
* @var array
* @access private
*/
private $parameters = array();

/**
* Amazon specific request headers
*
* @var array
* @access private
*/
private $amzHeaders = array(), $headers = array(
'Host' => '', 'Date' => '', 'Content-MD5' => '', 'Content-Type' => ''
);
public $fp = false, $size = 0, $data = false, $response;

/**
* Use HTTP PUT?
*
* @var bool
* @access public
*/
public $fp = false;

/**
* PUT file size
*
* @var int
* @access public
*/
public $size = 0;

/**
* PUT post fields
*
* @var array
* @access public
*/
public $data = false;

/**
* S3 request respone
*
* @var object
* @access public
*/
public $response;


/**
Expand All @@ -1733,10 +1949,12 @@ final class S3Request
* @param string $verb Verb
* @param string $bucket Bucket name
* @param string $uri Object URI
* @param string $endpoint AWS endpoint URI
* @return mixed
*/
function __construct($verb, $bucket = '', $uri = '', $endpoint = 's3.amazonaws.com')
{

$this->endpoint = $endpoint;
$this->verb = $verb;
$this->bucket = $bucket;
Expand Down Expand Up @@ -2065,7 +2283,22 @@ private function __responseHeaderCallback(&$curl, &$data)

}

/**
* S3 exception class
*
* @link http://undesigned.org.za/2007/10/22/amazon-s3-php-class
* @version 0.5.0-dev
*/

class S3Exception extends Exception {
/**
* Class constructor
*
* @param string $message Exception message
* @param string $file File in which exception was created
* @param string $line Line number on which exception was created
* @param int $code Exception code
*/
function __construct($message, $file, $line, $code = 0)
{
parent::__construct($message, $code);
Expand Down