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)
169169 */
170170 public static function createTimestampAntiLeechUrl ($ rawUrl , $ encryptKey , $ durationInSeconds )
171171 {
172-
173172 $ parsedUrl = parse_url ($ rawUrl );
174173
175174 $ deadline = time () + $ durationInSeconds ;
176175 $ expireHex = dechex ($ deadline );
176+
177177 $ path = isset ($ parsedUrl ['path ' ]) ? $ parsedUrl ['path ' ] : '' ;
178178 $ path = implode ('/ ' , array_map ('rawurlencode ' , explode ('/ ' , $ path )));
179-
180179 $ strToSign = $ encryptKey . $ path . $ expireHex ;
181180 $ signStr = md5 ($ strToSign );
182181
182+ $ url = $ parsedUrl ['scheme ' ].':// ' .$ parsedUrl ['host ' ].$ path ;
183+
183184 if (isset ($ parsedUrl ['query ' ])) {
184- $ signedUrl = $ rawUrl . '&sign= ' . $ signStr . '&t= ' . $ expireHex ;
185+ $ signedUrl = $ url . '&sign= ' . $ signStr . '&t= ' . $ expireHex ;
185186 } else {
186- $ signedUrl = $ rawUrl . '?sign= ' . $ signStr . '&t= ' . $ expireHex ;
187+ $ signedUrl = $ url . '?sign= ' . $ signStr . '&t= ' . $ expireHex ;
187188 }
188189
189190 return $ signedUrl ;
You can’t perform that action at this time.
0 commit comments