推 kai0817: [大笑]忘了洗碗水的人類08/22 16:16
推 eyb602: 蟑螂:我就是看到洗碗水換人拿才衝出來的08/22 16:47
→ eyb602: 話說妳這樣子只會教出比妳更怕蟑螂的小孩08/22 16:48
推 tcc440s: 所以五樓都吃蟑螂來交小孩不要怕蟑螂08/22 16:54
→ tcc440s: 教08/22 16:55
→ tcc440s: 幹...早知道就不要改了......08/22 16:56
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.193.74.170
※ 文章網址: http://www.ptt.cc/bbs/Web_Design/M.1409381251.A.133.html
Code:
<?
$t = 0;
$str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_';
$tab;
$temp = "{";
while ($t <= 63) {
global $tab,$temp;
$temp = $temp."\"".$str[$t]."\" : ".$t.",";
$t++;
};
$temp = substr($temp, 0,-1)."}";
$tab = json_decode($temp);
function aidc2aidu($aidc) {
global $str,$tab;
$aidu = 0;
if($aidc == null)
return 0;
$temp = $aidc[0];
$i = 0;
while ($i<strlen($aidc)) {
$v = 0;
if(strstr($str,$temp) != FALSE)
$v = $tab->$temp;
else
return 0;
$aidu = $aidu << 6;
//echo ($aidu | ($v & 0x3f))."<br/>";
$aidu = $aidu | ($v & 0x3f);
$temp = $aidc[$i];
$i++;
}
return $aidu;
}
function aidu2fn($fn,$aidu){
global $str,$tab;
$type = (($aidu >> 44) & 0xf);
$v1 = (($aidu >> 12) & 0xffffffff);
$v2 = ($aidu & 0xfff);
if($fn == null)
return null;
$fn = (($type == 0) ? 'M' : 'G').".".$v1.".A.".$v2;
return $fn;
}
//echo aidc2aidu("1JHzal4T")."<br/>";
$aidu = ( (float) sprintf('%u', ( aidu2fn("",aidc2aidu($_GET["aid"])) )));
echo "https://www.ptt.cc/bbs/".$_GET["board"]."/".$aidu.".html";
?>
※ 編輯: oToToT (123.193.74.170), 08/30/2014 21:29:59
→ alphadog: 那個就只是aid表示的8位base64轉48bits 08/31 01:11
→ alphadog: 48bits取右邊12bits和之上的32bits 08/31 01:14
→ alphadog: 再把這2組資料轉成數字拿來合成網址就行 08/31 01:17