idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
41,800
protected function parseDataFromResponse ( ) { $ content = $ this -> rawResponse -> body ; $ xml = simplexml_load_string ( $ content ) ; $ bucket = isset ( $ xml -> Bucket ) ? strval ( $ xml -> Bucket ) : "" ; $ key = isset ( $ xml -> Key ) ? strval ( $ xml -> Key ) : "" ; $ uploadId = isset ( $ xml -> UploadId ) ? str...
Parse the xml data returned by the ListParts interface
41,801
public function set_credentials ( $ user , $ pass ) { $ this -> username = $ user ; $ this -> password = $ pass ; return $ this ; }
Set the credentials to use for authentication .
41,802
public function remove_header ( $ key ) { if ( isset ( $ this -> request_headers [ $ key ] ) ) { unset ( $ this -> request_headers [ $ key ] ) ; } return $ this ; }
Remove an HTTP header from the cURL request .
41,803
public function set_read_file ( $ location ) { $ this -> read_file = $ location ; $ read_file_handle = fopen ( $ location , 'r' ) ; return $ this -> set_read_stream ( $ read_file_handle ) ; }
Set the file to read from while streaming up .
41,804
public function set_proxy ( $ proxy ) { $ proxy = parse_url ( $ proxy ) ; $ proxy [ 'user' ] = isset ( $ proxy [ 'user' ] ) ? $ proxy [ 'user' ] : null ; $ proxy [ 'pass' ] = isset ( $ proxy [ 'pass' ] ) ? $ proxy [ 'pass' ] : null ; $ proxy [ 'port' ] = isset ( $ proxy [ 'port' ] ) ? $ proxy [ 'port' ] : null ; $ this...
Set the proxy to use for making requests .
41,805
public function set_seek_position ( $ position ) { $ this -> seek_position = isset ( $ position ) ? ( integer ) $ position : null ; return $ this ; }
Set the intended starting seek position .
41,806
public function get_response_header ( $ header = null ) { if ( $ header ) { return $ this -> response_headers [ strtolower ( $ header ) ] ; } return $ this -> response_headers ; }
Get the HTTP response headers from the request .
41,807
public function getBucketMeta ( $ bucket , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_HEAD ; $ options [ self :: OSS_OBJECT ] = '/' ; $ response = $ this -> auth ( $ options ) ;...
Get the Meta information for the Bucket
41,808
public function putBucketAcl ( $ bucket , $ acl , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_PUT ; $ options [ self :: OSS_OBJECT ] = '/' ; $ options [ self :: OSS_HEADERS ] = a...
Sets the bucket ACL
41,809
public function getObjectAcl ( $ bucket , $ object ) { $ options = array ( ) ; $ this -> precheckCommon ( $ bucket , $ object , $ options , true ) ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_GET ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_OBJECT ] = $ object ; $ options [ self :: O...
Gets object ACL
41,810
public function putObjectAcl ( $ bucket , $ object , $ acl ) { $ this -> precheckCommon ( $ bucket , $ object , $ options , true ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_PUT ; $ options [ self :: OSS_OBJECT ] = $ object ; $ options [ self :: OSS_HEADERS ] = a...
Sets the object ACL
41,811
public function putBucketLogging ( $ bucket , $ targetBucket , $ targetPrefix , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ this -> precheckBucket ( $ targetBucket , 'targetbucket is not allowed empty' ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OS...
Sets the bycket logging config . Only owner can call this API .
41,812
public function getBucketWebsite ( $ bucket , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_GET ; $ options [ self :: OSS_OBJECT ] = '/' ; $ options [ self :: OSS_SUB_RESOURCE ] = ...
Gets the website config in the bucket
41,813
public function deleteBucketWebsite ( $ bucket , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_DELETE ; $ options [ self :: OSS_OBJECT ] = '/' ; $ options [ self :: OSS_SUB_RESOURC...
Deletes the website config in the bucket
41,814
public function getBucketCors ( $ bucket , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_GET ; $ options [ self :: OSS_OBJECT ] = '/' ; $ options [ self :: OSS_SUB_RESOURCE ] = 'co...
Gets the bucket CORS config
41,815
public function addBucketCname ( $ bucket , $ cname , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_POST ; $ options [ self :: OSS_OBJECT ] = '/' ; $ options [ self :: OSS_SUB_RESO...
Bind a CName for the bucket
41,816
public function putBucketLiveChannel ( $ bucket , $ channelName , $ channelConfig , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_PUT ; $ options [ self :: OSS_OBJECT ] = $ channel...
Creates a Live Channel under a bucket
41,817
public function putLiveChannelStatus ( $ bucket , $ channelName , $ channelStatus , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_PUT ; $ options [ self :: OSS_OBJECT ] = $ channel...
Sets the LiveChannel status
41,818
public function getLiveChannelInfo ( $ bucket , $ channelName , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_GET ; $ options [ self :: OSS_OBJECT ] = $ channelName ; $ options [ s...
Gets the LiveChannel information by the channel name
41,819
public function getLiveChannelStatus ( $ bucket , $ channelName , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_GET ; $ options [ self :: OSS_OBJECT ] = $ channelName ; $ options [...
Gets the status of LiveChannel
41,820
public function listBucketLiveChannels ( $ bucket , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_GET ; $ options [ self :: OSS_OBJECT ] = '/' ; $ options [ self :: OSS_SUB_RESOURC...
Gets the live channel list under a bucket .
41,821
public function postVodPlaylist ( $ bucket , $ channelName , $ playlistName , $ setTime ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_POST ; $ options [ self :: OSS_OBJECT ] = $ channelName . '/' ....
Creates a play list file for the LiveChannel
41,822
public function signRtmpUrl ( $ bucket , $ channelName , $ timeout = 60 , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ channelName , $ options , false ) ; $ expires = time ( ) + $ timeout ; $ proto = 'rtmp://' ; $ hostname = $ this -> generateHostname ( $ bucket ) ; $ cano_params = '' ; $ query_items = ...
Generates the signed pushing streaming url
41,823
public function putBucketStorageCapacity ( $ bucket , $ storageCapacity , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_PUT ; $ options [ self :: OSS_OBJECT ] = '/' ; $ options [ s...
Set the size of the bucket the unit is GB When the capacity of the bucket is bigger than the set it s forbidden to continue writing
41,824
public function uploadFile ( $ bucket , $ object , $ file , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; OssUtil :: throwOssExceptionWithMessageIfEmpty ( $ file , "file path is invalid" ) ; $ file = OssUtil :: encodePath ( $ file ) ; if ( ! file_exists ( $ file ) ) { throw new Oss...
Uploads a local file
41,825
public function appendObject ( $ bucket , $ object , $ content , $ position , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; $ options [ self :: OSS_CONTENT ] = $ content ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_POST ; $ opt...
Append the object with the content at the specified position . The specified position is typically the lengh of the current file .
41,826
public function appendFile ( $ bucket , $ object , $ file , $ position , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; OssUtil :: throwOssExceptionWithMessageIfEmpty ( $ file , "file path is invalid" ) ; $ file = OssUtil :: encodePath ( $ file ) ; if ( ! file_exists ( $ file ) ) { ...
Append the object with a local file
41,827
public function copyObject ( $ fromBucket , $ fromObject , $ toBucket , $ toObject , $ options = NULL ) { $ this -> precheckCommon ( $ fromBucket , $ fromObject , $ options ) ; $ this -> precheckCommon ( $ toBucket , $ toObject , $ options ) ; $ options [ self :: OSS_BUCKET ] = $ toBucket ; $ options [ self :: OSS_METH...
Copy from an existing OSS object to another OSS object . If the target object exists already it will be overwritten .
41,828
public function getObjectMeta ( $ bucket , $ object , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_HEAD ; $ options [ self :: OSS_OBJECT ] = $ object ; $ response = $ this -> auth ( $...
Gets Object metadata
41,829
public function deleteObject ( $ bucket , $ object , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_DELETE ; $ options [ self :: OSS_OBJECT ] = $ object ; $ response = $ this -> auth ( ...
Deletes a object
41,830
public function deleteObjects ( $ bucket , $ objects , $ options = null ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; if ( ! is_array ( $ objects ) || ! $ objects ) { throw new OssException ( 'objects must be array' ) ; } $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_POST ; $ options [ se...
Deletes multiple objects in a bucket
41,831
public function getObject ( $ bucket , $ object , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_GET ; $ options [ self :: OSS_OBJECT ] = $ object ; if ( isset ( $ options [ self :: OSS...
Gets Object content
41,832
public function restoreObject ( $ bucket , $ object , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_POST ; $ options [ self :: OSS_OBJECT ] = $ object ; $ options [ self :: OSS_SUB_RES...
Object reading for Archive type Use Restore to enable the server to perform the thawing task
41,833
private function computePartSize ( $ partSize ) { $ partSize = ( integer ) $ partSize ; if ( $ partSize <= self :: OSS_MIN_PART_SIZE ) { $ partSize = self :: OSS_MIN_PART_SIZE ; } elseif ( $ partSize > self :: OSS_MAX_PART_SIZE ) { $ partSize = self :: OSS_MAX_PART_SIZE ; } return $ partSize ; }
Gets the part size according to the preferred part size . If the specified part size is too small or too big it will return a min part or max part size instead . Otherwise returns the specified part size .
41,834
public function initiateMultipartUpload ( $ bucket , $ object , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_POST ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_OBJECT ] = $ object ; $ options [ self :: O...
Initialize a multi - part upload
41,835
public function uploadPart ( $ bucket , $ object , $ uploadId , $ options = null ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; $ this -> precheckParam ( $ options , self :: OSS_FILE_UPLOAD , __FUNCTION__ ) ; $ this -> precheckParam ( $ options , self :: OSS_PART_NUM , __FUNCTION__ ) ; $ options [ s...
Upload a part in a multiparts upload .
41,836
public function listParts ( $ bucket , $ object , $ uploadId , $ options = null ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_GET ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_OBJECT ] = $ object ; $ options [ self :: OSS...
Gets the uploaded parts .
41,837
public function completeMultipartUpload ( $ bucket , $ object , $ uploadId , $ listParts , $ options = NULL ) { $ this -> precheckCommon ( $ bucket , $ object , $ options ) ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_POST ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_OBJECT ] = $ obj...
Completes a multiparts upload after all parts are uploaded .
41,838
public function listMultipartUploads ( $ bucket , $ options = null ) { $ this -> precheckCommon ( $ bucket , NULL , $ options , false ) ; $ options [ self :: OSS_METHOD ] = self :: OSS_HTTP_GET ; $ options [ self :: OSS_BUCKET ] = $ bucket ; $ options [ self :: OSS_OBJECT ] = '/' ; $ options [ self :: OSS_SUB_RESOURCE ...
Lists all ongoing multipart upload events which means all initialized but not completed or aborted multipart uploads .
41,839
public function uploadPartCopy ( $ fromBucket , $ fromObject , $ toBucket , $ toObject , $ partNumber , $ uploadId , $ options = NULL ) { $ this -> precheckCommon ( $ fromBucket , $ fromObject , $ options ) ; $ this -> precheckCommon ( $ toBucket , $ toObject , $ options ) ; $ start_range = "0" ; if ( isset ( $ options...
Copy an existing file as a part
41,840
private function precheckCommon ( $ bucket , $ object , & $ options , $ isCheckObject = true ) { if ( $ isCheckObject ) { $ this -> precheckObject ( $ object ) ; } $ this -> precheckOptions ( $ options ) ; $ this -> precheckBucket ( $ bucket ) ; }
Validates bucket options parameters and optionally validate object parameter .
41,841
private function getValue ( $ options , $ key , $ default = NULL , $ isCheckEmpty = false , $ isCheckBool = false ) { $ value = $ default ; if ( isset ( $ options [ $ key ] ) ) { if ( $ isCheckEmpty ) { if ( ! empty ( $ options [ $ key ] ) ) { $ value = $ options [ $ key ] ; } } else { $ value = $ options [ $ key ] ; }...
Gets value of the specified key from the options
41,842
private function authPrecheckObjectEncoding ( & $ options ) { $ tmp_object = $ options [ self :: OSS_OBJECT ] ; try { if ( OssUtil :: isGb2312 ( $ options [ self :: OSS_OBJECT ] ) ) { $ options [ self :: OSS_OBJECT ] = iconv ( 'GB2312' , "UTF-8//IGNORE" , $ options [ self :: OSS_OBJECT ] ) ; } elseif ( OssUtil :: check...
Checks the object s encoding . Convert it to UTF8 if it s in GBK or GB2312
41,843
private function authPrecheckAcl ( $ options ) { if ( isset ( $ options [ self :: OSS_HEADERS ] [ self :: OSS_ACL ] ) && ! empty ( $ options [ self :: OSS_HEADERS ] [ self :: OSS_ACL ] ) ) { if ( ! in_array ( strtolower ( $ options [ self :: OSS_HEADERS ] [ self :: OSS_ACL ] ) , self :: $ OSS_ACL_TYPES ) ) { throw new ...
Checks if the ACL is one of the 3 predefined one . Throw OSSException if not .
41,844
private function generateResourceUri ( $ options ) { $ resource_uri = "" ; if ( isset ( $ options [ self :: OSS_BUCKET ] ) && '' !== $ options [ self :: OSS_BUCKET ] ) { if ( $ this -> hostType === self :: OSS_HOST_TYPE_IP ) { $ resource_uri = '/' . $ options [ self :: OSS_BUCKET ] ; } } if ( isset ( $ options [ self :...
Gets the resource Uri in the current request
41,845
private function generateSignableQueryStringParam ( $ options ) { $ signableQueryStringParams = array ( ) ; $ signableList = array ( self :: OSS_PART_NUM , 'response-content-type' , 'response-content-language' , 'response-cache-control' , 'response-content-encoding' , 'response-expires' , 'response-content-disposition'...
Generates the signalbe query string parameters in array type
41,846
private function generateSignableResource ( $ options ) { $ signableResource = "" ; $ signableResource .= '/' ; if ( isset ( $ options [ self :: OSS_BUCKET ] ) && '' !== $ options [ self :: OSS_BUCKET ] ) { $ signableResource .= $ options [ self :: OSS_BUCKET ] ; if ( $ options [ self :: OSS_OBJECT ] == '/' ) { if ( $ ...
Generates the resource uri for signing
41,847
private function generateQueryString ( $ options ) { $ queryStringParams = array ( ) ; if ( isset ( $ options [ self :: OSS_QUERY_STRING ] ) ) { $ queryStringParams = array_merge ( $ queryStringParams , $ options [ self :: OSS_QUERY_STRING ] ) ; } return OssUtil :: toQueryString ( $ queryStringParams ) ; }
generates query string
41,848
public static function checkEnv ( ) { if ( function_exists ( 'get_loaded_extensions' ) ) { $ enabled_extension = array ( "curl" ) ; $ extensions = get_loaded_extensions ( ) ; if ( $ extensions ) { foreach ( $ enabled_extension as $ item ) { if ( ! in_array ( $ item , $ extensions ) ) { throw new OssException ( "Extensi...
Check if all dependent extensions are installed correctly . For now only curl is needed .
41,849
public function parseFromXml ( $ strXml ) { $ this -> rules = array ( ) ; $ xml = simplexml_load_string ( $ strXml ) ; if ( ! isset ( $ xml -> Rule ) ) return ; $ this -> rules = array ( ) ; foreach ( $ xml -> Rule as $ rule ) { $ id = strval ( $ rule -> ID ) ; $ prefix = strval ( $ rule -> Prefix ) ; $ status = strval...
Parse the xml into this object .
41,850
protected function parseDataFromResponse ( ) { $ content = $ this -> rawResponse -> body ; $ config = new LoggingConfig ( ) ; $ config -> parseFromXml ( $ content ) ; return $ config ; }
Parse LoggingConfig data
41,851
private function retrieveErrorMessage ( $ body ) { if ( empty ( $ body ) || false === strpos ( $ body , '<?xml' ) ) { return '' ; } $ xml = simplexml_load_string ( $ body ) ; if ( isset ( $ xml -> Message ) ) { return strval ( $ xml -> Message ) ; } return '' ; }
Try to get the error message from body
41,852
private function retrieveErrorCode ( $ body ) { if ( empty ( $ body ) || false === strpos ( $ body , '<?xml' ) ) { return '' ; } $ xml = simplexml_load_string ( $ body ) ; if ( isset ( $ xml -> Code ) ) { return strval ( $ xml -> Code ) ; } return '' ; }
Try to get the error Code from body
41,853
protected function parseDataFromResponse ( ) { $ content = $ this -> rawResponse -> body ; $ config = new RefererConfig ( ) ; $ config -> parseFromXml ( $ content ) ; return $ config ; }
Parse RefererConfig data
41,854
protected function parseDataFromResponse ( ) { $ content = $ this -> rawResponse -> body ; $ config = new WebsiteConfig ( ) ; $ config -> parseFromXml ( $ content ) ; return $ config ; }
Parse WebsiteConfig data
41,855
public function appendToXml ( & $ xmlRule ) { $ xmlAction = $ xmlRule -> addChild ( $ this -> action ) ; $ xmlAction -> addChild ( $ this -> timeSpec , $ this -> timeValue ) ; }
Use appendToXml to insert actions into xml .
41,856
protected function parseDataFromResponse ( ) { $ xml = new \ SimpleXMLElement ( $ this -> rawResponse -> body ) ; $ encodingType = isset ( $ xml -> EncodingType ) ? strval ( $ xml -> EncodingType ) : "" ; $ objectList = $ this -> parseObjectList ( $ xml , $ encodingType ) ; $ prefixList = $ this -> parsePrefixList ( $ ...
Parse the xml data returned by the ListObjects interface
41,857
public function serializeToXml ( ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="utf-8"?><BucketLoggingStatus></BucketLoggingStatus>' ) ; if ( isset ( $ this -> targetBucket ) && isset ( $ this -> targetPrefix ) ) { $ loggingEnabled = $ xml -> addChild ( 'LoggingEnabled' ) ; $ loggingEnabled -> addC...
Serialize to xml string
41,858
protected function parseDataFromResponse ( ) { $ content = $ this -> rawResponse -> body ; $ xml = simplexml_load_string ( $ content ) ; $ encodingType = isset ( $ xml -> EncodingType ) ? strval ( $ xml -> EncodingType ) : "" ; $ bucket = isset ( $ xml -> Bucket ) ? strval ( $ xml -> Bucket ) : "" ; $ keyMarker = isset...
Parse the return data from the ListMultipartUpload interface
41,859
public static function getOssClient ( ) { try { $ ossClient = new OssClient ( self :: accessKeyId , self :: accessKeySecret , self :: endpoint , false ) ; } catch ( OssException $ e ) { printf ( __FUNCTION__ . "creating OssClient instance: FAILED\n" ) ; printf ( $ e -> getMessage ( ) . "\n" ) ; return null ; } return $...
Get an OSSClient instance according to config .
41,860
public static function createBucket ( ) { $ ossClient = self :: getOssClient ( ) ; if ( is_null ( $ ossClient ) ) exit ( 1 ) ; $ bucket = self :: getBucketName ( ) ; $ acl = OssClient :: OSS_ACL_TYPE_PUBLIC_READ ; try { $ ossClient -> createBucket ( $ bucket , $ acl ) ; } catch ( OssException $ e ) { $ message = $ e ->...
A tool function which creates a bucket and exists the process if there are exceptions
41,861
public static function toQueryString ( $ options = array ( ) ) { $ temp = array ( ) ; uksort ( $ options , 'strnatcasecmp' ) ; foreach ( $ options as $ key => $ value ) { if ( is_string ( $ key ) && ! is_array ( $ value ) ) { $ temp [ ] = rawurlencode ( $ key ) . '=' . rawurlencode ( $ value ) ; } } return implode ( '&...
Generate query params
41,862
public static function isGb2312 ( $ str ) { for ( $ i = 0 ; $ i < strlen ( $ str ) ; $ i ++ ) { $ v = ord ( $ str [ $ i ] ) ; if ( $ v > 127 ) { if ( ( $ v >= 228 ) && ( $ v <= 233 ) ) { if ( ( $ i + 2 ) >= ( strlen ( $ str ) - 1 ) ) return true ; $ v1 = ord ( $ str [ $ i + 1 ] ) ; $ v2 = ord ( $ str [ $ i + 2 ] ) ; if...
Checks if the string is encoded by GB2312 .
41,863
public static function checkChar ( $ str , $ gbk = true ) { for ( $ i = 0 ; $ i < strlen ( $ str ) ; $ i ++ ) { $ v = ord ( $ str [ $ i ] ) ; if ( $ v > 127 ) { if ( ( $ v >= 228 ) && ( $ v <= 233 ) ) { if ( ( $ i + 2 ) >= ( strlen ( $ str ) - 1 ) ) return $ gbk ? true : FALSE ; $ v1 = ord ( $ str [ $ i + 1 ] ) ; $ v2 ...
Checks if the string is encoded by GBK
41,864
public static function generateFile ( $ filename , $ size ) { if ( file_exists ( $ filename ) && $ size == filesize ( $ filename ) ) { echo $ filename . " already exists, no need to create again. " ; return ; } $ part_size = 1 * 1024 * 1024 ; $ fp = fopen ( $ filename , "w" ) ; $ characters = <<<BBB0123456789abcdefghi...
This is a method for test only . DO NOT USE .
41,865
public static function getMd5SumForFile ( $ filename , $ from_pos , $ to_pos ) { $ content_md5 = "" ; if ( ( $ to_pos - $ from_pos ) > self :: OSS_MAX_PART_SIZE ) { return $ content_md5 ; } $ filesize = filesize ( $ filename ) ; if ( $ from_pos >= $ filesize || $ to_pos >= $ filesize || $ from_pos < 0 || $ to_pos < 0 )...
Get MD5 of the file .
41,866
public static function encodePath ( $ file_path ) { if ( self :: chkChinese ( $ file_path ) && self :: isWin ( ) ) { $ file_path = iconv ( 'utf-8' , 'gbk' , $ file_path ) ; } return $ file_path ; }
Encodes the file path from GBK to UTF - 8 . The default encoding in Windows is GBK . And if the file path is in Chinese the file would not be found without the transcoding to UTF - 8 .
41,867
public static function createDeleteObjectsXmlBody ( $ objects , $ quiet ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="utf-8"?><Delete></Delete>' ) ; $ xml -> addChild ( 'Quiet' , $ quiet ) ; foreach ( $ objects as $ object ) { $ sub_object = $ xml -> addChild ( 'Object' ) ; $ object = OssUtil :: s...
Generate the xml message of DeleteMultiObjects .
41,868
public static function createCompleteMultipartUploadXmlBody ( $ listParts ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="utf-8"?><CompleteMultipartUpload></CompleteMultipartUpload>' ) ; foreach ( $ listParts as $ node ) { $ part = $ xml -> addChild ( 'Part' ) ; $ part -> addChild ( 'PartNumber' , $...
Generate the xml message of CompleteMultipartUpload .
41,869
public static function decodeKey ( $ key , $ encoding ) { if ( $ encoding == "" ) { return $ key ; } if ( $ encoding == "url" ) { return rawurldecode ( $ key ) ; } else { throw new OssException ( "Unrecognized encoding type: " . $ encoding ) ; } }
Decode key based on the encoding type
41,870
public function serializeToXml ( ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="utf-8"?><RefererConfiguration></RefererConfiguration>' ) ; if ( $ this -> allowEmptyReferer ) { $ xml -> addChild ( 'AllowEmptyReferer' , 'true' ) ; } else { $ xml -> addChild ( 'AllowEmptyReferer' , 'false' ) ; } $ ref...
serialize the RefererConfig object into xml string
41,871
public function addRule ( $ rule ) { if ( count ( $ this -> rules ) >= self :: OSS_MAX_RULES ) { throw new OssException ( "num of rules in the config exceeds self::OSS_MAX_RULES: " . strval ( self :: OSS_MAX_RULES ) ) ; } $ this -> rules [ ] = $ rule ; }
Add a new CorsRule
41,872
public function parseFromXml ( $ strXml ) { $ xml = simplexml_load_string ( $ strXml ) ; if ( ! isset ( $ xml -> CORSRule ) ) return ; foreach ( $ xml -> CORSRule as $ rule ) { $ corsRule = new CorsRule ( ) ; foreach ( $ rule as $ key => $ value ) { if ( $ key === self :: OSS_CORS_ALLOWED_HEADER ) { $ corsRule -> addAl...
Parse CorsConfig from the xml .
41,873
public function serializeToXml ( ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="utf-8"?><CORSConfiguration></CORSConfiguration>' ) ; foreach ( $ this -> rules as $ rule ) { $ xmlRule = $ xml -> addChild ( 'CORSRule' ) ; $ rule -> appendToXml ( $ xmlRule ) ; } return $ xml -> asXML ( ) ; }
Serialize the object into xml string .
41,874
public static function getMimetype ( $ name ) { $ parts = explode ( '.' , $ name ) ; if ( count ( $ parts ) > 1 ) { $ ext = strtolower ( end ( $ parts ) ) ; if ( isset ( self :: $ mime_types [ $ ext ] ) ) { return self :: $ mime_types [ $ ext ] ; } } return null ; }
Get the content - type value of http header from the file s extension name .
41,875
public function isOK ( $ codes = array ( 200 , 201 , 204 , 206 ) ) { if ( is_array ( $ codes ) ) { return in_array ( $ this -> status , $ codes ) ; } return $ this -> status === $ codes ; }
Did we receive the status code we expected?
41,876
public function serializeToXml ( ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="utf-8"?><BucketUserQos></BucketUserQos>' ) ; $ xml -> addChild ( 'StorageCapacity' , strval ( $ this -> storageCapacity ) ) ; return $ xml -> asXML ( ) ; }
Serialize StorageCapacityConfig into xml
41,877
protected function parseDataFromResponse ( ) { $ header = $ this -> rawResponse -> header ; if ( isset ( $ header [ "x-oss-next-append-position" ] ) ) { return intval ( $ header [ "x-oss-next-append-position" ] ) ; } throw new OssException ( "cannot get next-append-position" ) ; }
Get the value of next - append - position from append s response headers
41,878
public function resolveVersionAlias ( string $ alias ) : ? string { if ( $ this -> migrationRepository -> hasVersion ( $ alias ) ) { return $ alias ; } switch ( $ alias ) { case self :: ALIAS_FIRST : return '0' ; case self :: ALIAS_CURRENT : return $ this -> migrationRepository -> getCurrentVersion ( ) ; case self :: A...
Returns the version number from an alias .
41,879
public function connect ( ) : bool { if ( $ this -> connection instanceof MasterSlaveConnection ) { return $ this -> connection -> connect ( 'master' ) ; } return $ this -> connection -> connect ( ) ; }
Explicitely opens the database connection . This is done to play nice with DBAL s MasterSlaveConnection . Which in some cases connects to a follower when fetching the executed migrations . If a follower is lagging significantly behind that means the migrations system may see unexecuted migrations that were actually exe...
41,880
public static function useCurrency ( $ currency , $ symbol = null ) { static :: $ currency = $ currency ; static :: useCurrencySymbol ( $ symbol ? : static :: guessCurrencySymbol ( $ currency ) ) ; }
Set the currency to be used when billing Stripe models .
41,881
public function handleWebhook ( Request $ request ) { $ payload = json_decode ( $ request -> getContent ( ) , true ) ; $ method = 'handle' . Str :: studly ( str_replace ( '.' , '_' , $ payload [ 'type' ] ) ) ; if ( method_exists ( $ this , $ method ) ) { return $ this -> { $ method } ( $ payload ) ; } return $ this -> ...
Handle a Stripe webhook call .
41,882
protected function handleCustomerSubscriptionUpdated ( array $ payload ) { $ user = $ this -> getUserByStripeId ( $ payload [ 'data' ] [ 'object' ] [ 'customer' ] ) ; if ( $ user ) { $ data = $ payload [ 'data' ] [ 'object' ] ; $ user -> subscriptions -> filter ( function ( Subscription $ subscription ) use ( $ data ) ...
Handle customer subscription updated .
41,883
protected function handleCustomerDeleted ( array $ payload ) { $ user = $ this -> getUserByStripeId ( $ payload [ 'data' ] [ 'object' ] [ 'id' ] ) ; if ( $ user ) { $ user -> subscriptions -> each ( function ( Subscription $ subscription ) { $ subscription -> skipTrial ( ) -> markAsCancelled ( ) ; } ) ; $ user -> force...
Handle deleted customer .
41,884
public function hasDiscount ( ) { return $ this -> invoice -> subtotal > 0 && $ this -> invoice -> subtotal != $ this -> invoice -> total && ! is_null ( $ this -> invoice -> discount ) ; }
Determine if the invoice has a discount .
41,885
public function discount ( ) { return $ this -> formatAmount ( $ this -> invoice -> subtotal + $ this -> invoice -> tax - $ this -> invoice -> total ) ; }
Get the discount amount .
41,886
public function coupon ( ) { if ( isset ( $ this -> invoice -> discount ) ) { return $ this -> invoice -> discount -> coupon -> id ; } }
Get the coupon code applied to the invoice .
41,887
public function amountOff ( ) { if ( isset ( $ this -> invoice -> discount -> coupon -> amount_off ) ) { return $ this -> formatAmount ( $ this -> invoice -> discount -> coupon -> amount_off ) ; } return $ this -> formatAmount ( 0 ) ; }
Get the discount amount for the invoice .
41,888
public function anchorBillingCycleOn ( $ date = 'now' ) { if ( $ date instanceof DateTimeInterface ) { $ date = $ date -> getTimestamp ( ) ; } $ this -> billingCycleAnchor = $ date ; return $ this ; }
Change the billing cycle anchor on a plan change .
41,889
public function cancel ( ) { $ subscription = $ this -> asStripeSubscription ( ) ; $ subscription -> cancel_at_period_end = true ; $ subscription -> save ( ) ; if ( $ this -> onTrial ( ) ) { $ this -> ends_at = $ this -> trial_ends_at ; } else { $ this -> ends_at = Carbon :: createFromTimestamp ( $ subscription -> curr...
Cancel the subscription at the end of the billing period .
41,890
public function syncTaxPercentage ( ) { $ subscription = $ this -> asStripeSubscription ( ) ; $ subscription -> tax_percent = $ this -> user -> taxPercentage ( ) ; $ subscription -> save ( ) ; }
Sync the tax percentage of the user to the subscription .
41,891
public function asStripeSubscription ( ) { $ subscriptions = $ this -> user -> asStripeCustomer ( ) -> subscriptions ; if ( ! $ subscriptions ) { throw new LogicException ( 'The Stripe customer does not have any subscriptions.' ) ; } return $ subscriptions -> retrieve ( $ this -> stripe_id ) ; }
Get the subscription as a Stripe subscription object .
41,892
public function tab ( $ description , $ amount , array $ options = [ ] ) { if ( ! $ this -> stripe_id ) { throw new InvalidArgumentException ( class_basename ( $ this ) . ' is not a Stripe customer. See the createAsStripeCustomer method.' ) ; } $ options = array_merge ( [ 'customer' => $ this -> stripe_id , 'amount' =>...
Add an invoice item to the customer s upcoming invoice .
41,893
public function invoiceFor ( $ description , $ amount , array $ tabOptions = [ ] , array $ invoiceOptions = [ ] ) { $ this -> tab ( $ description , $ amount , $ tabOptions ) ; return $ this -> invoice ( $ invoiceOptions ) ; }
Invoice the customer for the given amount and generate an invoice immediately .
41,894
public function onTrial ( $ subscription = 'default' , $ plan = null ) { if ( func_num_args ( ) === 0 && $ this -> onGenericTrial ( ) ) { return true ; } $ subscription = $ this -> subscription ( $ subscription ) ; if ( is_null ( $ plan ) ) { return $ subscription && $ subscription -> onTrial ( ) ; } return $ subscript...
Determine if the Stripe model is on trial .
41,895
public function subscribed ( $ subscription = 'default' , $ plan = null ) { $ subscription = $ this -> subscription ( $ subscription ) ; if ( is_null ( $ subscription ) ) { return false ; } if ( is_null ( $ plan ) ) { return $ subscription -> valid ( ) ; } return $ subscription -> valid ( ) && $ subscription -> stripe_...
Determine if the Stripe model has a given subscription .
41,896
public function subscription ( $ subscription = 'default' ) { return $ this -> subscriptions -> sortByDesc ( function ( $ value ) { return $ value -> created_at -> getTimestamp ( ) ; } ) -> first ( function ( $ value ) use ( $ subscription ) { return $ value -> name === $ subscription ; } ) ; }
Get a subscription instance by name .
41,897
public function cards ( $ parameters = [ ] ) { $ cards = [ ] ; $ parameters = array_merge ( [ 'limit' => 24 ] , $ parameters ) ; $ stripeCards = $ this -> asStripeCustomer ( ) -> sources -> all ( [ 'object' => 'card' ] + $ parameters ) ; if ( ! is_null ( $ stripeCards ) ) { foreach ( $ stripeCards -> data as $ card ) {...
Get a collection of the entity s cards .
41,898
public function defaultCard ( ) { if ( ! $ this -> hasStripeId ( ) ) { return ; } $ customer = $ this -> asStripeCustomer ( ) ; foreach ( $ customer -> sources -> data as $ card ) { if ( $ card -> id === $ customer -> default_source ) { return $ card ; } } }
Get the default card for the entity .
41,899
protected function fillCardDetails ( $ card ) { if ( $ card instanceof StripeCard ) { $ this -> card_brand = $ card -> brand ; $ this -> card_last_four = $ card -> last4 ; } elseif ( $ card instanceof StripeBankAccount ) { $ this -> card_brand = 'Bank Account' ; $ this -> card_last_four = $ card -> last4 ; } return $ t...
Fills the model s properties with the source from Stripe .