public function decode($hash, $type = '')
{
if (strlen($hash) !== 11) {
return false;
}
if (!isset($this->_keys[$type])) {
$this->_keys[$type] = md5($this->_key . $type, true);
}
$r = unpack('Vid/Vr', mcrypt_decrypt(MCRYPT_XTEA, $this->_keys[$type], base64_decode($hash . '='), MCRYPT_MODE_ECB));
if ($r['r'] & 0xffff) {
return false;
} else {
return $r['id'];
}
}