diff --git a/modules/board/board.controller.php b/modules/board/board.controller.php
index ea7b619e6..58fe74501 100644
--- a/modules/board/board.controller.php
+++ b/modules/board/board.controller.php
@@ -823,18 +823,19 @@ class BoardController extends Board
* @param int $document_srl
* @return string
*/
- public function createAnonymousName($format, $member_srl, $document_srl)
+ public static function createAnonymousName($format, $member_srl, $document_srl): string
{
- return preg_replace_callback('/\$((?:DAILY|DOC|DOCDAILY|)NUM)(?::([0-9]))?/', function($matches) use($member_srl, $document_srl) {
- $digits = empty($matches[2]) ? 8 : max(1, min(8, intval($matches[2])));
+ return preg_replace_callback('/\$(DAILY|DOC|DOCDAILY|)(NUM|STR)(?::([0-9]))?/', function($matches) use($member_srl, $document_srl) {
+ $digits = empty($matches[3]) ? 8 : max(1, min(8, intval($matches[3])));
+ $type = strtolower($matches[2]);
switch ($matches[1])
{
- case 'NUM': return self::_createHash($member_srl ?: \RX_CLIENT_IP, $digits);
- case 'DAILYNUM': return self::_createHash(($member_srl ?: \RX_CLIENT_IP) . ':date:' . date('Y-m-d'), $digits);
- case 'DOCNUM': return self::_createHash(($member_srl ?: \RX_CLIENT_IP) . ':document_srl:' . $document_srl, $digits);
- case 'DOCDAILYNUM': return self::_createHash(($member_srl ?: \RX_CLIENT_IP) . ':document_srl:' . $document_srl . ':date:' . date('Y-m-d'), $digits);
+ case '': return self::_createHash($member_srl ?: \RX_CLIENT_IP, $digits, $type);
+ case 'DAILY': return self::_createHash(($member_srl ?: \RX_CLIENT_IP) . ':date:' . date('Y-m-d'), $digits, $type);
+ case 'DOC': return self::_createHash(($member_srl ?: \RX_CLIENT_IP) . ':document_srl:' . $document_srl, $digits, $type);
+ case 'DOCDAILY': return self::_createHash(($member_srl ?: \RX_CLIENT_IP) . ':document_srl:' . $document_srl . ':date:' . date('Y-m-d'), $digits, $type);
}
- }, $format);
+ }, (string)$format);
}
/**
@@ -842,12 +843,19 @@ class BoardController extends Board
*
* @param string $content
* @param int $digits
+ * @param string $type
* @return string
*/
- protected static function _createHash(string $content, int $digits = 8): string
+ protected static function _createHash(string $content, int $digits = 8, string $type = 'num'): string
{
$hash = hash_hmac('sha256', $content, config('crypto.authentication_key'));
- $num = sprintf('%0' . $digits . 'd', hexdec(substr($hash, 0, 8)) % pow(10, $digits));
- return $num;
+ if ($type === 'num')
+ {
+ return sprintf('%0' . $digits . 'd', hexdec(substr($hash, 0, 8)) % pow(10, $digits));
+ }
+ else
+ {
+ return substr($hash, 0, $digits);
+ }
}
}
diff --git a/modules/board/lang/en.php b/modules/board/lang/en.php
index e03a72b48..ec3ad2bc5 100644
--- a/modules/board/lang/en.php
+++ b/modules/board/lang/en.php
@@ -34,7 +34,7 @@ $lang->about_customize_bottom_list = 'Calculating the bottom list consumes a lot
$lang->about_use_anonymous_part1 = 'Hide the author\'s nickname to turn this board into an anonymous board.';
$lang->about_use_anonymous_part2 = 'It is more useful if you also hide the nickname in the skin.
Please also turn off document history, or the author\'s information may be revealed by the history.';
$lang->about_anonymous_except_admin = 'The administrator\'s nickname will not be hidden.';
-$lang->about_anonymous_name = 'You can customize the anonymous name that is displayed instead of the author\'s nickname.
$NUM will be replaced with a random number that is unique to each member. (e.g. anon_$NUM → anon_12345678)
$DAILYNUM will be replaced with a random number that is unique to each member but changes every day.
$DOCNUM will be replaced with a random number that is unique to each member and changes from document to document.
$DOCDAILYNUM will be replaced with a random number that is unique to each member and changes every day from document to document.
You can append a number to each variable, like $DAILYNUM:5 to control the number of digits from 1 to 8.';
+$lang->about_anonymous_name = 'You can customize the anonymous name that is displayed instead of the author\'s nickname.
$NUM will be replaced with a random number that is unique to each member. (e.g. anon_$NUM → anon_12345678)
$DAILYNUM will be replaced with a random number that is unique to each member but changes every day.
$DOCNUM will be replaced with a random number that is unique to each member and changes from document to document.
$DOCDAILYNUM will be replaced with a random number that is unique to each member and changes every day from document to document.
You can append a number to each variable, like $DAILYNUM:5 to control the number of digits from 1 to 8.
To use hexadecimal digits that include some alphabets, use STR instead of NUM.';
$lang->about_board = 'This module is for creating and managing boards.';
$lang->about_consultation = 'Non-administrator members would see their own articles. Non-members would not be able to write articles when using consultation.';
$lang->about_secret = 'Users will be able to write secret articles or comments.';
diff --git a/modules/board/lang/ko.php b/modules/board/lang/ko.php
index d501354d6..89c6d2bd8 100644
--- a/modules/board/lang/ko.php
+++ b/modules/board/lang/ko.php
@@ -35,7 +35,7 @@ $lang->about_customize_bottom_list = '게시물이 많은 경우 하단목록
$lang->about_use_anonymous_part1 = '글쓴이의 정보를 제거하고 익명으로 게시판을 사용하도록 합니다.';
$lang->about_use_anonymous_part2 = '스킨 설정에서 글쓴이 정보 등을 숨기도록 설정하면 더욱 유용합니다.
추가 설정에서 문서 히스토리가 켜져 있으면 문서 수정시 작성자가 표시될 수 있으니 주의하십시오.';
$lang->about_anonymous_except_admin = '관리권한이 있는 회원은 익명으로 표시되지 않도록 합니다.';
-$lang->about_anonymous_name = '익명 기능을 사용할 때 표시할 익명 닉네임을 정할 수 있습니다.
$NUM을 사용하면 회원마다 고유한 난수를 부여할 수 있습니다. (예: 익명_$NUM → 익명_12345678)
$DAILYNUM을 사용하면 매일 난수가 변경되고, $DOCNUM을 사용하면 문서마다 변경됩니다.
$DOCDAILYNUM을 사용하면 문서마다 각각, 그리고 매일 변경됩니다.
각 변수 뒤에 $DAILYNUM:5와 같이 1~8 숫자를 붙여 자릿수를 조정할 수 있습니다.';
+$lang->about_anonymous_name = '익명 기능을 사용할 때 표시할 익명 닉네임을 정할 수 있습니다.
$NUM을 사용하면 회원마다 고유한 난수를 부여할 수 있습니다. (예: 익명_$NUM → 익명_12345678)
$DAILYNUM을 사용하면 매일 난수가 변경되고, $DOCNUM을 사용하면 문서마다 변경됩니다.
$DOCDAILYNUM을 사용하면 문서마다 각각, 그리고 매일 변경됩니다.
각 변수 뒤에 $DAILYNUM:5와 같이 1~8 숫자를 붙여 자릿수를 조정할 수 있습니다.
NUM 대신 STR를 사용하면 일부 알파벳이 포함된 16진수를 사용합니다.';
$lang->about_board = '게시판을 생성하고 관리할 수 있습니다.';
$lang->about_consultation = '상담 기능은 관리권한이 없는 회원은 자신이 쓴 글만 보이도록 하는 기능입니다. 단 상담기능 사용시 비회원 글쓰기는 자동으로 금지됩니다.';
$lang->about_secret = '게시판 및 댓글의 비밀글 기능을 사용할 수 있도록 합니다.';