Improve anonymous nickname to generate random number per date and document.

https://www.xetown.com/qna/745244
This commit is contained in:
BJRambo 2017-09-27 15:48:02 +09:00
parent 5138a765d4
commit f75efa1b5d
2 changed files with 7 additions and 1 deletions

View file

@ -742,6 +742,12 @@ class boardController extends board
$num = sprintf('%08d', hexdec(substr($num, 0, 8)) % 100000000);
return strtr($format, array('$DOCNUM' => $num));
}
elseif (strpos($format, '$DOCDAILYNUM') !== false)
{
$num = hash_hmac('sha256', ($member_srl ?: \RX_CLIENT_IP) . ':document_srl:' . $document_srl . ':date:' . date('Y-m-d'), config('crypto.authentication_key'));
$num = sprintf('%08d', hexdec(substr($num, 0, 8)) % 100000000);
return strtr($format, array('$DOCDAILYNUM' => $num));
}
else
{
return $format;