-
-
Save noscripter/da645bc6a3b7384920a24dac5103bc84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function from62to10($num) { | |
$from = 62; | |
$num = strval($num); | |
$dict = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
$len = strlen($num); | |
$dec = 0; | |
for($i = 0; $i < $len; $i++) { | |
$pos = strpos($dict, $num[$i]); | |
$dec = bcadd(bcmul(bcpow($from, $len - $i - 1), $pos), $dec); | |
} | |
return $dec; | |
} | |
function decode($url) { | |
$file = basename($url,'.jpg'); | |
$code = substr($file, 0, 8); | |
if (substr($code, 0, 2) == '00') { | |
return from62to10($code); | |
} else { | |
return hexdec($code); | |
} | |
} | |
$weibo = 'http://weibo.com/u/' . decode($url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment