Add DAILYNUM option for daily rotation of random numbers

This commit is contained in:
Kijin Sung 2016-04-28 11:19:19 +09:00
parent ffc46763c9
commit a23addca17

View file

@ -642,15 +642,21 @@ class boardController extends board
*/
public function createAnonymousNickname($format, $logged_info)
{
if (strpos($format, '$NUM') === false)
{
return $format;
}
else
if (strpos($format, '$NUM') !== false)
{
$num = hash_hmac('sha256', $logged_info->member_srl ?: \RX_CLIENT_IP, config('crypto.authentication_key'));
$num = sprintf('%08d', hexdec(substr($num, 0, 8)) % 100000000);
return strtr($format, array('$NUM' => $num));
}
elseif (strpos($format, '$DAILYNUM') !== false)
{
$num = hash_hmac('sha256', ($logged_info->member_srl ?: \RX_CLIENT_IP) . date('Ymd'), config('crypto.authentication_key'));
$num = sprintf('%08d', hexdec(substr($num, 0, 8)) % 100000000);
return strtr($format, array('$DAILYNUM' => $num));
}
else
{
return $format;
}
}
}