Merge branch 'develop' into blacktek-toml

This commit is contained in:
slawkens
2026-04-17 17:31:13 +02:00
28 changed files with 217 additions and 93 deletions

View File

@@ -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)

View File

@@ -1,9 +1,12 @@
## [2.0-dev - x.x.2025] ## [2.0-dev - x.x.2025]
### Added ### Added
* Add an "access" option to Menus (#340) * Menus: Add an "access" option to Menus (#340)
* Possibility to hide menus for unauthorized users * Possibility to hide menus for unauthorized users
* Add the possibility to fetch skills, balance and frags in the getTopPlayers function (#347) * Settings: Add Reset button (https://github.com/slawkens/myaac/commit/7104c2258fd724a55239821b46a616dab845b22a, https://github.com/slawkens/myaac/commit/e274b8350451a20c24e652ea05ed1964ebb86b54)
* New Setting: block create account spam by ip (https://github.com/slawkens/myaac/commit/54265f42e987522803288477952d6e5c4daeeb24)
* Functions: Add the possibility to fetch skills, balance and frags in the getTopPlayers function (#347)
* Plugins: autoload init-priority option (https://github.com/slawkens/myaac/commit/f1aa12840875960849fa0c99a2bbe0ad2949bbec)
### Changed ### Changed
* Better handling of vocations: (#345) * Better handling of vocations: (#345)
@@ -11,6 +14,7 @@
* Support for Monk vocation * Support for Monk vocation
* Better gallery, loads images from images/gallery folder * Better gallery, loads images from images/gallery folder
* Reworked account action logs to use a single IP column as varchar(45) for both ipv4 and ipv6 (#289) * Reworked account action logs to use a single IP column as varchar(45) for both ipv4 and ipv6 (#289)
* Make myaac_config table columns bigger (https://github.com/slawkens/myaac/commit/2c62a97160a3ffe9976ee5bd1d770a0abc576742)
* Admin Panel: save menu collapse state (https://github.com/slawkens/myaac/commit/55da00520df7463a1d1ca41931df1598e9f2ffeb) * Admin Panel: save menu collapse state (https://github.com/slawkens/myaac/commit/55da00520df7463a1d1ca41931df1598e9f2ffeb)
### Internal ### Internal

View File

@@ -7,7 +7,7 @@ Official website: https://my-aac.org
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/slawkens/myaac/cypress.yml)](https://github.com/slawkens/myaac/actions) [![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/slawkens/myaac/cypress.yml)](https://github.com/slawkens/myaac/actions)
[![License: GPL-3.0](https://img.shields.io/github/license/slawkens/myaac)](https://opensource.org/licenses/gpl-license) [![License: GPL-3.0](https://img.shields.io/github/license/slawkens/myaac)](https://opensource.org/licenses/gpl-license)
[![Downloads Count](https://img.shields.io/github/downloads/slawkens/myaac/total)](https://github.com/slawkens/myaac/releases) [![Downloads Count](https://img.shields.io/github/downloads/slawkens/myaac/total)](https://github.com/slawkens/myaac/releases)
[![OpenTibia Discord](https://img.shields.io/discord/288399552581468162)](https://discord.gg/2J39Wus) [![MyAAC Discord](https://img.shields.io/discord/1468205461319848049)](https://discord.gg/aVagGPJt3g)
[![Closed Issues](https://img.shields.io/github/issues-closed-raw/slawkens/myaac)](https://github.com/slawkens/myaac/issues?q=is%3Aissue+is%3Aclosed) [![Closed Issues](https://img.shields.io/github/issues-closed-raw/slawkens/myaac)](https://github.com/slawkens/myaac/issues?q=is%3Aissue+is%3Aclosed)
| Version | Status | Branch | Requirements | | Version | Status | Branch | Requirements |
@@ -86,12 +86,6 @@ Look: [Contributing](https://docs.my-aac.org/misc/contributing) in our wiki.
If you have a great idea or want to contribute to the project - visit our website at https://www.my-aac.org If you have a great idea or want to contribute to the project - visit our website at https://www.my-aac.org
## Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
[![JetBrains](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/slawkens)
### License ### License
This program and all associated files are released under the GNU Public License. This program and all associated files are released under the GNU Public License.

View File

@@ -46,6 +46,15 @@ if (!is_array($settingsFile)) {
return; return;
} }
if (isset($_POST['reset']) && $_POST['reset'] == '1') {
$settings = Settings::getInstance();
$settings->deleteFromDatabase($settingsFile['key']);
$settings->clearCache();
success('Settings for this plugin has been reset.');
}
$settingsKeyName = ($plugin == 'core' ? $plugin : $settingsFile['key']); $settingsKeyName = ($plugin == 'core' ? $plugin : $settingsFile['key']);
$title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $settingsFile['name']); $title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $settingsFile['name']);
@@ -57,4 +66,5 @@ $twig->display('admin.settings.html.twig', [
'settings' => $settingsFile['settings'], 'settings' => $settingsFile['settings'],
'script' => $settingsParsed['script'], 'script' => $settingsParsed['script'],
'settingsKeyName' => $settingsKeyName, 'settingsKeyName' => $settingsKeyName,
'pluginName' => $plugin,
]); ]);

View File

@@ -172,7 +172,8 @@
<div class="float-sm-right d-none d-sm-inline"> <div class="float-sm-right d-none d-sm-inline">
<span class="p-2 right badge badge-<?php echo((isset($status['online']) and $status['online']) ? 'success' : 'danger'); ?>"><?php echo $config['lua']['serverName'] ?></span> <span class="p-2 right badge badge-<?php echo((isset($status['online']) and $status['online']) ? 'success' : 'danger'); ?>"><?php echo $config['lua']['serverName'] ?></span>
</div> </div>
<?php echo base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4='); ?> <?= base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4='); ?>
<?= 'Load time: ' . round(microtime(true) - START_TIME, 4) . ' seconds.'; ?>
</footer> </footer>
<div id="sidebar-overlay"></div> <div id="sidebar-overlay"></div>
</div> </div>

View File

@@ -27,7 +27,7 @@ if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is
const MYAAC = true; const MYAAC = true;
const MYAAC_VERSION = '2.0-dev'; const MYAAC_VERSION = '2.0-dev';
const DATABASE_VERSION = 50; const DATABASE_VERSION = 52;
const TABLE_PREFIX = 'myaac_'; const TABLE_PREFIX = 'myaac_';
define('START_TIME', microtime(true)); define('START_TIME', microtime(true));
define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX'));

View File

@@ -5,7 +5,9 @@ CREATE TABLE IF NOT EXISTS `myaac_account_actions`
`ip` varchar(45) NOT NULL DEFAULT '', `ip` varchar(45) NOT NULL DEFAULT '',
`date` int NOT NULL DEFAULT 0, `date` int NOT NULL DEFAULT 0,
`action` varchar(255) NOT NULL DEFAULT '', `action` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`) PRIMARY KEY (`id`),
INDEX `myaac_account_actions_account_id` (`account_id`),
INDEX `myaac_account_actions_ip` (`ip`)
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;
CREATE TABLE IF NOT EXISTS `myaac_account_emails_verify` CREATE TABLE IF NOT EXISTS `myaac_account_emails_verify`
@@ -43,8 +45,8 @@ CREATE TABLE IF NOT EXISTS `myaac_changelog`
CREATE TABLE IF NOT EXISTS `myaac_config` CREATE TABLE IF NOT EXISTS `myaac_config`
( (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL, `name` varchar(255) NOT NULL,
`value` varchar(1000) NOT NULL, `value` varchar(10000) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE (`name`) UNIQUE (`name`)
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4; ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;

View File

@@ -30,7 +30,7 @@ if(file_exists(CACHE . 'install.txt')) {
$install_status = unserialize(file_get_contents(CACHE . 'install.txt')); $install_status = unserialize(file_get_contents(CACHE . 'install.txt'));
if(!isset($_REQUEST['step'])) { if(!isset($_REQUEST['step'])) {
$step = isset($install_status['step']) ? $install_status['step'] : ''; $step = $install_status['step'] ?? '';
} }
} }
@@ -53,7 +53,7 @@ if($step == 'finish' && (!isset($config['installed']) || !$config['installed']))
// step verify // step verify
$steps = array(1 => 'welcome', 2 => 'license', 3 => 'requirements', 4 => 'config', 5 => 'database', 6 => 'admin', 7 => 'finish'); $steps = array(1 => 'welcome', 2 => 'license', 3 => 'requirements', 4 => 'config', 5 => 'database', 6 => 'admin', 7 => 'finish');
if(!in_array($step, $steps)) // check if step is valid if(!in_array($step, $steps)) // check if a step is valid
throw new RuntimeException('ERROR: Unknown step.'); throw new RuntimeException('ERROR: Unknown step.');
$install_status['step'] = $step; $install_status['step'] = $step;
@@ -61,7 +61,7 @@ $errors = array();
if($step == 'database') { if($step == 'database') {
foreach($_SESSION as $key => $value) { foreach($_SESSION as $key => $value) {
if(strpos($key, 'var_') === false) { if(!str_contains($key, 'var_')) {
continue; continue;
} }
@@ -182,7 +182,7 @@ $error = false;
clearstatcache(); clearstatcache();
if(is_writable(CACHE) && (MYAAC_OS != 'WINDOWS' || win_is_writable(CACHE))) { if(is_writable(CACHE) && (MYAAC_OS != 'WINDOWS' || win_is_writable(CACHE))) {
if(!file_exists(BASE . 'install/ip.txt')) { if(!file_exists(BASE . 'install/ip.txt')) {
$content = warning('AAC installation is disabled. To enable it make file <b>ip.txt</b> in install/ directory and put there your IP.<br/> $content = warning('AAC installation is disabled. To enable it make a file <b>ip.txt</b> in install/ directory and put there your IP.<br/>
Your IP is:<br /><b>' . get_browser_real_ip() . '</b>', true); Your IP is:<br /><b>' . get_browser_real_ip() . '</b>', true);
} }
else { else {
@@ -198,7 +198,7 @@ if(is_writable(CACHE) && (MYAAC_OS != 'WINDOWS' || win_is_writable(CACHE))) {
if(!$allow) if(!$allow)
{ {
$content = warning('In file <b>install/ip.txt</b> must be your IP!<br/> $content = warning('In file <b>install/ip.txt</b> must be your IP!<br/>
In file is:<br /><b>' . nl2br($file_content) . '</b><br/> In the file is:<br /><b>' . nl2br($file_content) . '</b><br/>
Your IP is:<br /><b>' . get_browser_real_ip() . '</b>', true); Your IP is:<br /><b>' . get_browser_real_ip() . '</b>', true);
} }
else { else {

View File

@@ -30,6 +30,8 @@ $up();
DataLoader::setLocale($locale); DataLoader::setLocale($locale);
DataLoader::load(); DataLoader::load();
clearCache();
// add menus entries // add menus entries
require_once SYSTEM . 'migrations/17.php'; require_once SYSTEM . 'migrations/17.php';
$up(); $up();
@@ -67,6 +69,10 @@ if(file_exists(CACHE . 'install.txt')) {
unlink(CACHE . 'install.txt'); unlink(CACHE . 'install.txt');
} }
if(file_exists(BASE . 'install/ip.txt')) {
unlink(BASE . 'install/ip.txt');
}
$locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(str_replace('tools/', '',ADMIN_URL), $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']); $locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(str_replace('tools/', '',ADMIN_URL), $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']);
$locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(str_replace('tools/', '', BASE_URL), $locale['step_finish_homepage'], true), $locale['step_finish_desc']); $locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(str_replace('tools/', '', BASE_URL), $locale['step_finish_homepage'], true), $locale['step_finish_desc']);
$locale['step_finish_desc'] = str_replace('$LINK$', generateLink('https://my-aac.org', 'https://my-aac.org', true), $locale['step_finish_desc']); $locale['step_finish_desc'] = str_replace('$LINK$', generateLink('https://my-aac.org', 'https://my-aac.org', true), $locale['step_finish_desc']);

View File

@@ -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'])
])); ]));
} }

12
package-lock.json generated
View File

@@ -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"
}, },
@@ -1743,9 +1743,9 @@
} }
}, },
"node_modules/qs": { "node_modules/qs": {
"version": "6.14.1", "version": "6.14.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
"integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
"dev": true, "dev": true,
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {

View File

@@ -20,7 +20,7 @@ $locale['not_loaded'] = 'Nicht geladen';
$locale['loading_spinner'] = 'Bitte warten, installieren...'; $locale['loading_spinner'] = 'Bitte warten, installieren...';
$locale['importing_spinner'] = 'Bitte warte, Daten werden importiert...'; $locale['importing_spinner'] = 'Bitte warte, Daten werden importiert...';
$locale['please_fill_all'] = 'Bitte füllen Sie alle Felder aus!'; $locale['please_fill_all'] = 'Bitte füllen Sie alle Felder aus!';
$locale['already_installed'] = 'MyAAC wurde bereits installiert. Bitte löschen <b>install/</b> Verzeichnis. Wenn Sie MyAAC neu installieren möchten, löschen Sie die Datei <strong>config.local.php</strong> aus dem Hauptverzeichnis und aktualisieren Sie die Seite.'; $locale['already_installed'] = 'MyAAC wurde bereits installiert. Wenn Sie MyAAC neu installieren möchten, löschen Sie die Datei <strong>config.local.php</strong> aus dem Hauptverzeichnis und aktualisieren Sie die Seite.';
// welcome // welcome
$locale['step_welcome'] = 'Willkommen'; $locale['step_welcome'] = 'Willkommen';

View File

@@ -20,7 +20,7 @@ $locale['not_loaded'] = 'Not loaded';
$locale['loading_spinner'] = 'Please wait, installing...'; $locale['loading_spinner'] = 'Please wait, installing...';
$locale['importing_spinner'] = 'Please wait, importing data...'; $locale['importing_spinner'] = 'Please wait, importing data...';
$locale['please_fill_all'] = 'Please fill all inputs!'; $locale['please_fill_all'] = 'Please fill all inputs!';
$locale['already_installed'] = 'MyAAC has been already installed. Please delete <b>install/</b> directory. If you want to reinstall MyAAC - please delete <strong>config.local.php</strong> file from the main directory and refresh the page.'; $locale['already_installed'] = 'MyAAC has been already installed. If you want to reinstall MyAAC - please delete <strong>config.local.php</strong> file from the main directory and refresh the page.';
// welcome // welcome
$locale['step_welcome'] = 'Welcome'; $locale['step_welcome'] = 'Welcome';

View File

@@ -20,7 +20,7 @@ $locale['not_loaded'] = 'Nie załadowane';
$locale['loading_spinner'] = 'Proszę czekać, trwa instalacja...'; $locale['loading_spinner'] = 'Proszę czekać, trwa instalacja...';
$locale['importing_spinner'] = 'Proszę czekać, trwa importowanie danych...'; $locale['importing_spinner'] = 'Proszę czekać, trwa importowanie danych...';
$locale['please_fill_all'] = 'Proszę wypełnić wszystkie pola!'; $locale['please_fill_all'] = 'Proszę wypełnić wszystkie pola!';
$locale['already_installed'] = 'MyAAC został już zainstalowany. Proszę usunąć katalog <b>install/</b>. Jeśli chcesz zainstalować MyAAC od nowa - proszę usuń plik <strong>config.local.php</strong> z katalogu głównego i odśwież stronę.'; $locale['already_installed'] = 'MyAAC został już zainstalowany. Jeśli chcesz zainstalować MyAAC od nowa - proszę usuń plik <strong>config.local.php</strong> z katalogu głównego i odśwież stronę.';
// welcome // welcome
$locale['step_welcome'] = 'Witamy'; $locale['step_welcome'] = 'Witamy';

View File

@@ -20,7 +20,7 @@ $locale['not_loaded'] = 'Não carregado';
$locale['loading_spinner'] = 'Por favor aguarde, instalando...'; $locale['loading_spinner'] = 'Por favor aguarde, instalando...';
$locale['importing_spinner'] = 'Por favor, aguarde, importando dados...'; $locale['importing_spinner'] = 'Por favor, aguarde, importando dados...';
$locale['please_fill_all'] = 'Por favor, preencha todas as entradas!'; $locale['please_fill_all'] = 'Por favor, preencha todas as entradas!';
$locale['already_installed'] = 'MyAAC já foi instalado. Por favor, apague o diretório <b> install/ <b/>. Se você quiser reinstalar o MyAAC - exclua o arquivo <strong> config.local.php </strong> do diretório principal e atualize a página.'; $locale['already_installed'] = 'MyAAC já foi instalado. Se você quiser reinstalar o MyAAC - exclua o arquivo <strong> config.local.php </strong> do diretório principal e atualize a página.';
// welcome // welcome
$locale['step_welcome'] = 'Bem vindo'; $locale['step_welcome'] = 'Bem vindo';

View File

@@ -18,7 +18,7 @@ $locale['loaded'] = 'Laddad';
$locale['not_loaded'] = 'Inte Laddad'; $locale['not_loaded'] = 'Inte Laddad';
$locale['please_fill_all'] = 'Vänligen fyll i allt!'; $locale['please_fill_all'] = 'Vänligen fyll i allt!';
$locale['already_installed'] = 'MyAAC är redan installerat. Vänligen ta bort <b>install/<b/> mappen. Om du vill installera MyAAC igen - ta bort filen <strong>config.local.php</strong> från huvudkatalogen och uppdatera sidan.'; $locale['already_installed'] = 'MyAAC är redan installerat. Om du vill installera MyAAC igen - ta bort filen <strong>config.local.php</strong> från huvudkatalogen och uppdatera sidan.';
// welcome // welcome
$locale['step_welcome'] = 'Välkommen'; $locale['step_welcome'] = 'Välkommen';

10
system/migrations/51.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
$up = function () use ($db) {
$db->modifyColumn(TABLE_PREFIX . 'config', 'name', "varchar(255) NOT NULL");
$db->modifyColumn(TABLE_PREFIX . 'config', 'value', "varchar(10000) NOT NULL");
};
$down = function () {
// nothing to do, to not lose data
};

13
system/migrations/52.php Normal file
View File

@@ -0,0 +1,13 @@
<?php
/**
* 2026-04-12
* Add indexes to myaac_account_actions table
*/
$up = function () use ($db) {
$db->query("CREATE INDEX `myaac_account_actions_account_id` ON `myaac_account_actions` (`account_id`);");
$db->query("CREATE INDEX `myaac_account_actions_ip` ON `myaac_account_actions` (`ip`);");
};
$down = function () {
// nothing to do, to not lose data
};

View File

@@ -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;

View File

@@ -39,7 +39,7 @@ class GiveAdminCommand extends Command
} }
if (!$account->isLoaded()) { if (!$account->isLoaded()) {
$io->error('Cannot find account mit supplied parameter: ' . $accountParam); $io->error('Cannot find account with supplied parameter: ' . $accountParam);
return self::FAILURE; return self::FAILURE;
} }

View File

@@ -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;

View File

@@ -18,6 +18,15 @@ class Account extends Model {
public $timestamps = false; public $timestamps = false;
protected $fillable = [
'name', 'number', 'email', 'password',
'key', 'created', 'rlname', 'location', 'country',
'web_lastlogin', 'web_flags',
'email_new', 'email_new_time', 'email_code',
'premium_points', 'coins', 'coins_transferable',
'premium_ends_at', 'premend', 'lastday', 'premdays',
];
protected $casts = [ protected $casts = [
'lastday' => 'integer', 'lastday' => 'integer',
'premdays' => 'integer', 'premdays' => 'integer',

View File

@@ -1,15 +0,0 @@
<?php
namespace MyAAC\Models;
use Illuminate\Database\Eloquent\Model;
class BugTracker extends Model {
protected $table = TABLE_PREFIX . 'bugtracker';
public $timestamps = false;
protected $fillable = ['account', 'type', 'status', 'text', 'id', 'subject', 'reply', 'who', 'uid', 'tag'];
}

View File

@@ -7,9 +7,11 @@ use MyAAC\Cache\Cache;
use MyAAC\Models\Menu; use MyAAC\Models\Menu;
class Plugins { class Plugins {
private static $warnings = []; private static array $warnings = [];
private static $error = null; private static string $error = '';
private static $plugin_json = []; private static array $plugin_json = [];
const DEFAULT_PRIORITY = 1000;
public static function getInits() public static function getInits()
{ {
@@ -20,13 +22,31 @@ class Plugins {
continue; continue;
} }
$initPriority = self::DEFAULT_PRIORITY;
if (isset($plugin['autoload']['init-priority'])) {
$initPriority = (int) $plugin['autoload']['init-priority'];
}
$pluginInits = glob(PLUGINS . $plugin['filename'] . '/init.php'); $pluginInits = glob(PLUGINS . $plugin['filename'] . '/init.php');
foreach ($pluginInits as $path) { foreach ($pluginInits as $path) {
$inits[] = $path; $inits[] = [
'file' => $path,
'priority' => $initPriority
];
} }
} }
return $inits; usort($inits, function ($a, $b)
{
return $a['priority'] <=> $b['priority'];
});
$ret = [];
foreach ($inits as $init) {
$ret[] = $init['file'];
}
return $ret;
}); });
} }
@@ -39,7 +59,7 @@ class Plugins {
continue; continue;
} }
$adminPagesDefaultPriority = 1000; $adminPagesDefaultPriority = self::DEFAULT_PRIORITY;
if (isset($plugin['admin-pages-default-priority'])) { if (isset($plugin['admin-pages-default-priority'])) {
$adminPagesDefaultPriority = $plugin['admin-pages-default-priority']; $adminPagesDefaultPriority = $plugin['admin-pages-default-priority'];
} }
@@ -117,7 +137,7 @@ class Plugins {
$routes = []; $routes = [];
foreach(self::getAllPluginsJson() as $plugin) { foreach(self::getAllPluginsJson() as $plugin) {
$routesDefaultPriority = 1000; $routesDefaultPriority = self::DEFAULT_PRIORITY;
if (isset($plugin['routes-default-priority'])) { if (isset($plugin['routes-default-priority'])) {
$routesDefaultPriority = $plugin['routes-default-priority']; $routesDefaultPriority = $plugin['routes-default-priority'];
} }
@@ -165,7 +185,7 @@ class Plugins {
} }
} }
$pagesDefaultPriority = 1000; $pagesDefaultPriority = self::DEFAULT_PRIORITY;
if (isset($plugin['pages-default-priority'])) { if (isset($plugin['pages-default-priority'])) {
$pagesDefaultPriority = $plugin['pages-default-priority']; $pagesDefaultPriority = $plugin['pages-default-priority'];
} }
@@ -318,7 +338,7 @@ class Plugins {
foreach(self::getAllPluginsJson() as $plugin) { foreach(self::getAllPluginsJson() as $plugin) {
if (isset($plugin['hooks'])) { if (isset($plugin['hooks'])) {
foreach ($plugin['hooks'] as $_name => $info) { foreach ($plugin['hooks'] as $_name => $info) {
$priority = 1000; $priority = self::DEFAULT_PRIORITY;
if (str_contains($info['type'], 'HOOK_')) { if (str_contains($info['type'], 'HOOK_')) {
$info['type'] = str_replace('HOOK_', '', $info['type']); $info['type'] = str_replace('HOOK_', '', $info['type']);
@@ -432,7 +452,7 @@ class Plugins {
return $plugins; return $plugins;
} }
public static function getPluginSettings($filename) public static function getPluginSettings($filename): mixed
{ {
$plugin_json = self::getPluginJson($filename); $plugin_json = self::getPluginJson($filename);
if (!$plugin_json) { if (!$plugin_json) {
@@ -868,6 +888,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;
} }
@@ -892,15 +917,15 @@ class Plugins {
return Semver::satisfies($plugin_info['version'], $version); return Semver::satisfies($plugin_info['version'], $version);
} }
public static function getWarnings() { public static function getWarnings(): array {
return self::$warnings; return self::$warnings;
} }
public static function clearWarnings() { public static function clearWarnings(): void {
self::$warnings = []; self::$warnings = [];
} }
public static function getError() { public static function getError(): string {
return self::$error; return self::$error;
} }
@@ -911,7 +936,7 @@ class Plugins {
* @param string $templateName * @param string $templateName
* @param array $menus * @param array $menus
*/ */
public static function installMenus($templateName, $menus, $clearOld = false) public static function installMenus($templateName, $menus, $clearOld = false): void
{ {
global $db; global $db;
@@ -962,7 +987,7 @@ class Plugins {
} }
} }
private static function getAutoLoadOption(array $plugin, string $optionName, bool $default = true) private static function getAutoLoadOption(array $plugin, string $optionName, bool $default = true): bool
{ {
if (isset($plugin['autoload'])) { if (isset($plugin['autoload'])) {
$autoload = $plugin['autoload']; $autoload = $plugin['autoload'];

View File

@@ -367,6 +367,7 @@ class Settings implements \ArrayAccess
</div> </div>
<div class="box-footer"> <div class="box-footer">
<button name="save" type="submit" class="btn btn-primary">Save</button> <button name="save" type="submit" class="btn btn-primary">Save</button>
<button form="reset-settings-form" name="reset" type="submit" class="btn btn-warning position-absolute" style="right: 0; bottom: 0" onclick="return confirm('Are you sure? This will clear all settings for this plugin!')">Reset</button>
</div> </div>
<?php <?php

View File

@@ -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;
} }

View File

@@ -9,7 +9,10 @@
<div class="box"> <div class="box">
<div class="box-body"> <div class="box-body">
<button name="save" type="submit" class="btn btn-primary">Save</button> <button name="save" type="submit" class="btn btn-primary">Save</button>
<button form="reset-settings-form" name="reset" type="submit" class="btn btn-warning position-absolute" style="right: 0; top: 0" onclick="return confirm('Are you sure? This will clear all settings for this plugin!')">Reset</button>
</div> </div>
<br/> <br/>
{{ settingsParsed|raw }} {{ settingsParsed|raw }}
</div> </div>
@@ -18,6 +21,12 @@
</form> </form>
</div> </div>
</div> </div>
<form id="reset-settings-form" method="post" action="{{ constant('ADMIN_URL') }}?p=settings&plugin={{ pluginName }}">
{{ csrf() }}
<input type="hidden" name="reset" value="1">
</form>
<style> <style>
.setting-default { .setting-default {
white-space: pre-wrap; white-space: pre-wrap;
@@ -95,12 +104,12 @@
.on('change input', function(){ .on('change input', function(){
const disable = $(this).serialize() === $(this).data('serialized'); const disable = $(this).serialize() === $(this).data('serialized');
$(this) $(this)
.find('input:submit, button:submit') .find('button[name="save"]')
.prop('disabled', disable) .prop('disabled', disable)
.prop('title', disable ? noChangesText : '') .prop('title', disable ? noChangesText : '')
; ;
}) })
.find('input:submit, button:submit') .find('button[name="save"]')
.prop('disabled', true) .prop('disabled', true)
.prop('title', noChangesText) .prop('title', noChangesText)
; ;
@@ -123,7 +132,7 @@
let $settings = $('#settings'); let $settings = $('#settings');
$settings.data('serialized', $settings.serialize()); $settings.data('serialized', $settings.serialize());
$settings $settings
.find('input:submit, button:submit') .find('button[name="save"]')
.prop('disabled', true) .prop('disabled', true)
.prop('title', noChangesText); .prop('title', noChangesText);
}, },

View File

@@ -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'];