mirror of
https://github.com/slawkens/myaac.git
synced 2026-04-26 20:33:31 +02:00
Compare commits
29 Commits
feature/da
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
925cbfbc95 | ||
|
|
81b8bd8a2c | ||
|
|
def432d4b7 | ||
|
|
b0edbb79d9 | ||
|
|
04d630d765 | ||
|
|
7851e337eb | ||
|
|
ba1ee4bdb7 | ||
|
|
e61c40d6b3 | ||
|
|
54bdea85a3 | ||
|
|
48284e426f | ||
|
|
ac9a328206 | ||
|
|
0635108d4c | ||
|
|
47ec36a176 | ||
|
|
e4a947cabb | ||
|
|
609cf152af | ||
|
|
c16f95f8d2 | ||
|
|
ec7079dd57 | ||
|
|
9e0e2601d2 | ||
|
|
e7198aeb23 | ||
|
|
1fa3630f86 | ||
|
|
e274b83504 | ||
|
|
a467a540b1 | ||
|
|
08507e2940 | ||
|
|
f1aa128408 | ||
|
|
7104c2258f | ||
|
|
f51211d47a | ||
|
|
fa93187f80 | ||
|
|
2c62a97160 | ||
|
|
7bc8a66cc1 |
@@ -1,9 +1,12 @@
|
||||
## [2.0-dev - x.x.2025]
|
||||
|
||||
### Added
|
||||
* Add an "access" option to Menus (#340)
|
||||
* Menus: Add an "access" option to Menus (#340)
|
||||
* 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
|
||||
* Better handling of vocations: (#345)
|
||||
@@ -11,6 +14,7 @@
|
||||
* Support for Monk vocation
|
||||
* 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)
|
||||
* 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)
|
||||
|
||||
### Internal
|
||||
|
||||
@@ -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
|
||||
|
||||
## Project supported by JetBrains
|
||||
|
||||
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
|
||||
|
||||
[](https://www.jetbrains.com/?from=https://github.com/slawkens)
|
||||
|
||||
### License
|
||||
|
||||
This program and all associated files are released under the GNU Public License.
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
use MyAAC\Admin\Insights;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$getYear = (int)($_GET['year'] ?? date('Y'));
|
||||
$getMonth = $_GET['month'] ?? (int)date('M') + 1;
|
||||
|
||||
$insights = new Insights($db);
|
||||
|
||||
$twig->display('insights.html.twig', [
|
||||
'lastLoginPlayers' => $insights->getLastLoggedPlayers($getYear, $getMonth),
|
||||
'lastCreatedAccounts' => $insights->getLastCreatedAccounts($getYear, $getMonth),
|
||||
|
||||
'firstYear' => $insights->getFirstYear(),
|
||||
|
||||
'getYear' => $getYear,
|
||||
'getMonth' => $getMonth,
|
||||
|
||||
'months' => $insights->getMonths(),
|
||||
]);
|
||||
@@ -1,99 +0,0 @@
|
||||
{% set currentYear = 'now' | date('Y') %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<div class="col-sm-3 col-md-6 col-lg-12">
|
||||
<div class="card card-info card-outline">
|
||||
<div class="card-header">
|
||||
<h5 class="m-0">Insights</h5>
|
||||
</div>
|
||||
|
||||
<div class="card-body p-3 row">
|
||||
<div class="col-md-6 col-sm-3">
|
||||
<label for="month">Month:</label>
|
||||
<select class="form-control" id="month" name="month">
|
||||
{% for id, name in months %}
|
||||
<option value="{{ id }}" {{ getMonth == id ? 'selected="selected"' : '' }}>{{ name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 col-sm-3">
|
||||
<label for="year">Year:</label>
|
||||
<select class="form-control" id="year" name="year">
|
||||
{% for year in range(firstYear, currentYear) %}
|
||||
<option value="{{ year }}" {{ getYear == year ? 'selected' : '' }}>{{ year }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body p-3 row">
|
||||
<div class="col-6 col-md-6">
|
||||
<div class="chart">
|
||||
<canvas id="lastLoginsChart" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-6">
|
||||
<div class="chart">
|
||||
<canvas id="lastCreatedChart" style="min-height: 250px; height: 250px; max-height: 250px; max-width: 100%;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
$('#year').on('change', function() {
|
||||
window.location.href = "?p=dashboard&year=" + $(this).val() + "&month={{ getMonth }}";
|
||||
});
|
||||
|
||||
$('#month').on('change', function() {
|
||||
window.location.href = "?p=dashboard&year={{ getYear }}" + "&month=" + $(this).val();
|
||||
});
|
||||
});
|
||||
|
||||
const config = {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: [
|
||||
{% for player in lastLoginPlayers %}
|
||||
"{{ player.date }}",
|
||||
{% endfor %}
|
||||
],
|
||||
datasets: [
|
||||
{
|
||||
label: "Logged players",
|
||||
backgroundColor: ["#3e95cd", "#8e5ea2", "#3cba9f", "#e8c3b9", "#c45850"],
|
||||
data: [
|
||||
{% for player in lastLoginPlayers %}
|
||||
{{ player.how_much }},
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
const myChart = new Chart(document.getElementById('lastLoginsChart'), config);
|
||||
|
||||
const config2 = {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: [
|
||||
{% for account in lastCreatedAccounts %}
|
||||
"{{ account.date }}",
|
||||
{% endfor %}
|
||||
],
|
||||
datasets: [
|
||||
{
|
||||
label: "Accounts created",
|
||||
backgroundColor: ["#3e95cd", "#8e5ea2", "#3cba9f", "#e8c3b9", "#c45850"],
|
||||
data: [
|
||||
{% for account in lastCreatedAccounts %}
|
||||
{{ account.how_much }},
|
||||
{% endfor %}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
const myChart2 = new Chart(document.getElementById('lastCreatedChart'), config2);
|
||||
</script>
|
||||
@@ -46,6 +46,15 @@ if (!is_array($settingsFile)) {
|
||||
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']);
|
||||
|
||||
$title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $settingsFile['name']);
|
||||
@@ -57,4 +66,5 @@ $twig->display('admin.settings.html.twig', [
|
||||
'settings' => $settingsFile['settings'],
|
||||
'script' => $settingsParsed['script'],
|
||||
'settingsKeyName' => $settingsKeyName,
|
||||
'pluginName' => $plugin,
|
||||
]);
|
||||
|
||||
@@ -27,7 +27,7 @@ if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is
|
||||
|
||||
const MYAAC = true;
|
||||
const MYAAC_VERSION = '2.0-dev';
|
||||
const DATABASE_VERSION = 50;
|
||||
const DATABASE_VERSION = 52;
|
||||
const TABLE_PREFIX = 'myaac_';
|
||||
define('START_TIME', microtime(true));
|
||||
define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX'));
|
||||
|
||||
@@ -5,7 +5,9 @@ CREATE TABLE IF NOT EXISTS `myaac_account_actions`
|
||||
`ip` varchar(45) NOT NULL DEFAULT '',
|
||||
`date` int NOT NULL DEFAULT 0,
|
||||
`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;
|
||||
|
||||
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`
|
||||
(
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(30) NOT NULL,
|
||||
`value` varchar(1000) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`value` varchar(10000) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;
|
||||
|
||||
@@ -30,9 +30,6 @@ parameters:
|
||||
# Eloquent models
|
||||
- '#Call to an undefined method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+\(\)#'
|
||||
- '#Call to an undefined static method [a-zA-Z0-9\\_]+::[a-zA-Z0-9\\_]+\(\)#'
|
||||
# system/pages/highscores.php
|
||||
- '#Access to an undefined property Illuminate\\Database\\Eloquent\\Model::\$online_status#'
|
||||
- '#Access to an undefined property Illuminate\\Database\\Eloquent\\Model::\$vocation_name#'
|
||||
-
|
||||
message: '#Variable \$tmp in empty\(\) always exists and is always falsy#'
|
||||
path: templates\kathrine\javascript.php
|
||||
|
||||
@@ -372,8 +372,8 @@ class POT
|
||||
|
||||
global $debugBar;
|
||||
if (isset($debugBar)) {
|
||||
$this->db = new DebugBar\DataCollector\PDO\TraceablePDO(new OTS_DB_MySQL($params));
|
||||
$debugBar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($this->db));
|
||||
$this->db = new \MyAAC\Debug\TraceablePDOWithBacktrace(new OTS_DB_MySQL($params));
|
||||
$debugBar->addCollector(new \MyAAC\Debug\PDOCollectorWithBacktrace($this->db));
|
||||
}
|
||||
else {
|
||||
$this->db = new OTS_DB_MySQL($params);
|
||||
|
||||
10
system/migrations/51.php
Normal file
10
system/migrations/51.php
Normal 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
13
system/migrations/52.php
Normal 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
|
||||
};
|
||||
@@ -47,7 +47,6 @@ if(isset($_REQUEST['name']))
|
||||
|
||||
if(empty($name))
|
||||
{
|
||||
$tmp_link = getPlayerLink($name);
|
||||
echo 'Here you can get detailed information about a certain player on ' . $config['lua']['serverName'] . '.<br/>';
|
||||
echo generate_search_form(true);
|
||||
return;
|
||||
|
||||
@@ -207,10 +207,14 @@ if (empty($highscores)) {
|
||||
}
|
||||
|
||||
$highscores = $query->get()->map(function($row) {
|
||||
/**
|
||||
* @var Player $row
|
||||
*/
|
||||
$tmp = $row->toArray();
|
||||
$tmp['online'] = $row->online_status;
|
||||
$tmp['vocation'] = $row->vocation_name;
|
||||
$tmp['outfit_url'] = $row->outfit_url; // @phpstan-ignore-line
|
||||
$tmp['outfit_url'] = $row->outfit_url;
|
||||
$tmp['link'] = getPlayerLink($row->name, false);
|
||||
unset($tmp['online_table']);
|
||||
|
||||
return $tmp;
|
||||
@@ -244,7 +248,6 @@ foreach($highscores as $id => &$player)
|
||||
$player['experience'] = number_format($player['experience']);
|
||||
}
|
||||
|
||||
$player['link'] = getPlayerLink($player['name'], false);
|
||||
$player['flag'] = getFlagImage($player['country']);
|
||||
$player['outfit'] = '<img style="position:absolute;margin-top:-50px;margin-left:-30px" src="' . $player['outfit_url'] . '" alt="" />';
|
||||
|
||||
|
||||
@@ -108,8 +108,9 @@ $title = 'Latest News';
|
||||
$cache = Cache::getInstance();
|
||||
|
||||
$news_cached = false;
|
||||
if($cache->enabled())
|
||||
if($cache->enabled() && !admin()) {
|
||||
$news_cached = News::getCached(NEWS);
|
||||
}
|
||||
|
||||
if(!$news_cached)
|
||||
{
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Admin;
|
||||
|
||||
use MyAAC\Cache\Cache;
|
||||
|
||||
class Insights
|
||||
{
|
||||
private $db;
|
||||
|
||||
public function __construct($db){
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
public function getLastLoggedPlayers(int $year, $month): array
|
||||
{
|
||||
return Cache::remember("admin_dashboard_insights_players_lastlogin_{$year}_{$month}", 5 * 60, function() use ($year, $month) {
|
||||
$lastLoggedPlayers = [];
|
||||
|
||||
$getFromTo = $this->getFromTo($year, $month);
|
||||
$whereLastLogin = 'AND lastlogin >= ' . $getFromTo[0] . ' AND lastlogin <= ' . $getFromTo[1];
|
||||
|
||||
if ($month === 'all') {
|
||||
$query = $this->db->query('SELECT count(id) as how_much, DATE_FORMAT(FROM_UNIXTIME(lastlogin), "%m.%Y") as lastdate FROM players WHERE lastlogin > 0 ' . $whereLastLogin . ' GROUP BY lastdate LIMIT 14');
|
||||
|
||||
foreach ($query as $item) {
|
||||
$date = explode('.', $item['lastdate']);
|
||||
$monthName = date('F', mktime(0, 0, 0, $date[0], 10));;
|
||||
|
||||
$lastLoggedPlayers[] = ['date' => $monthName, 'how_much' => $item['how_much']];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$query = $this->db->query('SELECT count(id) as how_much, DATE_FORMAT(FROM_UNIXTIME(lastlogin), "%d.%m.%Y") as lastdate FROM players WHERE lastlogin > 0 ' . $whereLastLogin . ' GROUP BY lastdate LIMIT 14');
|
||||
|
||||
foreach ($query as $item) {
|
||||
$lastLoggedPlayers[] = ['date' => $item['lastdate'], 'how_much' => $item['how_much']];
|
||||
}
|
||||
}
|
||||
|
||||
return $lastLoggedPlayers;
|
||||
});
|
||||
}
|
||||
|
||||
public function getLastCreatedAccounts(int $year, $month): array
|
||||
{
|
||||
return Cache::remember("admin_dashboard_insights_accounts_created_{$year}_{$month}", 10 * 60, function() use ($year, $month) {
|
||||
$lastCreatedAccounts = [];
|
||||
|
||||
$getFromTo = $this->getFromTo($year, $month);
|
||||
$whereCreated = 'AND created >= ' . $getFromTo[0] . ' AND created <= ' . $getFromTo[1];
|
||||
|
||||
if ($month == 'all') {
|
||||
$query = $this->db->query('SELECT count(id) as how_much, DATE_FORMAT(FROM_UNIXTIME(created), "%m.%Y") as createdDate FROM accounts WHERE created > 0 ' . $whereCreated . ' GROUP BY createdDate LIMIT 31');
|
||||
|
||||
foreach ($query as $item) {
|
||||
$date = explode('.', $item['createdDate']);
|
||||
$monthName = date('F', mktime(0, 0, 0, $date[0], 10));;
|
||||
$lastCreatedAccounts[] = ['date' => $monthName, 'how_much' => $item['how_much']];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$query = $this->db->query('SELECT count(id) as how_much, DATE_FORMAT(FROM_UNIXTIME(created), "%d.%m.%Y") as createdDate FROM accounts WHERE created > 0 ' . $whereCreated . ' GROUP BY createdDate LIMIT 31');
|
||||
|
||||
foreach ($query as $item) {
|
||||
$lastCreatedAccounts[] = ['date' => $item['createdDate'], 'how_much' => $item['how_much']];
|
||||
}
|
||||
}
|
||||
|
||||
return $lastCreatedAccounts;
|
||||
});
|
||||
}
|
||||
|
||||
public function getFirstYear(): int
|
||||
{
|
||||
$query = $this->db->query('SELECT created FROM accounts WHERE created > 0 ORDER BY created LIMIT 1');
|
||||
if ($query->rowCount()) {
|
||||
$firstAccountCreated = $query->fetch()['created'];
|
||||
}
|
||||
else {
|
||||
$firstAccountCreated = time();
|
||||
}
|
||||
|
||||
return (int)date('Y', $firstAccountCreated);
|
||||
}
|
||||
|
||||
public function getMonths(): array
|
||||
{
|
||||
$months = [];
|
||||
|
||||
$months['all'] = 'All';
|
||||
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$months[$i] = date('F', mktime(0, 0, 0, $i, 10));
|
||||
}
|
||||
|
||||
return $months;
|
||||
}
|
||||
|
||||
private function getFromTo(int $year, $month): array
|
||||
{
|
||||
if ($month == 'all') {
|
||||
$firstMonth = 1;
|
||||
$lastMonth = 12;
|
||||
}
|
||||
else {
|
||||
$firstMonth = $month;
|
||||
$lastMonth = $month;
|
||||
}
|
||||
|
||||
$from = date('U', mktime(0, 0, 0, $firstMonth, 1, $year));
|
||||
$to = date('U', mktime(0, 0, 0, $lastMonth, 31, $year));
|
||||
|
||||
return [$from, $to];
|
||||
}
|
||||
}
|
||||
52
system/src/Debug/PDOCollectorWithBacktrace.php
Normal file
52
system/src/Debug/PDOCollectorWithBacktrace.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Debug;
|
||||
|
||||
use DebugBar\DataCollector\PDO\PDOCollector;
|
||||
use DebugBar\DataCollector\PDO\TraceablePDO;
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
|
||||
class PDOCollectorWithBacktrace extends PDOCollector
|
||||
{
|
||||
protected function collectPDO(TraceablePDO $pdo, ?TimeDataCollector $timeCollector = null, $connectionName = null): array
|
||||
{
|
||||
$data = parent::collectPDO($pdo, $timeCollector, $connectionName);
|
||||
|
||||
if ($pdo instanceof TraceablePDOWithBacktrace) {
|
||||
$backtraces = $pdo->getBacktraces();
|
||||
foreach ($data['statements'] as $i => &$stmt) {
|
||||
if (isset($backtraces[$i])) {
|
||||
$stmt['backtrace'] = $this->formatBacktrace($backtraces[$i]);
|
||||
}
|
||||
}
|
||||
unset($stmt);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
private function formatBacktrace(array $backtrace): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($backtrace as $frame) {
|
||||
if (!isset($frame['file'], $frame['line'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str_contains($frame['file'], DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str_contains($frame['file'], DIRECTORY_SEPARATOR . 'Debug' . DIRECTORY_SEPARATOR)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$function = isset($frame['class'])
|
||||
? $frame['class'] . ($frame['type'] ?? '::') . ($frame['function'] ?? '')
|
||||
: ($frame['function'] ?? '');
|
||||
|
||||
$result[] = ($function ? $function . '() ' : '') . $frame['file'] . ':' . $frame['line'];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
26
system/src/Debug/TraceablePDOWithBacktrace.php
Normal file
26
system/src/Debug/TraceablePDOWithBacktrace.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Debug;
|
||||
|
||||
use DebugBar\DataCollector\PDO\TraceablePDO;
|
||||
use DebugBar\DataCollector\PDO\TracedStatement;
|
||||
|
||||
class TraceablePDOWithBacktrace extends TraceablePDO
|
||||
{
|
||||
/** @var array[] */
|
||||
protected array $backtraces = [];
|
||||
|
||||
public function addExecutedStatement(TracedStatement $stmt): void
|
||||
{
|
||||
$this->backtraces[] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
parent::addExecutedStatement($stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
*/
|
||||
public function getBacktraces(): array
|
||||
{
|
||||
return $this->backtraces;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,15 @@ class Account extends Model {
|
||||
|
||||
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 = [
|
||||
'lastday' => 'integer',
|
||||
'premdays' => 'integer',
|
||||
|
||||
@@ -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'];
|
||||
|
||||
}
|
||||
@@ -5,8 +5,10 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* @property string $name
|
||||
* @property int $level
|
||||
* @property int $vocation
|
||||
* @property int $promotion
|
||||
* @property int $online
|
||||
* @property int $looktype
|
||||
* @property int $lookhead
|
||||
@@ -14,6 +16,8 @@ use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
* @property int $looklegs
|
||||
* @property int $lookfeet
|
||||
* @property int $lookaddons
|
||||
* @property bool $online_status
|
||||
* @property string $vocation_name
|
||||
* @property string $outfit_url
|
||||
* @property hasOne $onlineTable
|
||||
*/
|
||||
|
||||
@@ -7,9 +7,11 @@ use MyAAC\Cache\Cache;
|
||||
use MyAAC\Models\Menu;
|
||||
|
||||
class Plugins {
|
||||
private static $warnings = [];
|
||||
private static $error = null;
|
||||
private static $plugin_json = [];
|
||||
private static array $warnings = [];
|
||||
private static string $error = '';
|
||||
private static array $plugin_json = [];
|
||||
|
||||
const DEFAULT_PRIORITY = 1000;
|
||||
|
||||
public static function getInits()
|
||||
{
|
||||
@@ -20,13 +22,31 @@ class Plugins {
|
||||
continue;
|
||||
}
|
||||
|
||||
$initPriority = self::DEFAULT_PRIORITY;
|
||||
if (isset($plugin['autoload']['init-priority'])) {
|
||||
$initPriority = (int) $plugin['autoload']['init-priority'];
|
||||
}
|
||||
|
||||
$pluginInits = glob(PLUGINS . $plugin['filename'] . '/init.php');
|
||||
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;
|
||||
}
|
||||
|
||||
$adminPagesDefaultPriority = 1000;
|
||||
$adminPagesDefaultPriority = self::DEFAULT_PRIORITY;
|
||||
if (isset($plugin['admin-pages-default-priority'])) {
|
||||
$adminPagesDefaultPriority = $plugin['admin-pages-default-priority'];
|
||||
}
|
||||
@@ -117,7 +137,7 @@ class Plugins {
|
||||
|
||||
$routes = [];
|
||||
foreach(self::getAllPluginsJson() as $plugin) {
|
||||
$routesDefaultPriority = 1000;
|
||||
$routesDefaultPriority = self::DEFAULT_PRIORITY;
|
||||
if (isset($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'])) {
|
||||
$pagesDefaultPriority = $plugin['pages-default-priority'];
|
||||
}
|
||||
@@ -318,7 +338,7 @@ class Plugins {
|
||||
foreach(self::getAllPluginsJson() as $plugin) {
|
||||
if (isset($plugin['hooks'])) {
|
||||
foreach ($plugin['hooks'] as $_name => $info) {
|
||||
$priority = 1000;
|
||||
$priority = self::DEFAULT_PRIORITY;
|
||||
|
||||
if (str_contains($info['type'], 'HOOK_')) {
|
||||
$info['type'] = str_replace('HOOK_', '', $info['type']);
|
||||
@@ -432,7 +452,7 @@ class Plugins {
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
public static function getPluginSettings($filename)
|
||||
public static function getPluginSettings($filename): mixed
|
||||
{
|
||||
$plugin_json = self::getPluginJson($filename);
|
||||
if (!$plugin_json) {
|
||||
@@ -870,7 +890,11 @@ class Plugins {
|
||||
|
||||
global $hooks;
|
||||
foreach($plugin_info['hooks'] ?? [] as $name => $info) {
|
||||
$hooks->unregister($name, $info['type'], $info['file']);
|
||||
if (str_contains($info['type'], 'HOOK_')) {
|
||||
$info['type'] = str_replace('HOOK_', '', $info['type']);
|
||||
}
|
||||
|
||||
$hooks->unregister($name, 'HOOK_' . $info['type'], $info['file']);
|
||||
}
|
||||
|
||||
clearCache();
|
||||
@@ -897,15 +921,15 @@ class Plugins {
|
||||
return Semver::satisfies($plugin_info['version'], $version);
|
||||
}
|
||||
|
||||
public static function getWarnings() {
|
||||
public static function getWarnings(): array {
|
||||
return self::$warnings;
|
||||
}
|
||||
|
||||
public static function clearWarnings() {
|
||||
public static function clearWarnings(): void {
|
||||
self::$warnings = [];
|
||||
}
|
||||
|
||||
public static function getError() {
|
||||
public static function getError(): string {
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
@@ -916,7 +940,7 @@ class Plugins {
|
||||
* @param string $templateName
|
||||
* @param array $menus
|
||||
*/
|
||||
public static function installMenus($templateName, $menus, $clearOld = false)
|
||||
public static function installMenus($templateName, $menus, $clearOld = false): void
|
||||
{
|
||||
global $db;
|
||||
|
||||
@@ -967,7 +991,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'])) {
|
||||
$autoload = $plugin['autoload'];
|
||||
|
||||
@@ -367,6 +367,7 @@ class Settings implements \ArrayAccess
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<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>
|
||||
<?php
|
||||
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
<div class="box">
|
||||
<div class="box-body">
|
||||
<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>
|
||||
|
||||
<br/>
|
||||
{{ settingsParsed|raw }}
|
||||
</div>
|
||||
@@ -18,6 +21,12 @@
|
||||
</form>
|
||||
</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>
|
||||
.setting-default {
|
||||
white-space: pre-wrap;
|
||||
@@ -95,12 +104,12 @@
|
||||
.on('change input', function(){
|
||||
const disable = $(this).serialize() === $(this).data('serialized');
|
||||
$(this)
|
||||
.find('input:submit, button:submit')
|
||||
.find('button[name="save"]')
|
||||
.prop('disabled', disable)
|
||||
.prop('title', disable ? noChangesText : '')
|
||||
;
|
||||
})
|
||||
.find('input:submit, button:submit')
|
||||
.find('button[name="save"]')
|
||||
.prop('disabled', true)
|
||||
.prop('title', noChangesText)
|
||||
;
|
||||
@@ -123,7 +132,7 @@
|
||||
let $settings = $('#settings');
|
||||
$settings.data('serialized', $settings.serialize());
|
||||
$settings
|
||||
.find('input:submit, button:submit')
|
||||
.find('button[name="save"]')
|
||||
.prop('disabled', true)
|
||||
.prop('title', noChangesText);
|
||||
},
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
<?php
|
||||
|
||||
$topPlayers = Cache::remember('tibiacom_highscores_top_players', 10 * 60, function() {
|
||||
$topPlayers = getTopPlayers(5);
|
||||
foreach($topPlayers as &$player) {
|
||||
$outfit_url = '';
|
||||
if (setting('core.online_outfit')) {
|
||||
$outfit_url = setting('core.outfit_images_url') . '?id=' . $player['looktype'] . (!empty
|
||||
($player['lookaddons']) ? '&addons=' . $player['lookaddons'] : '') . '&head=' . $player['lookhead'] . '&body=' . $player['lookbody'] . '&legs=' . $player['looklegs'] . '&feet=' . $player['lookfeet'];
|
||||
$player['outfit'] = $player['outfit_url'];
|
||||
$player['link'] = getPlayerLink($player['id'], false);
|
||||
}
|
||||
|
||||
$player['outfit'] = $outfit_url;
|
||||
}
|
||||
}
|
||||
return $topPlayers;
|
||||
});
|
||||
|
||||
$twig->display('highscores.html.twig', array(
|
||||
'topPlayers' => $topPlayers
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<div id="Topbar" class="Themebox" style="background-image:url({{ template_path }}/images/themeboxes/highscores/highscores.png);">
|
||||
<div class="top_level" style="background:url({{ template_path }}/images/themeboxes/bg_top.png)" align=" ">
|
||||
{% for player in topPlayers %}
|
||||
<div style="text-align:left"><a href="{{ getPlayerLink(player['name'], false) }} " class="topfont {% if player['online'] %}online{% else %}offline{% endif %}">
|
||||
<div style="text-align:left"><a href="{{ player['link'] }} " class="topfont {% if player['online'] %}online{% else %}offline{% endif %}">
|
||||
{% if setting('core.online_outfit') %}
|
||||
<img style="position:absolute;margin-top:-45px;margin-left:-25px;" src="{{ player.outfit }}" alt="player outfit"/>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user