mirror of
https://github.com/slawkens/myaac.git
synced 2025-09-14 04:23:34 +02:00
Compare commits
19 Commits
feature/tw
...
develop
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e719725841 | ||
![]() |
4ca58b4178 | ||
![]() |
03e2752139 | ||
![]() |
2fece725a4 | ||
![]() |
bb3e90110d | ||
![]() |
c24c580796 | ||
![]() |
620a47da72 | ||
![]() |
9b75011224 | ||
![]() |
5b4b7b8a97 | ||
![]() |
99997eb57d | ||
![]() |
73a5829974 | ||
![]() |
497338c2d6 | ||
![]() |
beb348fe27 | ||
![]() |
5b1bd4f005 | ||
![]() |
f09606d01b | ||
![]() |
67ab425bb9 | ||
![]() |
113473f256 | ||
![]() |
d6ac4e8d85 | ||
![]() |
6845869838 |
4
.github/workflows/cypress.yml
vendored
4
.github/workflows/cypress.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: [ '8.1', '8.2', '8.3' ]
|
||||
php-versions: [ '8.1', '8.2', '8.3', '8.4' ]
|
||||
ots: ['tfs-1.4', 'canary-3.1.2'] # TODO: add 'tfs-master' (actually doesn't work cause AAC doesn't support reading .env configuration)
|
||||
name: Cypress (PHP ${{ matrix.php-versions }}, ${{ matrix.ots }})
|
||||
steps:
|
||||
@@ -146,6 +146,7 @@ jobs:
|
||||
with:
|
||||
name: cypress-screenshots-${{ matrix.php-versions }}-${{ matrix.ots }}
|
||||
path: cypress/screenshots
|
||||
if-no-files-found: ignore
|
||||
|
||||
- name: Upload Cypress Videos
|
||||
uses: actions/upload-artifact@v4
|
||||
@@ -153,6 +154,7 @@ jobs:
|
||||
with:
|
||||
name: cypress-videos-${{ matrix.php-versions }}-${{ matrix.ots }}
|
||||
path: cypress/videos
|
||||
if-no-files-found: ignore
|
||||
|
||||
- name: Upload PHP Logs
|
||||
uses: actions/upload-artifact@v4
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# [MyAAC](https://my-aac.org)
|
||||
|
||||
MyAAC is a free and open-source Automatic Account Creator (AAC) written in PHP. It is a fork of the [Gesior](https://github.com/gesior/Gesior2012) project. It supports only MySQL databases.
|
||||
MyAAC is a free and open-source Automatic Account Creator (AAC) for Open Tibia Servers written in PHP. It is a fork of the [Gesior](https://github.com/gesior/Gesior2012) project. It supports only MySQL databases.
|
||||
|
||||
Official website: https://my-aac.org
|
||||
|
||||
|
@@ -168,6 +168,7 @@ if ($logged && admin()) {
|
||||
'username' => USE_ACCOUNT_NAME ? $account_logged->getName() : $account_logged->getId()
|
||||
]);
|
||||
}
|
||||
|
||||
$title_full = (isset($title) ? $title . ' - ' : '') . $config['lua']['serverName'];
|
||||
require $template_path . '/' . $template_index;
|
||||
|
||||
|
@@ -54,12 +54,13 @@ if ($db->hasTable('players')) {
|
||||
}
|
||||
}
|
||||
|
||||
Plugins::installMenus('kathrine', require TEMPLATES . 'kathrine/menus.php');
|
||||
Plugins::installMenus('tibiacom', require TEMPLATES . 'tibiacom/menus.php');
|
||||
|
||||
DataLoader::setLocale($locale);
|
||||
DataLoader::load();
|
||||
|
||||
// add menus entries
|
||||
require_once SYSTEM . 'migrations/17.php';
|
||||
$up();
|
||||
|
||||
// update config.highscores_ids_hidden
|
||||
require_once SYSTEM . 'migrations/20.php';
|
||||
$up();
|
||||
|
@@ -74,7 +74,3 @@ function fieldExist($field, $table)
|
||||
global $db;
|
||||
return $db->hasColumn($table, $field);
|
||||
}
|
||||
|
||||
function getCreatureImgPath($creature): string {
|
||||
return getMonsterImgPath($creature);
|
||||
}
|
||||
|
@@ -1578,22 +1578,6 @@ function right($str, $length) {
|
||||
return substr($str, -$length);
|
||||
}
|
||||
|
||||
function getMonsterImgPath($monster): string
|
||||
{
|
||||
$monster_path = setting('core.monsters_images_url');
|
||||
$monster_gfx_name = trim(strtolower($monster)) . setting('core.monsters_images_extension');
|
||||
if (!file_exists($monster_path . $monster_gfx_name)) {
|
||||
$monster_gfx_name = str_replace(" ", "", $monster_gfx_name);
|
||||
if (file_exists($monster_path . $monster_gfx_name)) {
|
||||
return $monster_path . $monster_gfx_name;
|
||||
} else {
|
||||
return $monster_path . 'nophoto.png';
|
||||
}
|
||||
} else {
|
||||
return $monster_path . $monster_gfx_name;
|
||||
}
|
||||
}
|
||||
|
||||
function between($x, $lim1, $lim2) {
|
||||
if ($lim1 < $lim2) {
|
||||
$lower = $lim1; $upper = $lim2;
|
||||
|
@@ -97,7 +97,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*
|
||||
* @param IOTS_GuildAction $invites Invites driver (don't pass it to clear driver).
|
||||
*/
|
||||
public function setInvitesDriver(IOTS_GuildAction $invites = null)
|
||||
public function setInvitesDriver(?IOTS_GuildAction $invites = null)
|
||||
{
|
||||
$this->invites = $invites;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*
|
||||
* @param IOTS_GuildAction $requests Membership requests driver (don't pass it to clear driver).
|
||||
*/
|
||||
public function setRequestsDriver(IOTS_GuildAction $requests = null)
|
||||
public function setRequestsDriver(?IOTS_GuildAction $requests = null)
|
||||
{
|
||||
$this->requests = $requests;
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ class OTS_GuildRank extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
* @throws PDOException On PDO operation error.
|
||||
* @throws E_OTS_NotLoaded If given <var>$guild</var> object is not loaded.
|
||||
*/
|
||||
public function find($name, OTS_Guild $guild = null)
|
||||
public function find($name, ?OTS_Guild $guild = null)
|
||||
{
|
||||
$where = '';
|
||||
|
||||
|
@@ -284,7 +284,7 @@ class OTS_Monster extends DOMDocument
|
||||
*/
|
||||
public function getLook()
|
||||
{
|
||||
$look = array();
|
||||
$look = [];
|
||||
|
||||
$element = $this->documentElement->getElementsByTagName('look')->item(0);
|
||||
|
||||
@@ -292,14 +292,30 @@ class OTS_Monster extends DOMDocument
|
||||
return $look;
|
||||
}
|
||||
|
||||
$look['type'] = $element->getAttribute('type');
|
||||
$look['typeex'] = $element->getAttribute('typeex');
|
||||
$look['head'] = $element->getAttribute('head');
|
||||
$look['body'] = $element->getAttribute('body');
|
||||
$look['legs'] = $element->getAttribute('legs');
|
||||
$look['feet'] = $element->getAttribute('feet');
|
||||
$look['addons'] = $element->getAttribute('addons');
|
||||
$look['corpse'] = $element->getAttribute('corpse');
|
||||
if ($element->hasAttribute('typeex')) {
|
||||
$look['typeEx'] = (int) $element->getAttribute('typeex');
|
||||
}
|
||||
if ($element->hasAttribute('type')) {
|
||||
$look['type'] = (int) $element->getAttribute('type');
|
||||
}
|
||||
if ($element->hasAttribute('head')) {
|
||||
$look['head'] = (int) $element->getAttribute('head');
|
||||
}
|
||||
if ($element->hasAttribute('body')) {
|
||||
$look['body'] = (int) $element->getAttribute('body');
|
||||
}
|
||||
if ($element->hasAttribute('legs')) {
|
||||
$look['legs'] = (int) $element->getAttribute('legs');
|
||||
}
|
||||
if ($element->hasAttribute('feet')) {
|
||||
$look['feet'] = (int) $element->getAttribute('feet');
|
||||
}
|
||||
if ($element->hasAttribute('addons')) {
|
||||
$look['addons'] = (int) $element->getAttribute('addons');
|
||||
}
|
||||
if ($element->hasAttribute('corpse')) {
|
||||
$look['corpse'] = (int) $element->getAttribute('corpse');
|
||||
}
|
||||
|
||||
return $look;
|
||||
}
|
||||
|
@@ -2026,7 +2026,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
* @param OTS_GuildRank|null Guild rank (null to clear assign).
|
||||
* @throws E_OTS_NotLoaded If passed <var>$guildRank</var> parameter is not loaded.
|
||||
*/
|
||||
public function setRank(OTS_GuildRank $guildRank = null)
|
||||
public function setRank(?OTS_GuildRank $guildRank = null)
|
||||
{
|
||||
if(isset($guildRank))
|
||||
$this->setRankId($guildRank->getId(), $guildRank->getGuild()->getId());
|
||||
@@ -2632,7 +2632,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
* @throws E_OTS_NotLoaded If player is not loaded.
|
||||
* @throws PDOException On PDO operation error.
|
||||
*/
|
||||
public function setSlot($slot, OTS_Item $item = null, $pid = 0)
|
||||
public function setSlot($slot, ?OTS_Item $item = null, $pid = 0)
|
||||
{
|
||||
static $sid;
|
||||
|
||||
@@ -2776,7 +2776,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
* @throws E_OTS_NotLoaded If player is not loaded.
|
||||
* @throws PDOException On PDO operation error.
|
||||
*/
|
||||
public function setDepot($depot, OTS_Item $item = null, $pid = 0, $depot_id = 0)
|
||||
public function setDepot($depot, ?OTS_Item $item = null, $pid = 0, $depot_id = 0)
|
||||
{
|
||||
static $sid;
|
||||
|
||||
|
@@ -10,8 +10,13 @@ $up = function () use ($db) {
|
||||
$db->exec(file_get_contents(__DIR__ . '/17-menu.sql'));
|
||||
}
|
||||
|
||||
Plugins::installMenus('kathrine', require TEMPLATES . 'kathrine/menus.php');
|
||||
Plugins::installMenus('tibiacom', require TEMPLATES . 'tibiacom/menus.php');
|
||||
$themes = ['kathrine', 'tibiacom',];
|
||||
foreach ($themes as $theme) {
|
||||
$file = TEMPLATES . $theme . '/menus.php';
|
||||
if (is_file($file)) {
|
||||
Plugins::installMenus($theme, require $file);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$down = function () use ($db) {
|
||||
|
@@ -16,18 +16,22 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Monsters';
|
||||
|
||||
if (empty($_REQUEST['name'])) {
|
||||
// display list of monsters
|
||||
$preview = setting('core.monsters_images_preview');
|
||||
$monsters = Monster::where('hide', '!=', 1)->when(!empty($_REQUEST['boss']), function ($query) {
|
||||
$query->where('rewardboss', 1);
|
||||
})->get()->toArray();
|
||||
|
||||
if ($preview) {
|
||||
foreach($monsters as $key => &$monster)
|
||||
{
|
||||
$monster['img_link'] = getMonsterImgPath($monster['name']);
|
||||
// display list of monsters
|
||||
$monsters = MyAAC\Cache::remember('monsters', 30 * 60, function () use ($preview) {
|
||||
$monsters = Monster::where('hide', '!=', 1)->when(!empty($_REQUEST['boss']), function ($query) {
|
||||
$query->where('rewardboss', 1);
|
||||
})->get()->toArray();
|
||||
|
||||
if ($preview) {
|
||||
foreach($monsters as &$monster) {
|
||||
$monster['img_link'] = getMonsterImage($monster);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $monsters;
|
||||
});
|
||||
|
||||
$twig->display('monsters.html.twig', array(
|
||||
'monsters' => $monsters,
|
||||
@@ -45,7 +49,7 @@ if ($monsterModel && isset($monsterModel->name)) {
|
||||
/** @var array $monster */
|
||||
$monster = $monsterModel->toArray();
|
||||
|
||||
function sort_by_chance($a, $b)
|
||||
function sort_by_chance($a, $b): int
|
||||
{
|
||||
if ($a['chance'] == $b['chance']) {
|
||||
return 0;
|
||||
@@ -55,7 +59,7 @@ if ($monsterModel && isset($monsterModel->name)) {
|
||||
|
||||
$title = $monster['name'] . " - Monsters";
|
||||
|
||||
$monster['img_link']= getMonsterImgPath($monster_name);
|
||||
$monster['img_link']= getMonsterImage($monster);
|
||||
|
||||
$voices = json_decode($monster['voices'], true);
|
||||
$summons = json_decode($monster['summons'], true);
|
||||
@@ -89,3 +93,39 @@ if ($monsterModel && isset($monsterModel->name)) {
|
||||
|
||||
// back button
|
||||
$twig->display('monsters.back_button.html.twig');
|
||||
|
||||
function getMonsterImage($monster): string
|
||||
{
|
||||
$outfit = json_decode($monster['look'], true);
|
||||
|
||||
if (!empty($outfit['typeEx'])) {
|
||||
return setting('core.item_images_url') . $outfit['typeEx'] . setting('core.item_images_extension');
|
||||
}
|
||||
|
||||
if (isset($outfit['type'])) {
|
||||
$getValue = function ($val) use ($outfit) {
|
||||
return (!empty($outfit[$val])
|
||||
? '&' . $val . '=' . $outfit[$val] : '');
|
||||
};
|
||||
|
||||
return setting('core.outfit_images_url') . '?id=' . $outfit['type'] . $getValue('addons') . $getValue('head') . $getValue('body') . $getValue('legs') . $getValue('feet');
|
||||
}
|
||||
|
||||
return getMonsterImgPath($monster['name']);
|
||||
}
|
||||
|
||||
function getMonsterImgPath($name): string
|
||||
{
|
||||
$monster_path = setting('core.monsters_images_url');
|
||||
$monster_gfx_name = trim(strtolower($name)) . setting('core.monsters_images_extension');
|
||||
if (!file_exists($monster_path . $monster_gfx_name)) {
|
||||
$monster_gfx_name = str_replace(" ", "", $monster_gfx_name);
|
||||
if (file_exists($monster_path . $monster_gfx_name)) {
|
||||
return $monster_path . $monster_gfx_name;
|
||||
} else {
|
||||
return $monster_path . 'nophoto.png';
|
||||
}
|
||||
} else {
|
||||
return $monster_path . $monster_gfx_name;
|
||||
}
|
||||
}
|
||||
|
@@ -317,6 +317,11 @@ $content .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
$hooks->trigger(HOOK_AFTER_PAGE);
|
||||
|
||||
if (isset($_REQUEST['_page_only'])) {
|
||||
echo $content;
|
||||
die;
|
||||
}
|
||||
|
||||
if(!isset($title)) {
|
||||
$title = str_replace('index.php/', '', $page);
|
||||
$title = ucfirst($title);
|
||||
|
@@ -1473,7 +1473,7 @@ Sent by MyAAC,<br/>
|
||||
],
|
||||
'status_timeout' => [
|
||||
'name' => 'Status Timeout',
|
||||
'type' => 'number',
|
||||
'type' => 'double',
|
||||
'min' => 0,
|
||||
'max' => 10, // more than 10 seconds waiting makes no sense
|
||||
'step' => 0.1,
|
||||
|
@@ -219,7 +219,7 @@ class Settings implements \ArrayAccess
|
||||
if ($setting['type'] === 'boolean') {
|
||||
$value = ($setting['default'] ? 'true' : 'false');
|
||||
}
|
||||
else if (in_array($setting['type'], ['text', 'number', 'email', 'password', 'textarea'])) {
|
||||
else if (in_array($setting['type'], ['text', 'number', 'float', 'double', 'email', 'password', 'textarea'])) {
|
||||
$value = $setting['default'];
|
||||
}
|
||||
else if ($setting['type'] === 'options') {
|
||||
@@ -245,7 +245,11 @@ class Settings implements \ArrayAccess
|
||||
$checkbox($key, false, $value);
|
||||
}
|
||||
|
||||
else if (in_array($setting['type'], ['text', 'number', 'email', 'password'])) {
|
||||
else if (in_array($setting['type'], ['text', 'number', 'float', 'double', 'email', 'password'])) {
|
||||
if (in_array($setting['type'], ['float', 'double'])) {
|
||||
$setting['type'] = 'number';
|
||||
}
|
||||
|
||||
if ($setting['type'] === 'number') {
|
||||
$min = (isset($setting['min']) ? ' min="' . $setting['min'] . '"' : '');
|
||||
$max = (isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '');
|
||||
@@ -351,7 +355,7 @@ class Settings implements \ArrayAccess
|
||||
if ($setting['type'] === 'boolean') {
|
||||
echo ($setting['default'] ? 'Yes' : 'No');
|
||||
}
|
||||
else if (in_array($setting['type'], ['text', 'number', 'email', 'password', 'textarea'])) {
|
||||
else if (in_array($setting['type'], ['text', 'number', 'float', 'double', 'email', 'password', 'textarea'])) {
|
||||
echo $setting['default'];
|
||||
}
|
||||
else if ($setting['type'] === 'options') {
|
||||
@@ -498,9 +502,12 @@ class Settings implements \ArrayAccess
|
||||
break;
|
||||
|
||||
case 'number':
|
||||
if (!isset($ret['step']) || (int)$ret['step'] == 1) {
|
||||
$ret['value'] = (int)$ret['value'];
|
||||
}
|
||||
$ret['value'] = (int)$ret['value'];
|
||||
break;
|
||||
|
||||
case 'double':
|
||||
case 'float':
|
||||
$ret['value'] = (double)($ret['value']);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -136,6 +136,11 @@ if($forumSetting != '')
|
||||
$twig->addGlobal('template_name', $template_name);
|
||||
$twig->addGlobal('template_path', $template_path);
|
||||
if($twig_loader) {
|
||||
$viewsPath = BASE . $template_path . '/views';
|
||||
if (is_dir($viewsPath)) {
|
||||
$twig_loader->prependPath($viewsPath);
|
||||
}
|
||||
|
||||
$twig_loader->prependPath(BASE . $template_path);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user