add getAccountId function

This commit is contained in:
Beu 2023-12-23 12:15:00 +01:00
parent e44dfa0ef2
commit 996dde826d
1 changed files with 17 additions and 0 deletions

View File

@ -196,6 +196,23 @@ class Player implements Dumpable, UsageInformationAble {
return ($this->pid <= 0 || substr($this->login, 0, 1) === '*');
}
/**
* Get AccountId from Login
*
* @api
* @return string
*/
public function getAccountId() {
if (strlen($this->login) !== 22) return $this->login;
$login = str_pad($this->login, 24, "=", STR_PAD_RIGHT);
$login = str_replace("_","/", str_replace("-","+", $login));
$login = base64_decode($login);
return vsprintf("%s%s-%s-%s-%s-%s%s%s", str_split(bin2hex($login), 4));
}
/**
* Get province
*