mirror of
https://github.com/slawkens/myaac.git
synced 2025-05-10 07:59:21 +02:00
Merge branch 'main' into develop
This commit is contained in:
commit
bb3e90110d
@ -1,6 +1,6 @@
|
|||||||
# [MyAAC](https://my-aac.org)
|
# [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
|
Official website: https://my-aac.org
|
||||||
|
|
||||||
|
@ -168,6 +168,7 @@ if ($logged && admin()) {
|
|||||||
'username' => USE_ACCOUNT_NAME ? $account_logged->getName() : $account_logged->getId()
|
'username' => USE_ACCOUNT_NAME ? $account_logged->getName() : $account_logged->getId()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$title_full = (isset($title) ? $title . ' - ' : '') . $config['lua']['serverName'];
|
$title_full = (isset($title) ? $title . ' - ' : '') . $config['lua']['serverName'];
|
||||||
require $template_path . '/' . $template_index;
|
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::setLocale($locale);
|
||||||
DataLoader::load();
|
DataLoader::load();
|
||||||
|
|
||||||
|
// add menus entries
|
||||||
|
require_once SYSTEM . 'migrations/17.php';
|
||||||
|
$up();
|
||||||
|
|
||||||
// update config.highscores_ids_hidden
|
// update config.highscores_ids_hidden
|
||||||
require_once SYSTEM . 'migrations/20.php';
|
require_once SYSTEM . 'migrations/20.php';
|
||||||
$up();
|
$up();
|
||||||
|
@ -74,7 +74,3 @@ function fieldExist($field, $table)
|
|||||||
global $db;
|
global $db;
|
||||||
return $db->hasColumn($table, $field);
|
return $db->hasColumn($table, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCreatureImgPath($creature): string {
|
|
||||||
return getMonsterImgPath($creature);
|
|
||||||
}
|
|
||||||
|
@ -575,7 +575,7 @@ function template_footer(): string
|
|||||||
$footer[] = base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4=');
|
$footer[] = base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4=');
|
||||||
|
|
||||||
global $hooks;
|
global $hooks;
|
||||||
$footer = $hooks->triggerFilter(HOOK_FILTER_THEME_FOOTER, $footer);
|
$hooks->triggerFilter(HOOK_FILTER_THEME_FOOTER, $footer);
|
||||||
|
|
||||||
return implode('<br/>', $footer);
|
return implode('<br/>', $footer);
|
||||||
}
|
}
|
||||||
@ -1578,22 +1578,6 @@ function right($str, $length) {
|
|||||||
return substr($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) {
|
function between($x, $lim1, $lim2) {
|
||||||
if ($lim1 < $lim2) {
|
if ($lim1 < $lim2) {
|
||||||
$lower = $lim1; $upper = $lim2;
|
$lower = $lim1; $upper = $lim2;
|
||||||
|
@ -284,7 +284,7 @@ class OTS_Monster extends DOMDocument
|
|||||||
*/
|
*/
|
||||||
public function getLook()
|
public function getLook()
|
||||||
{
|
{
|
||||||
$look = array();
|
$look = [];
|
||||||
|
|
||||||
$element = $this->documentElement->getElementsByTagName('look')->item(0);
|
$element = $this->documentElement->getElementsByTagName('look')->item(0);
|
||||||
|
|
||||||
@ -292,14 +292,30 @@ class OTS_Monster extends DOMDocument
|
|||||||
return $look;
|
return $look;
|
||||||
}
|
}
|
||||||
|
|
||||||
$look['type'] = $element->getAttribute('type');
|
if ($element->hasAttribute('typeex')) {
|
||||||
$look['typeex'] = $element->getAttribute('typeex');
|
$look['typeEx'] = (int) $element->getAttribute('typeex');
|
||||||
$look['head'] = $element->getAttribute('head');
|
}
|
||||||
$look['body'] = $element->getAttribute('body');
|
if ($element->hasAttribute('type')) {
|
||||||
$look['legs'] = $element->getAttribute('legs');
|
$look['type'] = (int) $element->getAttribute('type');
|
||||||
$look['feet'] = $element->getAttribute('feet');
|
}
|
||||||
$look['addons'] = $element->getAttribute('addons');
|
if ($element->hasAttribute('head')) {
|
||||||
$look['corpse'] = $element->getAttribute('corpse');
|
$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;
|
return $look;
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,13 @@ $up = function () use ($db) {
|
|||||||
$db->exec(file_get_contents(__DIR__ . '/17-menu.sql'));
|
$db->exec(file_get_contents(__DIR__ . '/17-menu.sql'));
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugins::installMenus('kathrine', require TEMPLATES . 'kathrine/menus.php');
|
$themes = ['kathrine', 'tibiacom',];
|
||||||
Plugins::installMenus('tibiacom', require TEMPLATES . 'tibiacom/menus.php');
|
foreach ($themes as $theme) {
|
||||||
|
$file = TEMPLATES . $theme . '/menus.php';
|
||||||
|
if (is_file($file)) {
|
||||||
|
Plugins::installMenus($theme, require $file);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$down = function () use ($db) {
|
$down = function () use ($db) {
|
||||||
|
@ -16,19 +16,23 @@ defined('MYAAC') or die('Direct access not allowed!');
|
|||||||
$title = 'Monsters';
|
$title = 'Monsters';
|
||||||
|
|
||||||
if (empty($_REQUEST['name'])) {
|
if (empty($_REQUEST['name'])) {
|
||||||
// display list of monsters
|
|
||||||
$preview = setting('core.monsters_images_preview');
|
$preview = setting('core.monsters_images_preview');
|
||||||
|
|
||||||
|
// 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) {
|
$monsters = Monster::where('hide', '!=', 1)->when(!empty($_REQUEST['boss']), function ($query) {
|
||||||
$query->where('rewardboss', 1);
|
$query->where('rewardboss', 1);
|
||||||
})->get()->toArray();
|
})->get()->toArray();
|
||||||
|
|
||||||
if ($preview) {
|
if ($preview) {
|
||||||
foreach($monsters as $key => &$monster)
|
foreach($monsters as &$monster) {
|
||||||
{
|
$monster['img_link'] = getMonsterImage($monster);
|
||||||
$monster['img_link'] = getMonsterImgPath($monster['name']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $monsters;
|
||||||
|
});
|
||||||
|
|
||||||
$twig->display('monsters.html.twig', array(
|
$twig->display('monsters.html.twig', array(
|
||||||
'monsters' => $monsters,
|
'monsters' => $monsters,
|
||||||
'preview' => $preview
|
'preview' => $preview
|
||||||
@ -45,7 +49,7 @@ if ($monsterModel && isset($monsterModel->name)) {
|
|||||||
/** @var array $monster */
|
/** @var array $monster */
|
||||||
$monster = $monsterModel->toArray();
|
$monster = $monsterModel->toArray();
|
||||||
|
|
||||||
function sort_by_chance($a, $b)
|
function sort_by_chance($a, $b): int
|
||||||
{
|
{
|
||||||
if ($a['chance'] == $b['chance']) {
|
if ($a['chance'] == $b['chance']) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -55,7 +59,7 @@ if ($monsterModel && isset($monsterModel->name)) {
|
|||||||
|
|
||||||
$title = $monster['name'] . " - Monsters";
|
$title = $monster['name'] . " - Monsters";
|
||||||
|
|
||||||
$monster['img_link']= getMonsterImgPath($monster_name);
|
$monster['img_link']= getMonsterImage($monster);
|
||||||
|
|
||||||
$voices = json_decode($monster['voices'], true);
|
$voices = json_decode($monster['voices'], true);
|
||||||
$summons = json_decode($monster['summons'], true);
|
$summons = json_decode($monster['summons'], true);
|
||||||
@ -89,3 +93,39 @@ if ($monsterModel && isset($monsterModel->name)) {
|
|||||||
|
|
||||||
// back button
|
// back button
|
||||||
$twig->display('monsters.back_button.html.twig');
|
$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();
|
ob_end_clean();
|
||||||
$hooks->trigger(HOOK_AFTER_PAGE);
|
$hooks->trigger(HOOK_AFTER_PAGE);
|
||||||
|
|
||||||
|
if (isset($_REQUEST['_page_only'])) {
|
||||||
|
echo $content;
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
if(!isset($title)) {
|
if(!isset($title)) {
|
||||||
$title = str_replace('index.php/', '', $page);
|
$title = str_replace('index.php/', '', $page);
|
||||||
$title = ucfirst($title);
|
$title = ucfirst($title);
|
||||||
|
@ -1473,7 +1473,7 @@ Sent by MyAAC,<br/>
|
|||||||
],
|
],
|
||||||
'status_timeout' => [
|
'status_timeout' => [
|
||||||
'name' => 'Status Timeout',
|
'name' => 'Status Timeout',
|
||||||
'type' => 'number',
|
'type' => 'double',
|
||||||
'min' => 0,
|
'min' => 0,
|
||||||
'max' => 10, // more than 10 seconds waiting makes no sense
|
'max' => 10, // more than 10 seconds waiting makes no sense
|
||||||
'step' => 0.1,
|
'step' => 0.1,
|
||||||
|
@ -37,7 +37,7 @@ class Hook
|
|||||||
return !isset($ret) || $ret == 1 || $ret;
|
return !isset($ret) || $ret == 1 || $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function executeFilter(...$args) {
|
public function executeFilter(&$args) {
|
||||||
return include BASE . $this->_file;
|
return include BASE . $this->_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,16 +30,14 @@ class Hooks
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function triggerFilter($type, $args = [])
|
public function triggerFilter($type, &$args): void
|
||||||
{
|
{
|
||||||
if(isset(self::$_hooks[$type])) {
|
if(isset(self::$_hooks[$type])) {
|
||||||
foreach(self::$_hooks[$type] as $hook) {
|
foreach(self::$_hooks[$type] as $hook) {
|
||||||
/** @var Hook $hook */
|
/** @var Hook $hook */
|
||||||
$args = $hook->executeFilter(...$args);
|
$hook->executeFilter($args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $args;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exist($type): bool {
|
public function exist($type): bool {
|
||||||
|
@ -198,6 +198,9 @@ class Plugins {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global $hooks;
|
||||||
|
$hooks->triggerFilter(HOOK_FILTER_ROUTES, $routes);
|
||||||
|
|
||||||
usort($routes, function ($a, $b)
|
usort($routes, function ($a, $b)
|
||||||
{
|
{
|
||||||
// key 3 is priority
|
// key 3 is priority
|
||||||
|
@ -219,7 +219,7 @@ class Settings implements \ArrayAccess
|
|||||||
if ($setting['type'] === 'boolean') {
|
if ($setting['type'] === 'boolean') {
|
||||||
$value = ($setting['default'] ? 'true' : 'false');
|
$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'];
|
$value = $setting['default'];
|
||||||
}
|
}
|
||||||
else if ($setting['type'] === 'options') {
|
else if ($setting['type'] === 'options') {
|
||||||
@ -245,7 +245,11 @@ class Settings implements \ArrayAccess
|
|||||||
$checkbox($key, false, $value);
|
$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') {
|
if ($setting['type'] === 'number') {
|
||||||
$min = (isset($setting['min']) ? ' min="' . $setting['min'] . '"' : '');
|
$min = (isset($setting['min']) ? ' min="' . $setting['min'] . '"' : '');
|
||||||
$max = (isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '');
|
$max = (isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '');
|
||||||
@ -351,7 +355,7 @@ class Settings implements \ArrayAccess
|
|||||||
if ($setting['type'] === 'boolean') {
|
if ($setting['type'] === 'boolean') {
|
||||||
echo ($setting['default'] ? 'Yes' : 'No');
|
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'];
|
echo $setting['default'];
|
||||||
}
|
}
|
||||||
else if ($setting['type'] === 'options') {
|
else if ($setting['type'] === 'options') {
|
||||||
@ -498,9 +502,12 @@ class Settings implements \ArrayAccess
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'number':
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -11,7 +11,7 @@ class EnvironmentBridge extends Environment
|
|||||||
global $hooks;
|
global $hooks;
|
||||||
|
|
||||||
$context['viewName'] = $name;
|
$context['viewName'] = $name;
|
||||||
$context = $hooks->triggerFilter(HOOK_FILTER_TWIG_DISPLAY, $context);
|
$hooks->triggerFilter(HOOK_FILTER_TWIG_DISPLAY, $context);
|
||||||
|
|
||||||
parent::display($name, $context);
|
parent::display($name, $context);
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ class EnvironmentBridge extends Environment
|
|||||||
global $hooks;
|
global $hooks;
|
||||||
|
|
||||||
$context['viewName'] = $name;
|
$context['viewName'] = $name;
|
||||||
$context = $hooks->triggerFilter(HOOK_FILTER_TWIG_RENDER, $context);
|
$hooks->triggerFilter(HOOK_FILTER_TWIG_RENDER, $context);
|
||||||
|
|
||||||
return parent::render($name, $context);
|
return parent::render($name, $context);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ define('HOOK_INSTALL_FINISH', ++$i);
|
|||||||
define('HOOK_INSTALL_FINISH_END', ++$i);
|
define('HOOK_INSTALL_FINISH_END', ++$i);
|
||||||
|
|
||||||
// hook filters
|
// hook filters
|
||||||
|
define('HOOK_FILTER_ROUTES', ++$i);
|
||||||
define('HOOK_FILTER_TWIG_DISPLAY', ++$i);
|
define('HOOK_FILTER_TWIG_DISPLAY', ++$i);
|
||||||
define('HOOK_FILTER_TWIG_RENDER', ++$i);
|
define('HOOK_FILTER_TWIG_RENDER', ++$i);
|
||||||
define('HOOK_FILTER_THEME_FOOTER', ++$i);
|
define('HOOK_FILTER_THEME_FOOTER', ++$i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user