Skip to content

Commit

Permalink
Merge pull request #311 from qiniu/develop
Browse files Browse the repository at this point in the history
update CdnManager.php
  • Loading branch information
ankadada authored Aug 1, 2019
2 parents afe7d87 + c1867c2 commit abf34f8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ php:
- 5.6
- 7.0

dist: trusty

before_script:
- export QINIU_TEST_ENV="travis"
- travis_retry composer self-update
Expand Down
11 changes: 2 additions & 9 deletions src/Qiniu/Cdn/CdnManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,16 @@ private function post($url, $body)
public static function createTimestampAntiLeechUrl($rawUrl, $encryptKey, $durationInSeconds)
{
$parsedUrl = parse_url($rawUrl);

$deadline = time() + $durationInSeconds;
$expireHex = dechex($deadline);

$path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '';
$path = implode('/', array_map('rawurlencode', explode('/', $path)));
$strToSign = $encryptKey . $path . $expireHex;
$signStr = md5($strToSign);

$url = $parsedUrl['scheme'].'://'.$parsedUrl['host'].$path;

if (isset($parsedUrl['query'])) {
$signedUrl = $url . '&sign=' . $signStr . '&t=' . $expireHex;
$signedUrl = $rawUrl . '&sign=' . $signStr . '&t=' . $expireHex;
} else {
$signedUrl = $url . '?sign=' . $signStr . '&t=' . $expireHex;
$signedUrl = $rawUrl . '?sign=' . $signStr . '&t=' . $expireHex;
}

return $signedUrl;
}
}
2 changes: 1 addition & 1 deletion src/Qiniu/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

final class Config
{
const SDK_VER = '7.2.9';
const SDK_VER = '7.2.10';

const BLOCK_SIZE = 4194304; //4*1024*1024 分块上传块大小,该参数为接口规格,不能修改

Expand Down

0 comments on commit abf34f8

Please sign in to comment.