mirror of
https://github.com/slawkens/myaac.git
synced 2026-04-23 02:43:31 +02:00
Merge branch 'main' into develop
This commit is contained in:
@@ -1,5 +1,18 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.8.9 - 06.04.2026]
|
||||||
|
### Added
|
||||||
|
* Settings: Possibility to add custom HTML for the head and body tags like Google Analytics code etc. (https://github.com/slawkens/myaac/commit/108e83806df5686a06826931ed5e243c19cbe130)
|
||||||
|
* Add command: give-admin (https://github.com/slawkens/myaac/commit/9fa9ec746c4b344387a21f21886c2251319806fc)
|
||||||
|
* Usage: php aac give:admin slawkens@gmail.com
|
||||||
|
Parameter: account email, name or id
|
||||||
|
* It's admin for the website, not the GM for the game! For that, go into the admin panel and change the group manually
|
||||||
|
* Add page load time to an Admin Panel footer (https://github.com/slawkens/myaac/commit/4ae2fdd0dfcd56697612395c14aecc2dfd33b1c3)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* Better character name validation, like in the original game website (#356)
|
||||||
|
* Install: don't suggest deleting of install folder - it's not required (https://github.com/slawkens/myaac/commit/5fcde4708a39255cf68edc8c43f2ac6597e2601d)
|
||||||
|
|
||||||
## [1.8.8 - 31.01.2026]
|
## [1.8.8 - 31.01.2026]
|
||||||
### Added
|
### Added
|
||||||
* Change Comment: Add missing hooks - patched from 0.8 (https://github.com/slawkens/myaac/commit/a60a23b84f61d41d1503073b52e01e3120f6d92a)
|
* Change Comment: Add missing hooks - patched from 0.8 (https://github.com/slawkens/myaac/commit/a60a23b84f61d41d1503073b52e01e3120f6d92a)
|
||||||
|
|||||||
@@ -93,9 +93,9 @@ switch ($action) {
|
|||||||
$creatureBoost = $db->query("SELECT * FROM " . $db->tableName('boosted_creature'))->fetchAll();
|
$creatureBoost = $db->query("SELECT * FROM " . $db->tableName('boosted_creature'))->fetchAll();
|
||||||
$bossBoost = $db->query("SELECT * FROM " . $db->tableName('boosted_boss'))->fetchAll();
|
$bossBoost = $db->query("SELECT * FROM " . $db->tableName('boosted_boss'))->fetchAll();
|
||||||
die(json_encode([
|
die(json_encode([
|
||||||
'boostedcreature' => true,
|
//'boostedcreature' => true,
|
||||||
|
'bossraceid' => intval($bossBoost[0]['raceid']),
|
||||||
'creatureraceid' => intval($creatureBoost[0]['raceid']),
|
'creatureraceid' => intval($creatureBoost[0]['raceid']),
|
||||||
'bossraceid' => intval($bossBoost[0]['raceid'])
|
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -1431,9 +1431,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.23",
|
"version": "4.18.1",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",
|
||||||
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
|
"integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ if($save)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(setting('core.account_create_character_create')) {
|
if(setting('core.account_create_character_create')) {
|
||||||
$character_name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : null;
|
$character_name = isset($_POST['name']) ? trim(stripslashes($_POST['name'])) : null;
|
||||||
$character_sex = isset($_POST['sex']) ? (int)$_POST['sex'] : null;
|
$character_sex = isset($_POST['sex']) ? (int)$_POST['sex'] : null;
|
||||||
$character_vocation = isset($_POST['vocation']) ? (int)$_POST['vocation'] : null;
|
$character_vocation = isset($_POST['vocation']) ? (int)$_POST['vocation'] : null;
|
||||||
$character_town = isset($_POST['town']) ? (int)$_POST['town'] : null;
|
$character_town = isset($_POST['town']) ? (int)$_POST['town'] : null;
|
||||||
|
|||||||
@@ -14,6 +14,26 @@ class Hooks
|
|||||||
self::$_hooks[$hook->type()][] = $hook;
|
self::$_hooks[$hook->type()][] = $hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function unregister($name, $type, $file): void
|
||||||
|
{
|
||||||
|
if (is_string($type)) {
|
||||||
|
$type = constant($type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset(self::$_hooks[$type])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(self::$_hooks[$type] as $id => $hook) {
|
||||||
|
if($name == $hook->name()
|
||||||
|
&& $type == $hook->type()
|
||||||
|
&& $file == $hook->file()
|
||||||
|
) {
|
||||||
|
unset(self::$_hooks[$type][$id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function trigger($type, $params = []): bool
|
public function trigger($type, $params = []): bool
|
||||||
{
|
{
|
||||||
$ret = true;
|
$ret = true;
|
||||||
|
|||||||
@@ -868,6 +868,11 @@ class Plugins {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global $hooks;
|
||||||
|
foreach($plugin_info['hooks'] ?? [] as $name => $info) {
|
||||||
|
$hooks->unregister($name, $info['type'], $info['file']);
|
||||||
|
}
|
||||||
|
|
||||||
clearCache();
|
clearCache();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ class Validator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// installer doesn't know config.php yet
|
// installer doesn't know settings yet
|
||||||
// that's why we need to ignore the nulls
|
// that's why we need to ignore the nulls
|
||||||
if(defined('MYAAC_INSTALL')) {
|
if(defined('MYAAC_INSTALL')) {
|
||||||
$minLength = 4;
|
$minLength = 4;
|
||||||
@@ -207,21 +207,15 @@ class Validator
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- [ ] '") != $length)
|
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM ") != $length)
|
||||||
{
|
{
|
||||||
self::$lastError = "Invalid name format. Use only A-Z, spaces and '.";
|
self::$lastError = "This name contains invalid letters. Please use only A-Z, a-z and space!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(preg_match('/ {2,}/', $name))
|
if(preg_match('/ {2,}/', $name))
|
||||||
{
|
{
|
||||||
self::$lastError = 'Invalid character name format. Use only A-Z and no double spaces.';
|
self::$lastError = 'Invalid character name format. Use only A-Z, a-z and no double spaces.';
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!preg_match("/[A-z ']/", $name))
|
|
||||||
{
|
|
||||||
self::$lastError = "Invalid name format. Use only A-Z, spaces and '.";
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,17 +224,23 @@ class Validator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate new character name.
|
* Validate new character name.
|
||||||
* Name lenght must be 3-25 chars
|
* Name length must be 3-25 chars
|
||||||
*
|
*
|
||||||
* @param string $name Name to check
|
* @param string $name Name to check
|
||||||
* @return bool Is name valid?
|
* @return bool Is name valid?
|
||||||
*/
|
*/
|
||||||
public static function newCharacterName($name)
|
public static function newCharacterName($name)
|
||||||
{
|
{
|
||||||
global $db, $config;
|
global $db;
|
||||||
|
|
||||||
|
$name = trim($name);
|
||||||
$name_lower = strtolower($name);
|
$name_lower = strtolower($name);
|
||||||
|
|
||||||
|
if(strlen($name) < 1) {
|
||||||
|
self::$lastError = 'Please enter a name.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$first_words_blocked = array_merge(["'", '-'], setting('core.create_character_name_blocked_prefix'));
|
$first_words_blocked = array_merge(["'", '-'], setting('core.create_character_name_blocked_prefix'));
|
||||||
foreach($first_words_blocked as $word) {
|
foreach($first_words_blocked as $word) {
|
||||||
if($word == substr($name_lower, 0, strlen($word))) {
|
if($word == substr($name_lower, 0, strlen($word))) {
|
||||||
@@ -249,11 +249,6 @@ class Validator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(str_ends_with($name_lower, "'") || str_ends_with($name_lower, "-")) {
|
|
||||||
self::$lastError = 'Your name contains illegal characters.';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(substr($name_lower, 1, 1) == ' ') {
|
if(substr($name_lower, 1, 1) == ' ') {
|
||||||
self::$lastError = 'Your name contains illegal space.';
|
self::$lastError = 'Your name contains illegal space.';
|
||||||
return false;
|
return false;
|
||||||
@@ -265,11 +260,36 @@ class Validator
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(preg_match('/ {2,}/', $name)) {
|
if(preg_match('/ {2,}/', $name)) {
|
||||||
self::$lastError = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
|
self::$lastError = 'Invalid character name format. Use only A-Z and no double spaces.';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strtolower($config['lua']['serverName']) == $name_lower) {
|
if (substr($name[0], 0, 1) !== strtoupper(substr($name[0], 0, 1))) {
|
||||||
|
self::$lastError = 'The first letter of a name has to be a capital letter.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (explode(' ', $name) as $word) {
|
||||||
|
$wordCut = substr($word, 1, strlen($word));
|
||||||
|
$hasUpperCase = preg_match('/[A-Z]/', $wordCut);
|
||||||
|
if ($hasUpperCase) {
|
||||||
|
self::$lastError = 'In names capital letters are only allowed at the beginning of a word.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($word) == 1) {
|
||||||
|
self::$lastError = 'This name contains a word with only one letter. Please use more than one letter for each word.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$hasVowel = preg_match('/[aeiouAEIOU]/', $word);
|
||||||
|
if (!$hasVowel) {
|
||||||
|
self::$lastError = 'This name contains a word without vowels. Please choose another name.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strtolower(configLua('serverName')) == $name_lower) {
|
||||||
self::$lastError = 'Your name cannot be same as server name.';
|
self::$lastError = 'Your name cannot be same as server name.';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,10 +63,7 @@ else if(isset($_GET['email']))
|
|||||||
}
|
}
|
||||||
else if(isset($_GET['name']))
|
else if(isset($_GET['name']))
|
||||||
{
|
{
|
||||||
$name = $_GET['name'];
|
$name = trim(stripslashes($_GET['name']));
|
||||||
if(!admin()) {
|
|
||||||
$name = strtolower(stripslashes($name));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Validator::characterName($name)) {
|
if(!Validator::characterName($name)) {
|
||||||
error_(Validator::getLastError());
|
error_(Validator::getLastError());
|
||||||
@@ -81,7 +78,12 @@ else if(isset($_GET['name']))
|
|||||||
error_($errors['name']);
|
error_($errors['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
success_('Good. Your name will be:<br /><b>' . (admin() ? $name : ucwords($name)) . '</b>');
|
$extraText = '';
|
||||||
|
if (admin()) {
|
||||||
|
$extraText = "<br/>Note: You are logged in as admin, so you can create almost any name without rules.";
|
||||||
|
}
|
||||||
|
|
||||||
|
success_("Good. Your name will be:<br /><b>$name</b>$extraText");
|
||||||
}
|
}
|
||||||
else if(isset($_GET['password']) && isset($_GET['password_confirm'])) {
|
else if(isset($_GET['password']) && isset($_GET['password_confirm'])) {
|
||||||
$password = $_GET['password'];
|
$password = $_GET['password'];
|
||||||
|
|||||||
Reference in New Issue
Block a user