Merge branch 'develop' into feature/new-router

# Conflicts:
#	composer.json
#	system/login.php
This commit is contained in:
slawkens
2023-02-03 07:31:39 +01:00
199 changed files with 4166 additions and 1379 deletions

View File

@@ -74,7 +74,7 @@ if($save)
if(config('recaptcha_enabled'))
{
require LIBS . 'GoogleReCAPTCHA.php';
require_once LIBS . 'GoogleReCAPTCHA.php';
if (!GoogleReCAPTCHA::verify('register')) {
$errors['verification'] = GoogleReCAPTCHA::getErrorMessage();
}

View File

@@ -0,0 +1,202 @@
<?php
/**
* Account Admin Tool
*
* @package MyAAC
* @author Slawkens <slawkens@gmail.com>
* @author Lee
* @copyright 2020 MyAAC
* @link https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Mass Account Actions';
$hasCoinsColumn = $db->hasColumn('accounts', 'coins');
$hasPointsColumn = $db->hasColumn('accounts', 'premium_points');
$freePremium = $config['lua']['freePremium'];
function admin_give_points($points)
{
global $db, $hasPointsColumn;
if (!$hasPointsColumn) {
error('Points not supported.');
return;
}
$statement = $db->prepare('UPDATE `accounts` SET `premium_points` = `premium_points` + :points');
if (!$statement) {
error('Failed to prepare query statement.');
return;
}
if (!$statement->execute([
'points' => $points
])) {
error('Failed to add points.');
return;
}
success($points . ' points added to all accounts.');
}
function admin_give_coins($coins)
{
global $db, $hasCoinsColumn;
if (!$hasCoinsColumn) {
error('Coins not supported.');
return;
}
$statement = $db->prepare('UPDATE `accounts` SET `coins` = `coins` + :coins');
if (!$statement) {
error('Failed to prepare query statement.');
return;
}
if (!$statement->execute([
'coins' => $coins
])) {
error('Failed to add coins.');
return;
}
success($coins . ' coins added to all accounts.');
}
function query_add_premium($column, $value_query, $condition_query = '1=1', $params = [])
{
global $db;
$statement = $db->prepare("UPDATE `accounts` SET `{$column}` = $value_query WHERE $condition_query");
if (!$statement) {
error('Failed to prepare query statement.');
return false;
}
if (!$statement->execute($params)) {
error('Failed to add premium days.');
return false;
}
return true;
}
function admin_give_premdays($days)
{
global $db, $freePremium;
if ($freePremium) {
error('Premium days not supported. Free Premium enabled.');
return;
}
$value = $days * 86400;
$now = time();
// othire
if ($db->hasColumn('accounts', 'premend')) {
// append premend
if (query_add_premium('premend', '`premend` + :value', '`premend` > :now', ['value' => $value, 'now' => $now])) {
// set premend
if (query_add_premium('premend', ':value', '`premend` <= :now', ['value' => $now + $value, 'now' => $now])) {
success($days . ' premium days added to all accounts.');
return;
} else {
error('Failed to execute set query.');
return;
}
} else {
error('Failed to execute append query.');
return;
}
return;
}
// tfs 0.x
if ($db->hasColumn('accounts', 'premdays')) {
// append premdays
if (query_add_premium('premdays', '`premdays` + :value', '1=1', ['value' => $days])) {
// append lastday
if (query_add_premium('lastday', '`lastday` + :value', '`lastday` > :now', ['value' => $value, 'now' => $now])) {
// set lastday
if (query_add_premium('lastday', ':value', '`lastday` <= :now', ['value' => $now + $value, 'now' => $now])) {
success($days . ' premium days added to all accounts.');
return;
} else {
error('Failed to execute set query.');
return;
}
success($days . ' premium days added to all accounts.');
return;
} else {
error('Failed to execute append query.');
return;
}
} else {
error('Failed to execute set days query.');
return;
}
return;
}
// tfs 1.x
if ($db->hasColumn('accounts', 'premium_ends_at')) {
// append premium_ends_at
if (query_add_premium('premium_ends_at', '`premium_ends_at` + :value', '`premium_ends_at` > :now', ['value' => $value, 'now' => $now])) {
// set premium_ends_at
if (query_add_premium('premium_ends_at', ':value', '`premium_ends_at` <= :now', ['value' => $now + $value, 'now' => $now])) {
success($days . ' premium days added to all accounts.');
return;
} else {
error('Failed to execute set query.');
return;
}
} else {
error('Failed to execute append query.');
return;
}
return;
}
error('Premium Days not supported.');
}
if (isset($_POST['action']) && $_POST['action']) {
$action = $_POST['action'];
if (preg_match("/[^A-z0-9_\-]/", $action)) {
error('Invalid action.');
} else {
$value = isset($_POST['value']) ? intval($_POST['value']) : 0;
if (!$value) {
error('Please fill all inputs');
} else {
switch ($action) {
case 'give-points':
admin_give_points($value);
break;
case 'give-coins':
admin_give_coins($value);
break;
case 'give-premdays':
admin_give_premdays($value);
break;
default:
error('Action ' . $action . 'not found.');
}
}
}
}
$twig->display('admin.tools.account.html.twig', array(
'hasCoinsColumn' => $hasCoinsColumn,
'hasPointsColumn' => $hasPointsColumn,
'freePremium' => $freePremium,
));

View File

@@ -0,0 +1,100 @@
<?php
/**
* Teleport Admin Tool
*
* @package MyAAC
* @author Slawkens <slawkens@gmail.com>
* @author Lee
* @copyright 2020 MyAAC
* @link https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Mass Teleport Actions';
function admin_teleport_position($x, $y, $z) {
global $db;
$statement = $db->prepare('UPDATE `players` SET `posx` = :x, `posy` = :y, `posz` = :z');
if (!$statement) {
error('Failed to prepare query statement.');
return;
}
if (!$statement->execute([
'x' => $x, 'y' => $y, 'z' => $z
])) {
error('Failed to execute query.');
return;
}
success('Player\'s position updated.');
}
function admin_teleport_town($town_id) {
global $db;
$statement = $db->prepare('UPDATE `players` SET `town_id` = :town_id');
if (!$statement) {
error('Failed to prepare query statement.');
return;
}
if (!$statement->execute([
'town_id' => $town_id
])) {
error('Failed to execute query.');
return;
}
success('Player\'s town updated.');
}
if (isset($_POST['action']) && $_POST['action']) {
$action = $_POST['action'];
if (preg_match("/[^A-z0-9_\-]/", $action)) {
error('Invalid action.');
} else {
$playersOnline = 0;
if($db->hasTable('players_online')) {// tfs 1.0
$playersOnline = $db->query('SELECT count(*) FROM `players_online`');
} else {
$playersOnline = $db->query('SELECT count(*) FROM `players` WHERE `players`.`online` > 0');
}
if ($playersOnline > 0) {
error('Please, close the server before execute this action otherwise players will not be affected.');
return;
}
$town_id = isset($_POST['town_id']) ? intval($_POST['town_id']) : 0;
$posx = isset($_POST['posx']) ? intval($_POST['posx']) : 0;
$posy = isset($_POST['posy']) ? intval($_POST['posy']) : 0;
$posz = isset($_POST['posz']) ? intval($_POST['posz']) : 0;
switch ($action) {
case 'set-town':
if (!isset($config['towns'][$town_id])) {
error('Please fill all inputs');
return;
}
admin_teleport_town($value);
break;
case 'set-position':
if (!$posx || !$posy || !$posz) {
error('Please fill all inputs');
return;
}
admin_teleport_position($posx, $posy, $posz);
break;
default:
error('Action ' . $action . 'not found.');
}
}
}
$twig->display('admin.tools.teleport.html.twig', array());

View File

@@ -145,8 +145,8 @@ class Gallery
$pathinfo = pathinfo($image);
$extension = strtolower($pathinfo['extension']);
$thumb_filename = 'images/gallery/' . $pathinfo['filename'] . '_thumb.' . $extension;
$filename = 'images/gallery/' . $pathinfo['filename'] . '.' . $extension;
$thumb_filename = GALLERY_DIR . $pathinfo['filename'] . '_thumb.' . $extension;
$filename = GALLERY_DIR . $pathinfo['filename'] . '.' . $extension;
if($db->insert(TABLE_PREFIX . 'gallery', array(
'comment' => $comment,
'image' => $filename, 'author' => $author,
@@ -172,7 +172,7 @@ class Gallery
$pathinfo = pathinfo($image);
$extension = strtolower($pathinfo['extension']);
$filename = 'images/gallery/' . $pathinfo['filename'] . '.' . $extension;
$filename = GALLERY_DIR . $pathinfo['filename'] . '.' . $extension;
if($db->update(TABLE_PREFIX . 'gallery', array(
'comment' => $comment,
@@ -291,7 +291,7 @@ class Gallery
{
$pathinfo = pathinfo($file);
$extension = strtolower($pathinfo['extension']);
$thumb_filename = 'images/gallery/' . $pathinfo['filename'] . '_thumb.' . $extension;
$thumb_filename = GALLERY_DIR . $pathinfo['filename'] . '_thumb.' . $extension;
if(!self::resize($file, 170, 110, $thumb_filename, $errors))
return false;

View File

@@ -46,7 +46,7 @@ if(empty($errors)) {
$allowed_ext = array('image/gif', 'image/jpg', 'image/pjpeg', 'image/jpeg', 'image/bmp', 'image/png', 'image/x-png');
$ext_name = array('image/gif' => 'gif', 'image/jpg' => 'jpg', 'image/jpeg' => 'jpg', 'image/pjpeg' => 'jpg', 'image/bmp' => 'bmp', 'image/png' => 'png', 'image/x-png' => 'png');
$save_file_name = str_replace(' ', '_', strtolower($guild->getName()));
$save_path = 'images/guilds/' . $save_file_name;
$save_path = GUILD_IMAGES_DIR . $save_file_name;
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save')
{
$file = $_FILES['newlogo'];
@@ -76,12 +76,12 @@ if(empty($errors)) {
{
$guild_logo = $guild->getCustomField('logo_name');
$guild_logo = str_replace(array('..', '/', '\\'), array('','',''), $guild->getCustomField('logo_name'));
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo)) {
if(empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo)) {
$guild_logo = "default.gif";
}
if($guild_logo != "default.gif" && $guild_logo != $save_file_name.'.'.$extension) {
unlink('images/guilds/' . $guild_logo);
unlink(GUILD_IMAGES_DIR . $guild_logo);
}
}
@@ -96,7 +96,7 @@ if(empty($errors)) {
}
$guild_logo = $guild->getCustomField('logo_name');
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo)) {
if(empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo)) {
$guild_logo = "default.gif";
}

View File

@@ -21,7 +21,7 @@ if(count($guilds_list) > 0)
{
foreach ($guilds_list as $guild) {
$guild_logo = $guild->getCustomField('logo_name');
if (empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo))
if (empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo))
$guild_logo = "default.gif";
$description = $guild->getCustomField('description');
@@ -38,4 +38,4 @@ $twig->display('guilds.list.html.twig', array(
'guilds' => $guilds,
'logged' => isset($logged) ? $logged : false,
'isAdmin' => admin(),
));
));

View File

@@ -80,7 +80,7 @@ if($logged)
//show guild page
$guild_logo = $guild->getCustomField('logo_name');
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo))
if(empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo))
$guild_logo = "default.gif";
$description = $guild->getCustomField('description');