no message
This commit is contained in:
parent
59fd6c9045
commit
66959ad103
@ -152,6 +152,9 @@ class Node extends Base {
|
||||
$oNode->duck_group = str_replace('server', 'node', $oNode->duck_group);
|
||||
$oNode->is_shadow = 1;
|
||||
$oNode->password = array_pop($aPwds[$oNode->pid]) ?? Tools::genRandomChar(32);
|
||||
if ($oNode->country_code) {
|
||||
$oNode->country_emoji = $this->getCountryEmoji($oNode->country_code);
|
||||
}
|
||||
$iDone += $oNode->save();
|
||||
$iNodeId++;
|
||||
}
|
||||
@ -160,6 +163,29 @@ class Node extends Base {
|
||||
return "搞定,生成".$iDone."节点";
|
||||
}
|
||||
|
||||
/**
|
||||
* 将国家代码转换为国旗 Emoji
|
||||
* * @param string $sCountryCode 如 "jp", "us"
|
||||
* @return string
|
||||
*/
|
||||
public function getCountryEmoji(string $sCountryCode): string
|
||||
{
|
||||
$sCountryCode = strtoupper($sCountryCode);
|
||||
|
||||
// 严谨校验:必须是 2 位字母
|
||||
if (!preg_match('/^[A-Z]{2}$/', $sCountryCode)) {
|
||||
return $sCountryCode;
|
||||
}
|
||||
|
||||
// 127397 是 Unicode 偏移量 (0x1F1E6 - 65)
|
||||
$iOffset = 127397;
|
||||
|
||||
$sFirstChar = mb_chr(ord($sCountryCode[0]) + $iOffset);
|
||||
$sSecondChar = mb_chr(ord($sCountryCode[1]) + $iOffset);
|
||||
|
||||
return $sFirstChar . $sSecondChar;
|
||||
}
|
||||
|
||||
public function clone($aParam)
|
||||
{
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user