File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -169,21 +169,22 @@ private function post($url, $body)
169
169
*/
170
170
public static function createTimestampAntiLeechUrl ($ rawUrl , $ encryptKey , $ durationInSeconds )
171
171
{
172
-
173
172
$ parsedUrl = parse_url ($ rawUrl );
174
173
175
174
$ deadline = time () + $ durationInSeconds ;
176
175
$ expireHex = dechex ($ deadline );
176
+
177
177
$ path = isset ($ parsedUrl ['path ' ]) ? $ parsedUrl ['path ' ] : '' ;
178
178
$ path = implode ('/ ' , array_map ('rawurlencode ' , explode ('/ ' , $ path )));
179
-
180
179
$ strToSign = $ encryptKey . $ path . $ expireHex ;
181
180
$ signStr = md5 ($ strToSign );
182
181
182
+ $ url = $ parsedUrl ['scheme ' ].':// ' .$ parsedUrl ['host ' ].$ path ;
183
+
183
184
if (isset ($ parsedUrl ['query ' ])) {
184
- $ signedUrl = $ rawUrl . '&sign= ' . $ signStr . '&t= ' . $ expireHex ;
185
+ $ signedUrl = $ url . '&sign= ' . $ signStr . '&t= ' . $ expireHex ;
185
186
} else {
186
- $ signedUrl = $ rawUrl . '?sign= ' . $ signStr . '&t= ' . $ expireHex ;
187
+ $ signedUrl = $ url . '?sign= ' . $ signStr . '&t= ' . $ expireHex ;
187
188
}
188
189
189
190
return $ signedUrl ;
You can’t perform that action at this time.
0 commit comments