mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-17 11:13:27 +02:00
Merge branch 'develop' into plugin-options
This commit is contained in:
@@ -14,11 +14,20 @@ defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
function message($message, $type, $return)
|
||||
{
|
||||
if($return)
|
||||
return '<div class="' . $type . '" style="margin-bottom:10px;">' . $message . '</div>';
|
||||
if(IS_CLI) {
|
||||
if($return) {
|
||||
return $message;
|
||||
}
|
||||
|
||||
echo '<div class="' . $type . '" style="margin-bottom:10px;">' . $message . '</div>';
|
||||
return true;
|
||||
echo $message;
|
||||
return true;
|
||||
}
|
||||
|
||||
if($return)
|
||||
return '<div class="' . $type . '" style="margin-bottom:10px;">' . $message . '</div>';
|
||||
|
||||
echo '<div class="' . $type . '" style="margin-bottom:10px;">' . $message . '</div>';
|
||||
return true;
|
||||
}
|
||||
function success($message, $return = false) {
|
||||
return message($message, 'success', $return);
|
||||
|
@@ -9,40 +9,46 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
define('HOOK_STARTUP', 1);
|
||||
define('HOOK_BEFORE_PAGE', 2);
|
||||
define('HOOK_AFTER_PAGE', 3);
|
||||
define('HOOK_FINISH', 4);
|
||||
define('HOOK_TIBIACOM_ARTICLE', 5);
|
||||
define('HOOK_TIBIACOM_BORDER_3', 6);
|
||||
define('HOOK_CHARACTERS_BEFORE_INFORMATIONS', 7);
|
||||
define('HOOK_CHARACTERS_AFTER_INFORMATIONS', 8);
|
||||
define('HOOK_CHARACTERS_BEFORE_SIGNATURE', 9);
|
||||
define('HOOK_CHARACTERS_AFTER_SIGNATURE', 10);
|
||||
define('HOOK_CHARACTERS_AFTER_ACCOUNT', 11);
|
||||
define('HOOK_CHARACTERS_AFTER_CHARACTERS', 12);
|
||||
define('HOOK_LOGIN', 13);
|
||||
define('HOOK_LOGIN_ATTEMPT', 14);
|
||||
define('HOOK_LOGOUT', 15);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_FORM', 16);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_BOXES', 17);
|
||||
define('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1', 18);
|
||||
define('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_2', 19);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_BOXES', 20);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_ACCOUNT', 21);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_ACCOUNT', 22);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_EMAIL', 23);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_COUNTRY', 24);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS', 25);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_RECAPTCHA', 26);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_CHARACTER_NAME', 27);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_CHARACTER_NAME', 28);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_SEX', 29);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_VOCATION', 30);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_TOWNS', 31);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_SUBMIT_BUTTON', 32);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_FORM', 33);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_SUBMIT', 34);
|
||||
$i = 0;
|
||||
define('HOOK_STARTUP', ++$i);
|
||||
define('HOOK_BEFORE_PAGE', ++$i);
|
||||
define('HOOK_AFTER_PAGE', ++$i);
|
||||
define('HOOK_FINISH', ++$i);
|
||||
define('HOOK_TIBIACOM_ARTICLE', ++$i);
|
||||
define('HOOK_TIBIACOM_BORDER_3', ++$i);
|
||||
define('HOOK_CHARACTERS_BEFORE_INFORMATIONS', ++$i);
|
||||
define('HOOK_CHARACTERS_AFTER_INFORMATIONS', ++$i);
|
||||
define('HOOK_CHARACTERS_BEFORE_SKILLS', ++$i);
|
||||
define('HOOK_CHARACTERS_AFTER_SKILLS', ++$i);
|
||||
define('HOOK_CHARACTERS_AFTER_QUESTS', ++$i);
|
||||
define('HOOK_CHARACTERS_AFTER_EQUIPMENT', ++$i);
|
||||
define('HOOK_CHARACTERS_BEFORE_DEATHS', ++$i);
|
||||
define('HOOK_CHARACTERS_BEFORE_SIGNATURE', ++$i);
|
||||
define('HOOK_CHARACTERS_AFTER_SIGNATURE', ++$i);
|
||||
define('HOOK_CHARACTERS_AFTER_ACCOUNT', ++$i);
|
||||
define('HOOK_CHARACTERS_AFTER_CHARACTERS', ++$i);
|
||||
define('HOOK_LOGIN', ++$i);
|
||||
define('HOOK_LOGIN_ATTEMPT', ++$i);
|
||||
define('HOOK_LOGOUT', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_FORM', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_BOXES', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_2', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_BOXES', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_ACCOUNT', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_ACCOUNT', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_EMAIL', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_COUNTRY', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_RECAPTCHA', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_CHARACTER_NAME', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_CHARACTER_NAME', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_SEX', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_VOCATION', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_TOWNS', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_SUBMIT_BUTTON', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_FORM', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_SUBMIT', ++$i);
|
||||
define('HOOK_FIRST', HOOK_STARTUP);
|
||||
define('HOOK_LAST', HOOK_ACCOUNT_CREATE_AFTER_SUBMIT);
|
||||
|
||||
|
@@ -180,7 +180,8 @@ else {
|
||||
// load towns from database (TFS 1.3) //
|
||||
////////////////////////////////////////
|
||||
|
||||
$towns = array();
|
||||
$tmp = '';
|
||||
$towns = [];
|
||||
if($cache->enabled() && $cache->fetch('towns', $tmp)) {
|
||||
$towns = unserialize($tmp);
|
||||
}
|
||||
@@ -193,20 +194,14 @@ else {
|
||||
}
|
||||
|
||||
unset($query);
|
||||
if($cache->enabled()) {
|
||||
$cache->set('towns', serialize($towns), 600);
|
||||
}
|
||||
}
|
||||
else if($cache->enabled()) {
|
||||
$cache->set('towns', serialize(array()), 600);
|
||||
else {
|
||||
$towns = config('towns');
|
||||
}
|
||||
}
|
||||
|
||||
$configTowns = config('towns');
|
||||
if($configTowns !== null && (!isset($configTowns[1]) || $configTowns[1] !== 'Sample town')) {
|
||||
$towns = array_replace(
|
||||
$towns, $configTowns
|
||||
);
|
||||
if($cache->enabled()) {
|
||||
$cache->set('towns', serialize($towns), 600);
|
||||
}
|
||||
}
|
||||
|
||||
config(['towns', $towns]);
|
||||
|
@@ -55,7 +55,12 @@ class InvitesDriver implements IOTS_GuildAction
|
||||
// invites player to current guild
|
||||
public function addRequest(OTS_Player $player)
|
||||
{
|
||||
$this->db->query('INSERT INTO ' . $this->db->tableName('guild_invites') .' (' . $this->db->fieldName('player_id') . ', ' . $this->db->fieldName('guild_id') . ') VALUES ('.$this->db->quote($player->getId()).', '.$this->db->quote($this->guild->id).')');
|
||||
$extra_keys = $extra_values = '';
|
||||
if($this->db->hasColumn('guild_invites', 'date')) {
|
||||
$extra_keys = ', `date`';
|
||||
$extra_values = ', '.$this->db->quote(time());
|
||||
}
|
||||
$this->db->query('INSERT INTO `guild_invites` (`player_id`, `guild_id`' . $extra_keys . ') VALUES ('.$this->db->quote($player->getId()).', '.$this->db->quote($this->guild->id). $extra_values . ')');
|
||||
}
|
||||
|
||||
// un-invites player
|
||||
|
@@ -229,7 +229,7 @@ class Validator
|
||||
|
||||
$name_lower = strtolower($name);
|
||||
|
||||
$first_words_blocked = array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ');
|
||||
$first_words_blocked = array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ', "'", '-');
|
||||
foreach($first_words_blocked as $word)
|
||||
{
|
||||
if($word == substr($name_lower, 0, strlen($word))) {
|
||||
|
22
system/migrate.php
Normal file
22
system/migrate.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
// database migrations
|
||||
$tmp = '';
|
||||
if(fetchDatabaseConfig('database_version', $tmp)) { // we got version
|
||||
$tmp = (int)$tmp;
|
||||
if($tmp < DATABASE_VERSION) { // import if older
|
||||
$db->revalidateCache();
|
||||
for($i = $tmp + 1; $i <= DATABASE_VERSION; $i++) {
|
||||
require SYSTEM . 'migrations/' . $i . '.php';
|
||||
updateDatabaseConfig('database_version', $i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // register first version
|
||||
registerDatabaseConfig('database_version', 0);
|
||||
$db->revalidateCache();
|
||||
for($i = 1; $i <= DATABASE_VERSION; $i++) {
|
||||
require SYSTEM . 'migrations/' . $i . '.php';
|
||||
updateDatabaseConfig('database_version', $i);
|
||||
}
|
||||
}
|
@@ -10,7 +10,7 @@
|
||||
`type` INT(2) NOT NULL DEFAULT 0,
|
||||
`file` VARCHAR(100) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
|
||||
");
|
||||
|
||||
?>
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'hooks', 'ordering'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "hooks` ADD `ordering` INT(11) NOT NULL DEFAULT 0 AFTER `file`;");
|
||||
|
||||
|
||||
if(!$db->hasTable(TABLE_PREFIX . 'admin_menu'))
|
||||
$db->query("
|
||||
CREATE TABLE `myaac_admin_menu`
|
||||
@@ -13,5 +13,5 @@ CREATE TABLE `myaac_admin_menu`
|
||||
`flags` INT(11) NOT NULL DEFAULT 0,
|
||||
`enabled` INT(1) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;");
|
||||
?>
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
|
||||
");
|
@@ -22,7 +22,8 @@ CREATE TABLE `" . TABLE_PREFIX . "items`
|
||||
`plural` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
`attributes` VARCHAR(500) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;");
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
|
||||
");
|
||||
|
||||
// new weapons table
|
||||
if(!$db->hasTable(TABLE_PREFIX . 'weapons'))
|
||||
@@ -34,7 +35,8 @@ CREATE TABLE `" . TABLE_PREFIX . "weapons`
|
||||
`maglevel` INT(11) NOT NULL DEFAULT 0,
|
||||
`vocations` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;");
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
|
||||
");
|
||||
|
||||
// modify vocations to support json data
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` MODIFY `vocations` VARCHAR(100) NOT NULL DEFAULT '';");
|
||||
|
@@ -12,8 +12,9 @@ CREATE TABLE `myaac_menu`
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
`enabled` INT(1) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;");
|
||||
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
|
||||
");
|
||||
|
||||
$db->query("
|
||||
/* MENU_CATEGORY_NEWS kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Latest News', 'news', 1, 0);
|
||||
|
@@ -11,7 +11,8 @@ CREATE TABLE `z_polls` (
|
||||
`answers` int(11) NOT NULL DEFAULT 0,
|
||||
`votes_all` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;');
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
|
||||
');
|
||||
|
||||
if(!$db->hasTable('z_polls_answers'))
|
||||
$db->query('
|
||||
@@ -20,7 +21,8 @@ $db->query('
|
||||
`answer_id` int(11) NOT NULL,
|
||||
`answer` varchar(255) NOT NULL,
|
||||
`votes` int(11) NOT NULL DEFAULT 0
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;');
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
|
||||
');
|
||||
|
||||
if(!$db->hasColumn('accounts', 'vote'))
|
||||
$db->query('ALTER TABLE `accounts` ADD `vote` INT( 11 ) DEFAULT 0 NOT NULL ;');
|
||||
|
@@ -60,9 +60,12 @@ if (isset($_REQUEST['template'])) {
|
||||
echo "No menu categories set in template config.php.<br/>This template doesn't support dynamic menus.";
|
||||
return;
|
||||
}
|
||||
|
||||
$title = 'Menus - ' . $template;
|
||||
?>
|
||||
<div align="center" class="text-center">
|
||||
<p class="note">Hint: You can drag menu items.<br/>
|
||||
<p class="note">You are editing: <?= $template ?><br/><br/>
|
||||
Hint: You can drag menu items.<br/>
|
||||
Hint: Add links to external sites using: <b>http://</b> or <b>https://</b> prefix.<br/>
|
||||
Not all templates support blank and colorful links.
|
||||
</p>
|
||||
|
@@ -414,7 +414,13 @@ else if (isset($_REQUEST['search'])) {
|
||||
<div class="col-12 col-sm-12 col-lg-6">
|
||||
<label for="town">Town:</label>
|
||||
<select name="town" id="town" class="form-control">
|
||||
<?php foreach ($config['towns'] as $id => $town): ?>
|
||||
<?php
|
||||
$configTowns = config('towns');
|
||||
if (!isset($configTowns[$player->getTownId()])) {
|
||||
$configTowns[$player->getTownId()] = 'Unknown Town';
|
||||
}
|
||||
|
||||
foreach ($configTowns as $id => $town): ?>
|
||||
<option value="<?php echo $id; ?>" <?php echo($player->getTownId() == $id ? 'selected' : ''); ?>><?php echo $town; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
@@ -26,7 +26,7 @@ if ($version_compare == 0) {
|
||||
success('MyAAC latest version is ' . $myaac_version . '. You\'re using the latest version.
|
||||
<br/>View CHANGELOG ' . generateLink(ADMIN_URL . '?p=changelog', 'here'));
|
||||
} else if ($version_compare < 0) {
|
||||
echo success('Woah, seems you\'re using newer version as latest released one! MyAAC latest released version is ' . $myaac_version . ', and you\'re using version ' . MYAAC_VERSION . '.
|
||||
success('Woah, seems you\'re using newer version as latest released one! MyAAC latest released version is ' . $myaac_version . ', and you\'re using version ' . MYAAC_VERSION . '.
|
||||
<br/>View CHANGELOG ' . generateLink(ADMIN_URL . '?p=changelog', 'here'));
|
||||
} else {
|
||||
warning('You\'re using outdated version.<br/>
|
||||
|
@@ -146,7 +146,7 @@ if (empty($_REQUEST['creature'])) {
|
||||
$name = getItemNameById($item['id']);
|
||||
$tooltip = $name . '<br/>Chance: ' . round($item['chance'] / 1000, 2) . '%<br/>Max count: ' . $item['count'];
|
||||
|
||||
echo getItemImage($item['id']);
|
||||
echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="item_image" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' . $name . '" />';
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,13 @@ if($config['template_allow_change'])
|
||||
}
|
||||
|
||||
setSession('template', $template_name);
|
||||
header('Location:' . getSession('last_uri'));
|
||||
|
||||
$newLocation = $lastUri = getSession('last_uri');
|
||||
if($lastUri === $_SERVER['REQUEST_URI']) { // avoid ERR_TOO_MANY_REDIRECTS error in browsers
|
||||
$newLocation = SERVER_URL;
|
||||
}
|
||||
|
||||
header('Location:' . $newLocation);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@@ -38,7 +38,7 @@
|
||||
<div class="col-8">
|
||||
<div class="icheck-primary">
|
||||
<input type="checkbox" id="remember_me" name="remember_me" value="true">
|
||||
<label for="remember">Remember Me</label>
|
||||
<label for="remember_me">Remember Me</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
@@ -50,4 +50,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -156,6 +156,8 @@
|
||||
<br/>
|
||||
<table border="0" width="100%">
|
||||
<tr>
|
||||
{{ hook(constant('HOOK_CHARACTERS_BEFORE_SKILLS')) }}
|
||||
|
||||
{% if config.characters.skills %}
|
||||
<!-- SKILLS -->
|
||||
<td width="30%" valign="top">
|
||||
@@ -176,6 +178,8 @@
|
||||
<!-- SKILLS_END -->
|
||||
{% endif %}
|
||||
|
||||
{{ hook(constant('HOOK_CHARACTERS_AFTER_SKILLS')) }}
|
||||
|
||||
{% if quests_enabled %}
|
||||
<!-- QUESTS -->
|
||||
<td width="40%" valign="top">
|
||||
@@ -196,6 +200,8 @@
|
||||
<!-- QUESTS_END -->
|
||||
{% endif %}
|
||||
|
||||
{{ hook(constant('HOOK_CHARACTERS_AFTER_QUESTS')) }}
|
||||
|
||||
{% if config.characters.equipment %}
|
||||
<!-- EQUIPMENT -->
|
||||
<td width="100" valign="top">
|
||||
@@ -231,9 +237,11 @@
|
||||
</td>
|
||||
<!-- EQUIPMENT_END -->
|
||||
{% endif %}
|
||||
{{ hook(constant('HOOK_CHARACTERS_AFTER_EQUIPMENT')) }}
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{{ hook(constant('HOOK_CHARACTERS_BEFORE_DEATHS')) }}
|
||||
{% if deaths|length > 0 %}
|
||||
<!-- DEATHS -->
|
||||
<br/>
|
||||
|
@@ -57,7 +57,7 @@
|
||||
}
|
||||
</style>
|
||||
<!--[if lt IE 9]>
|
||||
<script src="/tools/js/html5shiv.js"></script>
|
||||
<script src="/tools/js/html5shiv.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
|
Reference in New Issue
Block a user