mirror of
https://github.com/slawkens/myaac.git
synced 2025-09-14 20:43:34 +02:00
Compare commits
8 Commits
feature/ac
...
v1.3.1
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ff1723b756 | ||
![]() |
1a5771ad51 | ||
![]() |
6fac883659 | ||
![]() |
4a6896b446 | ||
![]() |
0852fba6f0 | ||
![]() |
9239a4f419 | ||
![]() |
00fe1adc15 | ||
![]() |
c2f55791c0 |
20
CHANGELOG.md
20
CHANGELOG.md
@@ -1,5 +1,25 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.3.1 - 19.03.2025]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* Fixed migrate:run command (https://github.com/slawkens/myaac/commit/1a5771ad51e595fe13368a0721b059c4ecefb17d)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* Small adjustments (https://github.com/slawkens/myaac/commit/6fac883659f581baac1361826d046410156f1e58, https://github.com/slawkens/myaac/commit/4a6896b4469968b9904292734cf6c14ba5eeef14)
|
||||||
|
|
||||||
|
## [1.3 - 10.03.2025]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* Use latest outfit-images host from @gesior (https://github.com/slawkens/myaac/commit/529bdcf016dd0f9dffbc34d81f99a046a9ddb70d)
|
||||||
|
* Change monster link to $_GET ?name= (https://github.com/slawkens/myaac/commit/4c5cc8b573b2b3e7ec00a22b7ede30a68083a924)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* Fixed house links (https://github.com/slawkens/myaac/commit/887b5068ad11c4cdab614afd34525caba785ce13)
|
||||||
|
* Fixed long title on headline.php (https://github.com/slawkens/myaac/commit/3e3f4bb5a514158ec8777684ca6c7f1c2a37bed5)
|
||||||
|
* Fixed menu colors once again, plus add !important tag (https://github.com/slawkens/myaac/commit/aa52df6e2ec92cafc25b655ae907bf2e1746d9cc)
|
||||||
|
* Fix: add possibility to remove all menu items in admin panel (https://github.com/slawkens/myaac/commit/00fe1adc15ea7646596d755f6e6e1f7854ffc1d5, https://github.com/slawkens/myaac/commit/9239a4f4198c3ad260802ac3b47e9c41b80b754e)
|
||||||
|
|
||||||
## [1.2 - 09.02.2025]
|
## [1.2 - 09.02.2025]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use MyAAC\Models\Account as AccountModel;
|
use MyAAC\Models\Account as AccountModel;
|
||||||
use MyAAC\Models\AccountAction;
|
|
||||||
use MyAAC\Models\Player;
|
use MyAAC\Models\Player;
|
||||||
|
|
||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
@@ -467,8 +466,9 @@ else if (isset($_REQUEST['search'])) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$accountActions = AccountAction::where('account_id', $account->getId())->orderByDesc('date')->get();
|
$accountActions = \MyAAC\Models\AccountAction::where('account_id', $account->getId())->orderByDesc('date')->get();
|
||||||
foreach ($accountActions as $i => $log):
|
foreach ($accountActions as $i => $log):
|
||||||
|
$log->ip = ($log->ip != 0 ? long2ip($log->ip) : inet_ntop($log->ipv6));
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $i + 1; ?></td>
|
<td><?php echo $i + 1; ?></td>
|
||||||
|
@@ -27,11 +27,11 @@ $pluginThemes = Plugins::getThemes();
|
|||||||
if (isset($_POST['template'])) {
|
if (isset($_POST['template'])) {
|
||||||
$template = $_POST['template'];
|
$template = $_POST['template'];
|
||||||
|
|
||||||
if (isset($_POST['menu'])) {
|
if (isset($_POST['save'])) {
|
||||||
$post_menu = $_POST['menu'];
|
$post_menu = $_POST['menu'] ?? [];
|
||||||
$post_menu_link = $_POST['menu_link'];
|
$post_menu_link = $_POST['menu_link'] ?? [];
|
||||||
$post_menu_blank = $_POST['menu_blank'];
|
$post_menu_blank = $_POST['menu_blank'] ?? [];
|
||||||
$post_menu_color = $_POST['menu_color'];
|
$post_menu_color = $_POST['menu_color'] ?? [];
|
||||||
if (count($post_menu) != count($post_menu_link)) {
|
if (count($post_menu) != count($post_menu_link)) {
|
||||||
echo 'Menu count is not equal menu links. Something went wrong when sending form.';
|
echo 'Menu count is not equal menu links. Something went wrong when sending form.';
|
||||||
return;
|
return;
|
||||||
@@ -135,7 +135,7 @@ if (isset($_POST['template'])) {
|
|||||||
<form method="post" id="menus-form" action="?p=menus">
|
<form method="post" id="menus-form" action="?p=menus">
|
||||||
<?php csrf(); ?>
|
<?php csrf(); ?>
|
||||||
<input type="hidden" name="template" value="<?php echo $template ?>"/>
|
<input type="hidden" name="template" value="<?php echo $template ?>"/>
|
||||||
<button type="submit" class="btn btn-info">Save</button><br/><br/>
|
<button type="submit" name="save" class="btn btn-info">Save</button><br/><br/>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<?php foreach ($config['menu_categories'] as $id => $cat): ?>
|
<?php foreach ($config['menu_categories'] as $id => $cat): ?>
|
||||||
<div class="col-md-12 col-lg-6">
|
<div class="col-md-12 col-lg-6">
|
||||||
@@ -168,7 +168,7 @@ if (isset($_POST['template'])) {
|
|||||||
</div>
|
</div>
|
||||||
<div class="row pb-2">
|
<div class="row pb-2">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<button type="submit" class="btn btn-info">Save</button>
|
<button type="submit" name="save" class="btn btn-info">Save</button>
|
||||||
<?php
|
<?php
|
||||||
echo '<button type="button" class="btn btn-danger float-right" value="Cancel" onclick="window.location = \'' . ADMIN_URL . '?p=menus\';"><i class="fas fa-cancel"></i> Cancel</button>';
|
echo '<button type="button" class="btn btn-danger float-right" value="Cancel" onclick="window.location = \'' . ADMIN_URL . '?p=menus\';"><i class="fas fa-cancel"></i> Cancel</button>';
|
||||||
?>
|
?>
|
||||||
|
@@ -26,8 +26,8 @@
|
|||||||
if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is required.');
|
if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is required.');
|
||||||
|
|
||||||
const MYAAC = true;
|
const MYAAC = true;
|
||||||
const MYAAC_VERSION = '1.2';
|
const MYAAC_VERSION = '1.3.1';
|
||||||
const DATABASE_VERSION = 44;
|
const DATABASE_VERSION = 43;
|
||||||
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'));
|
||||||
|
@@ -2,12 +2,12 @@ SET @myaac_database_version = 43;
|
|||||||
|
|
||||||
CREATE TABLE `myaac_account_actions`
|
CREATE TABLE `myaac_account_actions`
|
||||||
(
|
(
|
||||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`account_id` INT(11) NOT NULL,
|
`account_id` INT(11) NOT NULL,
|
||||||
`ip` VARCHAR(45) NOT NULL DEFAULT '',
|
`ip` INT(10) UNSIGNED NOT NULL DEFAULT 0,
|
||||||
|
`ipv6` BINARY(16) NOT NULL DEFAULT 0,
|
||||||
`date` INT(11) NOT NULL DEFAULT 0,
|
`date` INT(11) NOT NULL DEFAULT 0,
|
||||||
`action` VARCHAR(255) NOT NULL DEFAULT '',
|
`action` VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
PRIMARY KEY (`id`)
|
KEY (`account_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;
|
||||||
|
|
||||||
CREATE TABLE `myaac_admin_menu`
|
CREATE TABLE `myaac_admin_menu`
|
||||||
|
@@ -12,8 +12,6 @@
|
|||||||
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3
|
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use MyAAC\Models\AccountAction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OTServ account abstraction.
|
* OTServ account abstraction.
|
||||||
*
|
*
|
||||||
@@ -445,19 +443,19 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
|||||||
throw new E_OTS_NotLoaded();
|
throw new E_OTS_NotLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$configFreePremium = configLua('freePremium');
|
||||||
|
if(isset($configFreePremium) && getBoolean($configFreePremium)) {return -1;}
|
||||||
|
|
||||||
if(isset($this->data['premium_ends_at']) || isset($this->data['premend'])) {
|
if(isset($this->data['premium_ends_at']) || isset($this->data['premend'])) {
|
||||||
$col = isset($this->data['premium_ends_at']) ? 'premium_ends_at' : 'premend';
|
$col = isset($this->data['premium_ends_at']) ? 'premium_ends_at' : 'premend';
|
||||||
$ret = ceil(($this->data[$col] - time()) / (24 * 60 * 60));
|
$ret = ceil(($this->data[$col] - time()) / (24 * 60 * 60));
|
||||||
return $ret > 0 ? $ret : 0;
|
return max($ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->data['premdays'] == 0) {
|
if($this->data['premdays'] == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
global $config;
|
|
||||||
if(isset($config['lua']['freePremium']) && getBoolean($config['lua']['freePremium'])) return -1;
|
|
||||||
|
|
||||||
if($this->data['premdays'] == self::GRATIS_PREMIUM_DAYS){
|
if($this->data['premdays'] == self::GRATIS_PREMIUM_DAYS){
|
||||||
return self::GRATIS_PREMIUM_DAYS;
|
return self::GRATIS_PREMIUM_DAYS;
|
||||||
}
|
}
|
||||||
@@ -1012,16 +1010,26 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
|||||||
|
|
||||||
public function logAction($action)
|
public function logAction($action)
|
||||||
{
|
{
|
||||||
AccountAction::create([
|
$ip = get_browser_real_ip();
|
||||||
'account_id' => $this->getId(),
|
if(!str_contains($ip, ":")) {
|
||||||
'ip' => get_browser_real_ip(),
|
$ipv6 = '0';
|
||||||
'date' => time(),
|
}
|
||||||
'action' => $action,
|
else {
|
||||||
]);
|
$ipv6 = $ip;
|
||||||
|
$ip = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->db->exec('INSERT INTO `' . TABLE_PREFIX . 'account_actions` (`account_id`, `ip`, `ipv6`, `date`, `action`) VALUES (' . $this->db->quote($this->getId()).', ' . ($ip == '' ? '0' : $this->db->quote(ip2long($ip))) . ', (' . ($ipv6 == '0' ? $this->db->quote('') : $this->db->quote(inet_pton($ipv6))) . '), UNIX_TIMESTAMP(NOW()), ' . $this->db->quote($action).')');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getActionsLog($limit) {
|
public function getActionsLog($limit1, $limit2)
|
||||||
return AccountAction::where('account_id', $this->data['id'])->orderByDesc('date')->limit($limit)->get()->toArray();
|
{
|
||||||
|
$actions = array();
|
||||||
|
|
||||||
|
foreach($this->db->query('SELECT `ip`, `ipv6`, `date`, `action` FROM `' . TABLE_PREFIX . 'account_actions` WHERE `account_id` = ' . $this->data['id'] . ' ORDER by `date` DESC LIMIT ' . $limit1 . ', ' . $limit2 . '')->fetchAll() as $a)
|
||||||
|
$actions[] = array('ip' => $a['ip'], 'ipv6' => $a['ipv6'], 'date' => $a['date'], 'action' => $a['action']);
|
||||||
|
|
||||||
|
return $actions;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns players iterator.
|
* Returns players iterator.
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* @var OTS_DB_MySQL $db
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 2025-02-27
|
|
||||||
// remove ipv6, change to ip (for both ipv4 + ipv6) as VARCHAR(45)
|
|
||||||
$up = function () use ($db) {
|
|
||||||
$db->query("ALTER TABLE `myaac_account_actions` DROP KEY `account_id`;");
|
|
||||||
$db->query("ALTER TABLE `myaac_account_actions` ADD COLUMN `id` INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`);");
|
|
||||||
|
|
||||||
$db->modifyColumn(TABLE_PREFIX . 'account_actions', 'ip', "VARCHAR(45) NOT NULL DEFAULT ''");
|
|
||||||
$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = INET_NTOA(`ip`) WHERE `ip` != '0';");
|
|
||||||
$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = INET6_NTOA(`ipv6`) WHERE `ip` = '0';");
|
|
||||||
$db->dropColumn(TABLE_PREFIX . 'account_actions', 'ipv6');
|
|
||||||
};
|
|
||||||
|
|
||||||
$down = function () use ($db) {
|
|
||||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "account_actions` DROP `id`;");
|
|
||||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "account_actions` ADD KEY (`account_id`);");
|
|
||||||
|
|
||||||
$db->addColumn(TABLE_PREFIX . 'account_actions', 'ipv6', "BINARY(16) NOT NULL DEFAULT 0x00000000000000000000000000000000 AFTER ip");
|
|
||||||
$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ipv6` = INET6_ATON(ip) WHERE NOT IS_IPV4(`ip`);");
|
|
||||||
$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = INET_ATON(`ip`) WHERE IS_IPV4(`ip`);");
|
|
||||||
$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = 0 WHERE `ipv6` != 0x00000000000000000000000000000000;");
|
|
||||||
$db->modifyColumn(TABLE_PREFIX . 'account_actions', 'ip', "INT(11) UNSIGNED NOT NULL DEFAULT 0;");
|
|
||||||
};
|
|
@@ -85,8 +85,12 @@ if($email_new_time > 1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions = $account_logged->getActionsLog(1000);
|
$actions = array();
|
||||||
|
foreach($account_logged->getActionsLog(0, 1000) as $action) {
|
||||||
|
$actions[] = array('action' => $action['action'], 'date' => $action['date'], 'ip' => $action['ip'] != 0 ? long2ip($action['ip']) : inet_ntop($action['ipv6']));
|
||||||
|
}
|
||||||
|
|
||||||
|
$players = array();
|
||||||
/** @var OTS_Players_List $account_players */
|
/** @var OTS_Players_List $account_players */
|
||||||
$account_players = $account_logged->getPlayersList();
|
$account_players = $account_logged->getPlayersList();
|
||||||
$account_players->orderBy('id');
|
$account_players->orderBy('id');
|
||||||
|
@@ -100,7 +100,7 @@ function getColorByPercent($percent)
|
|||||||
|
|
||||||
if(!$logged)
|
if(!$logged)
|
||||||
{
|
{
|
||||||
echo 'You are not logged in. <a href="?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic=polls') . '">Log in</a> to vote in polls.<br /><br />';
|
echo 'You are not logged in. <a href="' . getLink('account/manage') . '?redirect=' . BASE_URL . urlencode('?subtopic=polls') . '">Log in</a> to vote in polls.<br /><br />';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@ namespace MyAAC\Commands;
|
|||||||
|
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
@@ -16,7 +17,8 @@ class MigrateRunCommand extends Command
|
|||||||
->addArgument('id',
|
->addArgument('id',
|
||||||
InputArgument::IS_ARRAY | InputArgument::REQUIRED,
|
InputArgument::IS_ARRAY | InputArgument::REQUIRED,
|
||||||
'Id or ids of migration(s)'
|
'Id or ids of migration(s)'
|
||||||
);
|
)
|
||||||
|
->addOption('down', 'd', InputOption::VALUE_NONE, 'Down');;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
@@ -41,8 +43,10 @@ class MigrateRunCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$down = $input->getOption('down') ?? false;
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$this->executeMigration($id, $io);
|
$this->executeMigration($id, $io, !$down);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
@@ -52,13 +56,24 @@ class MigrateRunCommand extends Command
|
|||||||
return file_exists(SYSTEM . 'migrations/' . $id . '.php');
|
return file_exists(SYSTEM . 'migrations/' . $id . '.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function executeMigration($id, $io): void
|
private function executeMigration($id, $io, $_up = true): void
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$db->revalidateCache();
|
$db->revalidateCache();
|
||||||
|
|
||||||
require SYSTEM . 'migrations/' . $id . '.php';
|
require SYSTEM . 'migrations/' . $id . '.php';
|
||||||
$io->success('Migration ' . $id . ' successfully executed');
|
if ($_up) {
|
||||||
|
if (isset($up)) {
|
||||||
|
$up();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (isset($down)) {
|
||||||
|
$down();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$io->success('Migration ' . $id . ' successfully executed' . ($_up ? '' : ' (downgrade)'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,6 @@ class AccountAction extends Model {
|
|||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
protected $fillable = ['account_id', 'ip', 'date', 'action'];
|
protected $fillable = ['account_id', 'ip', 'ipv6', 'date', 'action'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -114,7 +114,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<b>Before you can create a guild you must login.</b>
|
<b>Before you can create a guild you must login.</b>
|
||||||
<br/>
|
<br/>
|
||||||
<form action="?subtopic=accountmanagement&redirect={{ getLink('guilds') }}" method="post">
|
<form action="{{ getLink('account/manage') }}?redirect={{ getLink('guilds') }}" method="post">
|
||||||
{{ csrf() }}
|
{{ csrf() }}
|
||||||
{% include('buttons.login.html.twig') %}
|
{% include('buttons.login.html.twig') %}
|
||||||
</form>
|
</form>
|
||||||
|
@@ -215,7 +215,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
{% if not logged %}
|
{% if not logged %}
|
||||||
<form action="?subtopic=accountmanagement&redirect={{ getGuildLink(guild_name|url_encode, false) }}" method="post">
|
<form action="{{ getLink('account/manage') }}?redirect={{ getGuildLink(guild_name|url_encode, false) }}" method="post">
|
||||||
{{ csrf() }}
|
{{ csrf() }}
|
||||||
<td>
|
<td>
|
||||||
{{ include('buttons.login.html.twig') }}
|
{{ include('buttons.login.html.twig') }}
|
||||||
|
Reference in New Issue
Block a user