mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 01:34:55 +02:00
Merge branch 'develop' into feature/cronjob
This commit is contained in:
@@ -1,206 +0,0 @@
|
||||
<?php
|
||||
namespace MyAAC;
|
||||
|
||||
$loader = new \MyAAC\Psr4AutoloaderClass;
|
||||
|
||||
// register the autoloader
|
||||
$loader->register();
|
||||
|
||||
// register the base directories for the namespace prefix
|
||||
$loader->addNamespace('Composer\Semver', LIBS . 'semver');
|
||||
$loader->addNamespace('Twig', LIBS . 'Twig');
|
||||
/**
|
||||
* An example of a general-purpose implementation that includes the optional
|
||||
* functionality of allowing multiple base directories for a single namespace
|
||||
* prefix.
|
||||
*
|
||||
* Given a foo-bar package of classes in the file system at the following
|
||||
* paths ...
|
||||
*
|
||||
* /path/to/packages/foo-bar/
|
||||
* src/
|
||||
* Baz.php # Foo\Bar\Baz
|
||||
* Qux/
|
||||
* Quux.php # Foo\Bar\Qux\Quux
|
||||
* tests/
|
||||
* BazTest.php # Foo\Bar\BazTest
|
||||
* Qux/
|
||||
* QuuxTest.php # Foo\Bar\Qux\QuuxTest
|
||||
*
|
||||
* ... add the path to the class files for the \Foo\Bar\ namespace prefix
|
||||
* as follows:
|
||||
*
|
||||
* <?php
|
||||
* // instantiate the loader
|
||||
* $loader = new \Example\Psr4AutoloaderClass;
|
||||
*
|
||||
* // register the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // register the base directories for the namespace prefix
|
||||
* $loader->addNamespace('Foo\Bar', '/path/to/packages/foo-bar/src');
|
||||
* $loader->addNamespace('Foo\Bar', '/path/to/packages/foo-bar/tests');
|
||||
*
|
||||
* The following line would cause the autoloader to attempt to load the
|
||||
* \Foo\Bar\Qux\Quux class from /path/to/packages/foo-bar/src/Qux/Quux.php:
|
||||
*
|
||||
* <?php
|
||||
* new \Foo\Bar\Qux\Quux;
|
||||
*
|
||||
* The following line would cause the autoloader to attempt to load the
|
||||
* \Foo\Bar\Qux\QuuxTest class from /path/to/packages/foo-bar/tests/Qux/QuuxTest.php:
|
||||
*
|
||||
* <?php
|
||||
* new \Foo\Bar\Qux\QuuxTest;
|
||||
*/
|
||||
class Psr4AutoloaderClass
|
||||
{
|
||||
/**
|
||||
* An associative array where the key is a namespace prefix and the value
|
||||
* is an array of base directories for classes in that namespace.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $prefixes = array();
|
||||
|
||||
/**
|
||||
* Register loader with SPL autoloader stack.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a base directory for a namespace prefix.
|
||||
*
|
||||
* @param string $prefix The namespace prefix.
|
||||
* @param string $base_dir A base directory for class files in the
|
||||
* namespace.
|
||||
* @param bool $prepend If true, prepend the base directory to the stack
|
||||
* instead of appending it; this causes it to be searched first rather
|
||||
* than last.
|
||||
* @return void
|
||||
*/
|
||||
public function addNamespace($prefix, $base_dir, $prepend = false)
|
||||
{
|
||||
// normalize namespace prefix
|
||||
$prefix = trim($prefix, '\\') . '\\';
|
||||
|
||||
// normalize the base directory with a trailing separator
|
||||
$base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR) . '/';
|
||||
|
||||
// initialize the namespace prefix array
|
||||
if (isset($this->prefixes[$prefix]) === false) {
|
||||
$this->prefixes[$prefix] = array();
|
||||
}
|
||||
|
||||
// retain the base directory for the namespace prefix
|
||||
if ($prepend) {
|
||||
array_unshift($this->prefixes[$prefix], $base_dir);
|
||||
} else {
|
||||
array_push($this->prefixes[$prefix], $base_dir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the class file for a given class name.
|
||||
*
|
||||
* @param string $class The fully-qualified class name.
|
||||
* @return mixed The mapped file name on success, or boolean false on
|
||||
* failure.
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if (0 === strpos($class, 'Twig_')) {
|
||||
$file = LIBS . 'Twig/' . str_replace(array('_', "\0"), array('/', ''), $class).'.php';
|
||||
|
||||
if((config('env') === 'dev') && !is_file($file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require $file;
|
||||
return false;
|
||||
}
|
||||
|
||||
// the current namespace prefix
|
||||
$prefix = $class;
|
||||
|
||||
// work backwards through the namespace names of the fully-qualified
|
||||
// class name to find a mapped file name
|
||||
while (false !== $pos = strrpos($prefix, '\\')) {
|
||||
|
||||
// retain the trailing namespace separator in the prefix
|
||||
$prefix = substr($class, 0, $pos + 1);
|
||||
|
||||
// the rest is the relative class name
|
||||
$relative_class = substr($class, $pos + 1);
|
||||
|
||||
// try to load a mapped file for the prefix and relative class
|
||||
$mapped_file = $this->loadMappedFile($prefix, $relative_class);
|
||||
if ($mapped_file) {
|
||||
return $mapped_file;
|
||||
}
|
||||
|
||||
// remove the trailing namespace separator for the next iteration
|
||||
// of strrpos()
|
||||
$prefix = rtrim($prefix, '\\');
|
||||
}
|
||||
|
||||
// never found a mapped file
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the mapped file for a namespace prefix and relative class.
|
||||
*
|
||||
* @param string $prefix The namespace prefix.
|
||||
* @param string $relative_class The relative class name.
|
||||
* @return mixed Boolean false if no mapped file can be loaded, or the
|
||||
* name of the mapped file that was loaded.
|
||||
*/
|
||||
protected function loadMappedFile($prefix, $relative_class)
|
||||
{
|
||||
// are there any base directories for this namespace prefix?
|
||||
if (isset($this->prefixes[$prefix]) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// look through base directories for this namespace prefix
|
||||
foreach ($this->prefixes[$prefix] as $base_dir) {
|
||||
|
||||
// replace the namespace prefix with the base directory,
|
||||
// replace namespace separators with directory separators
|
||||
// in the relative class name, append with .php
|
||||
$file = $base_dir
|
||||
. str_replace('\\', '/', $relative_class)
|
||||
. '.php';
|
||||
|
||||
// if the mapped file exists, require it
|
||||
if ($this->requireFile($file)) {
|
||||
// yes, we're done
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// never found it
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a file exists, require it from the file system.
|
||||
*
|
||||
* @param string $file The file to require.
|
||||
* @return bool True if the file exists, false if not.
|
||||
*/
|
||||
protected function requireFile($file)
|
||||
{
|
||||
if (config('env') !== 'dev' || file_exists($file)) {
|
||||
require $file;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -9,7 +9,30 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Player extends OTS_Player {}
|
||||
class Guild extends OTS_Guild {}
|
||||
class Account extends OTS_Account {
|
||||
public function loadById($id) {
|
||||
$this->load($id);
|
||||
}
|
||||
public function loadByName($name) {
|
||||
$this->find($name);
|
||||
}
|
||||
}
|
||||
|
||||
class Player extends OTS_Player {
|
||||
public function loadById($id) {
|
||||
$this->load($id);
|
||||
}
|
||||
public function loadByName($name) {
|
||||
$this->find($name);
|
||||
}
|
||||
}
|
||||
class Guild extends OTS_Guild {
|
||||
public function loadById($id) {
|
||||
$this->load($id);
|
||||
}
|
||||
public function loadByName($name) {
|
||||
$this->find($name);
|
||||
}
|
||||
}
|
||||
class GuildRank extends OTS_GuildRank {}
|
||||
class House extends OTS_House {}
|
||||
|
118
system/compat/config.php
Normal file
118
system/compat/config.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
$deprecatedConfig = [
|
||||
'date_timezone',
|
||||
'genders',
|
||||
'template',
|
||||
'template_allow_change',
|
||||
'vocations_amount',
|
||||
'vocations',
|
||||
'client',
|
||||
'session_prefix',
|
||||
'friendly_urls',
|
||||
'backward_support',
|
||||
'charset',
|
||||
'meta_description',
|
||||
'meta_keywords',
|
||||
'footer',
|
||||
'database_encryption' => 'database_hash',
|
||||
//'language',
|
||||
'visitors_counter',
|
||||
'visitors_counter_ttl',
|
||||
'views_counter',
|
||||
'outfit_images_url',
|
||||
'outfit_images_wrong_looktypes',
|
||||
'item_images_url',
|
||||
'account_country',
|
||||
'towns',
|
||||
'quests',
|
||||
'character_samples',
|
||||
'character_towns',
|
||||
'characters_per_account',
|
||||
'characters_search_limit',
|
||||
'news_author',
|
||||
'news_limit',
|
||||
'news_ticker_limit',
|
||||
'news_date_format',
|
||||
'guild_management',
|
||||
'guild_need_level',
|
||||
'guild_need_premium',
|
||||
'guild_image_size_kb',
|
||||
'guild_description_default',
|
||||
'guild_description_chars_limit',
|
||||
'guild_motd_chars_limit',
|
||||
'highscores_groups_hidden',
|
||||
'highscores_ids_hidden',
|
||||
'highscores_vocation_box',
|
||||
'highscores_vocation',
|
||||
'highscores_outfit',
|
||||
'online_record',
|
||||
'online_vocations',
|
||||
'online_vocations_images',
|
||||
'online_skulls',
|
||||
'online_outfit',
|
||||
'online_afk',
|
||||
'team_display_outfit' => 'team_outfit',
|
||||
'team_display_status' => 'team_status',
|
||||
'team_display_world' => 'team_world',
|
||||
'team_display_lastlogin' => 'team_lastlogin',
|
||||
'last_kills_limit',
|
||||
'multiworld',
|
||||
'forum',
|
||||
'signature_enabled',
|
||||
'signature_type',
|
||||
'signature_cache_time',
|
||||
'signature_browser_cache',
|
||||
'gifts_system',
|
||||
'status_enabled',
|
||||
'status_ip',
|
||||
'status_port',
|
||||
'mail_enabled',
|
||||
'mail_address',
|
||||
'account_login_by_email',
|
||||
'account_login_by_email_fallback',
|
||||
'account_mail_verify',
|
||||
'account_mail_unique',
|
||||
'account_mail_change',
|
||||
'account_premium_days',
|
||||
'account_premium_points',
|
||||
'account_create_character_create',
|
||||
'account_change_character_name',
|
||||
'account_change_character_name_points' => 'account_change_character_name_price',
|
||||
'account_change_character_sex',
|
||||
'account_change_character_sex_points' => 'account_change_character_name_price',
|
||||
];
|
||||
|
||||
foreach ($deprecatedConfig as $key => $value) {
|
||||
config(
|
||||
[
|
||||
(is_string($key) ? $key : $value),
|
||||
setting('core.'.$value)
|
||||
]
|
||||
);
|
||||
|
||||
//var_dump($settings['core.'.$value]['value']);
|
||||
}
|
||||
|
||||
$deprecatedConfigCharacters = [
|
||||
'level',
|
||||
'experience',
|
||||
'magic_level',
|
||||
'balance',
|
||||
'marriage_info' => 'marriage',
|
||||
'outfit',
|
||||
'creation_date',
|
||||
'quests',
|
||||
'skills',
|
||||
'equipment',
|
||||
'frags',
|
||||
'deleted',
|
||||
];
|
||||
|
||||
$tmp = [];
|
||||
foreach ($deprecatedConfigCharacters as $key => $value) {
|
||||
$tmp[(is_string($key) ? $key : $value)] = setting('core.characters_'.$value);
|
||||
}
|
||||
|
||||
config(['characters', $tmp]);
|
||||
unset($tmp);
|
@@ -10,6 +10,10 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
switch($page)
|
||||
{
|
||||
case 'adminpanel':
|
||||
header('Location: ' . ADMIN_URL);
|
||||
die;
|
||||
|
||||
case 'createaccount':
|
||||
$page = 'account/create';
|
||||
break;
|
||||
@@ -30,6 +34,7 @@ switch($page)
|
||||
$page = 'news';
|
||||
break;
|
||||
|
||||
case 'archive':
|
||||
case 'newsarchive':
|
||||
$page = 'news/archive';
|
||||
break;
|
||||
|
@@ -51,4 +51,3 @@ else
|
||||
updateDatabaseConfig('views_counter', $views_counter); // update counter
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -7,9 +7,16 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(!isset($config['database_user'][0], $config['database_password'][0], $config['database_name'][0]))
|
||||
if (!isset($config['database_overwrite'])) {
|
||||
$config['database_overwrite'] = false;
|
||||
}
|
||||
|
||||
if(!$config['database_overwrite'] && !isset($config['database_user'][0], $config['database_password'][0], $config['database_name'][0]))
|
||||
{
|
||||
if(isset($config['lua']['sqlType'])) {// tfs 0.3
|
||||
if(isset($config['lua']['mysqlHost'])) {// tfs 0.2
|
||||
@@ -87,21 +94,34 @@ if(!isset($config['database_socket'])) {
|
||||
$config['database_socket'] = '';
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$ots->connect(array(
|
||||
'host' => $config['database_host'],
|
||||
'user' => $config['database_user'],
|
||||
'password' => $config['database_password'],
|
||||
'database' => $config['database_name'],
|
||||
'log' => $config['database_log'],
|
||||
'socket' => @$config['database_socket'],
|
||||
'persistent' => @$config['database_persistent']
|
||||
)
|
||||
);
|
||||
'host' => $config['database_host'],
|
||||
'user' => $config['database_user'],
|
||||
'password' => $config['database_password'],
|
||||
'database' => $config['database_name'],
|
||||
'log' => $config['database_log'],
|
||||
'socket' => @$config['database_socket'],
|
||||
'persistent' => @$config['database_persistent']
|
||||
));
|
||||
|
||||
$db = POT::getInstance()->getDBHandle();
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
$capsule = new Capsule;
|
||||
$capsule->addConnection([
|
||||
'driver' => 'mysql',
|
||||
'database' => $config['database_name'],
|
||||
]);
|
||||
|
||||
$capsule->getConnection()->setPdo($db);
|
||||
$capsule->getConnection()->setReadPdo($db);
|
||||
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
|
||||
$eloquentConnection = $capsule->getConnection();
|
||||
|
||||
} catch (Exception $e) {
|
||||
if(isset($cache) && $cache->enabled()) {
|
||||
$cache->delete('config_lua');
|
||||
}
|
||||
@@ -115,5 +135,5 @@ catch(PDOException $error) {
|
||||
'<ul>' .
|
||||
'<li>MySQL is not configured propertly in <i>config.lua</i>.</li>' .
|
||||
'<li>MySQL server is not running.</li>' .
|
||||
'</ul>' . $error->getMessage());
|
||||
}
|
||||
'</ul>' . $e->getMessage());
|
||||
}
|
||||
|
@@ -1,4 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception handler
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2023 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
if (class_exists(\Whoops\Run::class)) {
|
||||
$whoops = new \Whoops\Run;
|
||||
if(IS_CLI) {
|
||||
$whoops->pushHandler(new \Whoops\Handler\PlainTextHandler);
|
||||
}
|
||||
else {
|
||||
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
|
||||
}
|
||||
|
||||
$whoops->register();
|
||||
return;
|
||||
}
|
||||
|
||||
require LIBS . 'SensitiveException.php';
|
||||
|
||||
@@ -23,6 +44,8 @@ function exception_handler($exception) {
|
||||
|
||||
$backtrace_formatted = nl2br($exception->getTraceAsString());
|
||||
|
||||
$message = $message . "<br/><br/>File: {$exception->getFile()}<br/>Line: {$exception->getLine()}";
|
||||
|
||||
// display basic error message without template
|
||||
// template is missing, why? probably someone deleted templates dir, or it wasn't downloaded right
|
||||
$template_file = SYSTEM . 'templates/exception.html.twig';
|
||||
|
@@ -7,12 +7,16 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
use MyAAC\Models\Config;
|
||||
use MyAAC\Models\Guild;
|
||||
use MyAAC\Models\House;
|
||||
use MyAAC\Models\Pages;
|
||||
use MyAAC\Models\Player;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use Twig\Loader\ArrayLoader as Twig_ArrayLoader;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
function message($message, $type, $return)
|
||||
{
|
||||
if(IS_CLI) {
|
||||
@@ -33,55 +37,49 @@ function message($message, $type, $return)
|
||||
return true;
|
||||
}
|
||||
function success($message, $return = false) {
|
||||
return message($message, 'success', $return);
|
||||
return message($message, 'success', $return);
|
||||
}
|
||||
function warning($message, $return = false) {
|
||||
return message($message, 'warning', $return);
|
||||
return message($message, 'warning', $return);
|
||||
}
|
||||
function note($message, $return = false) {
|
||||
return message($message, 'note', $return);
|
||||
return message($message, 'note', $return);
|
||||
}
|
||||
function error($message, $return = false) {
|
||||
return message($message, ((defined('MYAAC_INSTALL') || defined('MYAAC_ADMIN')) ? 'danger' : 'error'), $return);
|
||||
return message($message, ((defined('MYAAC_INSTALL') || defined('MYAAC_ADMIN')) ? 'danger' : 'error'), $return);
|
||||
}
|
||||
|
||||
function longToIp($ip)
|
||||
function longToIp($ip): string
|
||||
{
|
||||
$exp = explode(".", long2ip($ip));
|
||||
return $exp[3].".".$exp[2].".".$exp[1].".".$exp[0];
|
||||
}
|
||||
|
||||
function generateLink($url, $name, $blank = false) {
|
||||
function generateLink($url, $name, $blank = false): string {
|
||||
return '<a href="' . $url . '"' . ($blank ? ' target="_blank"' : '') . '>' . $name . '</a>';
|
||||
}
|
||||
|
||||
function getFullLink($page, $name, $blank = false) {
|
||||
function getFullLink($page, $name, $blank = false): string {
|
||||
return generateLink(getLink($page), $name, $blank);
|
||||
}
|
||||
|
||||
function getLink($page, $action = null)
|
||||
{
|
||||
global $config;
|
||||
return BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . $page . ($action ? '/' . $action : '');
|
||||
function getLink($page, $action = null): string {
|
||||
return BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . $page . ($action ? '/' . $action : '');
|
||||
}
|
||||
function internalLayoutLink($page, $action = null) {return getLink($page, $action);}
|
||||
|
||||
function getForumThreadLink($thread_id, $page = NULL)
|
||||
{
|
||||
global $config;
|
||||
return BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : '');
|
||||
function internalLayoutLink($page, $action = null): string {
|
||||
return getLink($page, $action);
|
||||
}
|
||||
|
||||
function getForumBoardLink($board_id, $page = NULL)
|
||||
{
|
||||
global $config;
|
||||
return BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
|
||||
function getForumThreadLink($thread_id, $page = NULL): string {
|
||||
return BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : '');
|
||||
}
|
||||
|
||||
function getPlayerLink($name, $generate = true)
|
||||
{
|
||||
global $config;
|
||||
function getForumBoardLink($board_id, $page = NULL): string {
|
||||
return BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
|
||||
}
|
||||
|
||||
function getPlayerLink($name, $generate = true): string
|
||||
{
|
||||
if(is_numeric($name))
|
||||
{
|
||||
$player = new OTS_Player();
|
||||
@@ -90,53 +88,45 @@ function getPlayerLink($name, $generate = true)
|
||||
$name = $player->getName();
|
||||
}
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'characters/' . urlencode($name);
|
||||
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'characters/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
}
|
||||
|
||||
function getMonsterLink($name, $generate = true)
|
||||
function getMonsterLink($name, $generate = true): string
|
||||
{
|
||||
global $config;
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'creatures/' . urlencode($name);
|
||||
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'creatures/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
}
|
||||
|
||||
function getHouseLink($name, $generate = true)
|
||||
function getHouseLink($name, $generate = true): string
|
||||
{
|
||||
global $db, $config;
|
||||
|
||||
if(is_numeric($name))
|
||||
{
|
||||
$house = $db->query(
|
||||
'SELECT `name` FROM `houses` WHERE `id` = ' . (int)$name);
|
||||
if($house->rowCount() > 0)
|
||||
$name = $house->fetchColumn();
|
||||
$house = House::find(intval($name), ['name']);
|
||||
if ($house) {
|
||||
$name = $house->name;
|
||||
}
|
||||
}
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'houses/' . urlencode($name);
|
||||
|
||||
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'houses/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
}
|
||||
|
||||
function getGuildLink($name, $generate = true)
|
||||
function getGuildLink($name, $generate = true): string
|
||||
{
|
||||
global $db, $config;
|
||||
|
||||
if(is_numeric($name))
|
||||
{
|
||||
$guild = $db->query(
|
||||
'SELECT `name` FROM `guilds` WHERE `id` = ' . (int)$name);
|
||||
if($guild->rowCount() > 0)
|
||||
$name = $guild->fetchColumn();
|
||||
if(is_numeric($name)) {
|
||||
$guild = Guild::find(intval($name), ['name']);
|
||||
$name = $guild->name ?? 'Unknown';
|
||||
}
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'guilds/' . urlencode($name);
|
||||
$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'guilds/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
@@ -161,8 +151,7 @@ function getItemImage($id, $count = 1)
|
||||
if($count > 1)
|
||||
$file_name .= '-' . $count;
|
||||
|
||||
global $config;
|
||||
return '<img src="' . $config['item_images_url'] . $file_name . config('item_images_extension') . '"' . $tooltip . ' width="32" height="32" border="0" alt="' .$id . '" />';
|
||||
return '<img src="' . setting('core.item_images_url') . $file_name . setting('core.item_images_extension') . '"' . $tooltip . ' width="32" height="32" border="0" alt="' .$id . '" />';
|
||||
}
|
||||
|
||||
function getItemRarity($chance) {
|
||||
@@ -182,7 +171,7 @@ function getItemRarity($chance) {
|
||||
return '';
|
||||
}
|
||||
|
||||
function getFlagImage($country)
|
||||
function getFlagImage($country): string
|
||||
{
|
||||
if(!isset($country[0]))
|
||||
return '';
|
||||
@@ -204,7 +193,7 @@ function getFlagImage($country)
|
||||
* @param mixed $v Variable to check.
|
||||
* @return bool Value boolean status.
|
||||
*/
|
||||
function getBoolean($v)
|
||||
function getBoolean($v): bool
|
||||
{
|
||||
if(is_bool($v)) {
|
||||
return $v;
|
||||
@@ -227,7 +216,7 @@ function getBoolean($v)
|
||||
* @param bool $special Should special characters by used?
|
||||
* @return string Generated string.
|
||||
*/
|
||||
function generateRandomString($length, $lowCase = true, $upCase = false, $numeric = false, $special = false)
|
||||
function generateRandomString($length, $lowCase = true, $upCase = false, $numeric = false, $special = false): string
|
||||
{
|
||||
$characters = '';
|
||||
if($lowCase)
|
||||
@@ -284,13 +273,12 @@ function getForumBoards()
|
||||
*/
|
||||
function fetchDatabaseConfig($name, &$value)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db->query('SELECT `value` FROM `' . TABLE_PREFIX . 'config` WHERE `name` = ' . $db->quote($name));
|
||||
if($query->rowCount() <= 0)
|
||||
$config = Config::select('value')->where('name', '=', $name)->first();
|
||||
if (!$config) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$value = $query->fetchColumn();
|
||||
$value = $config->value;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -315,8 +303,7 @@ function getDatabaseConfig($name)
|
||||
*/
|
||||
function registerDatabaseConfig($name, $value)
|
||||
{
|
||||
global $db;
|
||||
$db->insert(TABLE_PREFIX . 'config', array('name' => $name, 'value' => $value));
|
||||
Config::create(compact('name', 'value'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,8 +314,9 @@ function registerDatabaseConfig($name, $value)
|
||||
*/
|
||||
function updateDatabaseConfig($name, $value)
|
||||
{
|
||||
global $db;
|
||||
$db->update(TABLE_PREFIX . 'config', array('value' => $value), array('name' => $name));
|
||||
Config::where('name', '=', $name)->update([
|
||||
'value' => $value
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,47 +343,55 @@ function encrypt($str)
|
||||
//delete player with name
|
||||
function delete_player($name)
|
||||
{
|
||||
global $db;
|
||||
$player = new OTS_Player();
|
||||
$player->find($name);
|
||||
if($player->isLoaded()) {
|
||||
try { $db->exec("DELETE FROM player_skills WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM guild_invites WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_items WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_depotitems WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_spells WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_storage WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_viplist WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_deaths WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
try { $db->exec("DELETE FROM player_deaths WHERE killed_by = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
$rank = $player->getRank();
|
||||
if($rank->isLoaded()) {
|
||||
$guild = $rank->getGuild();
|
||||
if($guild->getOwner()->getId() == $player->getId()) {
|
||||
$rank_list = $guild->getGuildRanksList();
|
||||
if(count($rank_list) > 0) {
|
||||
$rank_list->orderBy('level');
|
||||
foreach($rank_list as $rank_in_guild) {
|
||||
$players_with_rank = $rank_in_guild->getPlayersList();
|
||||
$players_with_rank->orderBy('name');
|
||||
$players_with_rank_number = count($players_with_rank);
|
||||
if($players_with_rank_number > 0) {
|
||||
foreach($players_with_rank as $player_in_guild) {
|
||||
$player_in_guild->setRank();
|
||||
$player_in_guild->save();
|
||||
}
|
||||
}
|
||||
$rank_in_guild->delete();
|
||||
}
|
||||
$guild->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
$player->delete();
|
||||
return true;
|
||||
// DB::beginTransaction();
|
||||
global $capsule;
|
||||
$player = Player::where(compact('name'))->first();
|
||||
if (!$player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
// global $db;
|
||||
// $player = new OTS_Player();
|
||||
// $player->find($name);
|
||||
// if($player->isLoaded()) {
|
||||
// try { $db->exec("DELETE FROM player_skills WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
// try { $db->exec("DELETE FROM guild_invites WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
// try { $db->exec("DELETE FROM player_items WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
// try { $db->exec("DELETE FROM player_depotitems WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
// try { $db->exec("DELETE FROM player_spells WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
// try { $db->exec("DELETE FROM player_storage WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
// try { $db->exec("DELETE FROM player_viplist WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
// try { $db->exec("DELETE FROM player_deaths WHERE player_id = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
// try { $db->exec("DELETE FROM player_deaths WHERE killed_by = '".$player->getId()."';"); } catch(PDOException $error) {}
|
||||
// $rank = $player->getRank();
|
||||
// if($rank->isLoaded()) {
|
||||
// $guild = $rank->getGuild();
|
||||
// if($guild->getOwner()->getId() == $player->getId()) {
|
||||
// $rank_list = $guild->getGuildRanksList();
|
||||
// if(count($rank_list) > 0) {
|
||||
// $rank_list->orderBy('level');
|
||||
// foreach($rank_list as $rank_in_guild) {
|
||||
// $players_with_rank = $rank_in_guild->getPlayersList();
|
||||
// $players_with_rank->orderBy('name');
|
||||
// $players_with_rank_number = count($players_with_rank);
|
||||
// if($players_with_rank_number > 0) {
|
||||
// foreach($players_with_rank as $player_in_guild) {
|
||||
// $player_in_guild->setRank();
|
||||
// $player_in_guild->save();
|
||||
// }
|
||||
// }
|
||||
// $rank_in_guild->delete();
|
||||
// }
|
||||
// $guild->delete();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// $player->delete();
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// return false;
|
||||
}
|
||||
|
||||
//delete guild with id
|
||||
@@ -467,7 +463,7 @@ function tickers()
|
||||
* Types: head_start, head_end, body_start, body_end, center_top
|
||||
*
|
||||
*/
|
||||
function template_place_holder($type)
|
||||
function template_place_holder($type): string
|
||||
{
|
||||
global $twig, $template_place_holders;
|
||||
$ret = '';
|
||||
@@ -491,10 +487,10 @@ function template_place_holder($type)
|
||||
/**
|
||||
* Returns <head> content to be used by templates.
|
||||
*/
|
||||
function template_header($is_admin = false)
|
||||
function template_header($is_admin = false): string
|
||||
{
|
||||
global $title_full, $config, $twig;
|
||||
$charset = isset($config['charset']) ? $config['charset'] : 'utf-8';
|
||||
global $title_full, $twig;
|
||||
$charset = setting('core.charset') ?? 'utf-8';
|
||||
|
||||
return $twig->render('templates.header.html.twig',
|
||||
[
|
||||
@@ -508,29 +504,32 @@ function template_header($is_admin = false)
|
||||
/**
|
||||
* Returns footer content to be used by templates.
|
||||
*/
|
||||
function template_footer()
|
||||
function template_footer(): string
|
||||
{
|
||||
global $config, $views_counter;
|
||||
global $views_counter;
|
||||
$ret = '';
|
||||
if(admin())
|
||||
if(admin()) {
|
||||
$ret .= generateLink(ADMIN_URL, 'Admin Panel', true);
|
||||
}
|
||||
|
||||
if($config['visitors_counter'])
|
||||
{
|
||||
if(setting('core.visitors_counter')) {
|
||||
global $visitors;
|
||||
$amount = $visitors->getAmountVisitors();
|
||||
$ret .= '<br/>Currently there ' . ($amount > 1 ? 'are' : 'is') . ' ' . $amount . ' visitor' . ($amount > 1 ? 's' : '') . '.';
|
||||
}
|
||||
|
||||
if($config['views_counter'])
|
||||
if(setting('core.views_counter')) {
|
||||
$ret .= '<br/>Page has been viewed ' . $views_counter . ' times.';
|
||||
}
|
||||
|
||||
if(config('footer_show_load_time')) {
|
||||
if(setting('core.footer_load_time')) {
|
||||
$ret .= '<br/>Load time: ' . round(microtime(true) - START_TIME, 4) . ' seconds.';
|
||||
}
|
||||
|
||||
if(isset($config['footer'][0]))
|
||||
$ret .= '<br/>' . $config['footer'];
|
||||
$settingFooter = setting('core.footer');
|
||||
if(isset($settingFooter[0])) {
|
||||
$ret .= '<br/>' . $settingFooter;
|
||||
}
|
||||
|
||||
// please respect my work and help spreading the word, thanks!
|
||||
return $ret . '<br/>' . base64_decode('UG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vbXktYWFjLm9yZyIgdGFyZ2V0PSJfYmxhbmsiPk15QUFDLjwvYT4=');
|
||||
@@ -538,8 +537,8 @@ function template_footer()
|
||||
|
||||
function template_ga_code()
|
||||
{
|
||||
global $config, $twig;
|
||||
if(!isset($config['google_analytics_id'][0]))
|
||||
global $twig;
|
||||
if(!isset(setting('core.google_analytics_id')[0]))
|
||||
return '';
|
||||
|
||||
return $twig->render('google_analytics.html.twig');
|
||||
@@ -756,10 +755,10 @@ function get_browser_languages()
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$acceptLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
if(!isset($acceptLang[0]))
|
||||
if(empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))
|
||||
return $ret;
|
||||
|
||||
$acceptLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
$languages = strtolower($acceptLang);
|
||||
// $languages = 'pl,en-us;q=0.7,en;q=0.3 ';
|
||||
// need to remove spaces from strings to avoid error
|
||||
@@ -792,16 +791,21 @@ function get_templates()
|
||||
* Generates list of installed plugins
|
||||
* @return array $plugins
|
||||
*/
|
||||
function get_plugins()
|
||||
function get_plugins($disabled = false): array
|
||||
{
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
|
||||
$path = PLUGINS;
|
||||
foreach(scandir($path, 0) as $file) {
|
||||
foreach(scandir($path, SCANDIR_SORT_ASCENDING) as $file) {
|
||||
$file_ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||
$file_name = pathinfo($file, PATHINFO_FILENAME);
|
||||
if ($file === '.' || $file === '..' || $file === 'disabled' || $file === 'example.json' || $file_ext !== 'json' || is_dir($path . $file))
|
||||
if ($file === '.' || $file === '..' || $file === 'example.json' || $file_ext !== 'json' || is_dir($path . $file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$disabled && strpos($file, 'disabled.') !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ret[] = str_replace('.json', '', $file_name);
|
||||
}
|
||||
@@ -819,7 +823,7 @@ function getWorldName($id)
|
||||
|
||||
/**
|
||||
* Mailing users.
|
||||
* $config['mail_enabled'] have to be enabled.
|
||||
* Mailing has to be enabled in settings (in Admin Panel).
|
||||
*
|
||||
* @param string $to Recipient email address.
|
||||
* @param string $subject Subject of the message.
|
||||
@@ -831,8 +835,9 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
|
||||
{
|
||||
global $mailer, $config;
|
||||
|
||||
if (!config('mail_enabled')) {
|
||||
log_append('mailer-error.log', '_mail() function has been used, but config.mail_enabled is disabled.');
|
||||
if (!setting('core.mail_enabled')) {
|
||||
log_append('mailer-error.log', '_mail() function has been used, but Mail Support is disabled.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$mailer)
|
||||
@@ -844,47 +849,60 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
|
||||
$mailer->clearAllRecipients();
|
||||
}
|
||||
|
||||
$signature_html = '';
|
||||
if(isset($config['mail_signature']['html']))
|
||||
$signature_html = $config['mail_signature']['html'];
|
||||
|
||||
$signature_html = setting('core.mail_signature_html');
|
||||
if($add_html_tags && isset($body[0]))
|
||||
$tmp_body = '<html><head></head><body>' . $body . '<br/><br/>' . $signature_html . '</body></html>';
|
||||
else
|
||||
$tmp_body = $body . '<br/><br/>' . $signature_html;
|
||||
|
||||
if($config['smtp_enabled'])
|
||||
define('MAIL_MAIL', 0);
|
||||
define('MAIL_SMTP', 1);
|
||||
|
||||
$mailOption = setting('core.mail_option');
|
||||
if($mailOption == MAIL_SMTP)
|
||||
{
|
||||
$mailer->isSMTP();
|
||||
$mailer->Host = $config['smtp_host'];
|
||||
$mailer->Port = (int)$config['smtp_port'];
|
||||
$mailer->SMTPAuth = $config['smtp_auth'];
|
||||
$mailer->Username = $config['smtp_user'];
|
||||
$mailer->Password = $config['smtp_pass'];
|
||||
$mailer->SMTPSecure = isset($config['smtp_secure']) ? $config['smtp_secure'] : '';
|
||||
$mailer->Host = setting('core.smtp_host');
|
||||
$mailer->Port = setting('core.smtp_port');
|
||||
$mailer->SMTPAuth = setting('core.smtp_auth');
|
||||
$mailer->Username = setting('core.smtp_user');
|
||||
$mailer->Password = setting('core.smtp_pass');
|
||||
|
||||
define('SMTP_SECURITY_NONE', 0);
|
||||
define('SMTP_SECURITY_SSL', 1);
|
||||
define('SMTP_SECURITY_TLS', 2);
|
||||
|
||||
$security = setting('core.smtp_security');
|
||||
|
||||
$tmp = '';
|
||||
if ($security === SMTP_SECURITY_SSL) {
|
||||
$tmp = 'ssl';
|
||||
}
|
||||
else if ($security == SMTP_SECURITY_TLS) {
|
||||
$tmp = 'tls';
|
||||
}
|
||||
|
||||
$mailer->SMTPSecure = $tmp;
|
||||
}
|
||||
else {
|
||||
$mailer->isMail();
|
||||
}
|
||||
|
||||
$mailer->isHTML(isset($body[0]) > 0);
|
||||
$mailer->From = $config['mail_address'];
|
||||
$mailer->Sender = $config['mail_address'];
|
||||
$mailer->From = setting('core.mail_address');
|
||||
$mailer->Sender = setting('core.mail_address');
|
||||
$mailer->CharSet = 'utf-8';
|
||||
$mailer->FromName = $config['lua']['serverName'];
|
||||
$mailer->Subject = $subject;
|
||||
$mailer->addAddress($to);
|
||||
$mailer->Body = $tmp_body;
|
||||
|
||||
if(config('smtp_debug')) {
|
||||
if(setting('core.smtp_debug')) {
|
||||
$mailer->SMTPDebug = 2;
|
||||
$mailer->Debugoutput = 'echo';
|
||||
}
|
||||
|
||||
$signature_plain = '';
|
||||
if(isset($config['mail_signature']['plain']))
|
||||
$signature_plain = $config['mail_signature']['plain'];
|
||||
|
||||
$signature_plain = setting('core.mail_signature_plain');
|
||||
if(isset($altBody[0])) {
|
||||
$mailer->AltBody = $altBody . $signature_plain;
|
||||
}
|
||||
@@ -926,8 +944,8 @@ function load_config_lua($filename)
|
||||
$config_file = $filename;
|
||||
if(!@file_exists($config_file))
|
||||
{
|
||||
log_append('error.log', '[load_config_file] Fatal error: Cannot load config.lua (' . $filename . '). Error: ' . print_r(error_get_last(), true));
|
||||
throw new RuntimeException('ERROR: Cannot find ' . $filename . ' file. More info in system/logs/error.log');
|
||||
log_append('error.log', '[load_config_file] Fatal error: Cannot load config.lua (' . $filename . ').');
|
||||
throw new RuntimeException('ERROR: Cannot find ' . $filename . ' file.');
|
||||
}
|
||||
|
||||
$result = array();
|
||||
@@ -1017,14 +1035,14 @@ function get_browser_real_ip() {
|
||||
return '0';
|
||||
}
|
||||
function setSession($key, $data) {
|
||||
$_SESSION[config('session_prefix') . $key] = $data;
|
||||
$_SESSION[setting('core.session_prefix') . $key] = $data;
|
||||
}
|
||||
function getSession($key) {
|
||||
$key = config('session_prefix') . $key;
|
||||
$key = setting('core.session_prefix') . $key;
|
||||
return isset($_SESSION[$key]) ? $_SESSION[$key] : false;
|
||||
}
|
||||
function unsetSession($key) {
|
||||
unset($_SESSION[config('session_prefix') . $key]);
|
||||
unset($_SESSION[setting('core.session_prefix') . $key]);
|
||||
}
|
||||
|
||||
function getTopPlayers($limit = 5) {
|
||||
@@ -1039,26 +1057,38 @@ function getTopPlayers($limit = 5) {
|
||||
}
|
||||
|
||||
if (!isset($players)) {
|
||||
$deleted = 'deleted';
|
||||
if($db->hasColumn('players', 'deletion'))
|
||||
$deleted = 'deletion';
|
||||
$columns = [
|
||||
'id', 'name', 'level', 'vocation', 'experience',
|
||||
'looktype', 'lookhead', 'lookbody', 'looklegs', 'lookfeet'
|
||||
];
|
||||
|
||||
$is_tfs10 = $db->hasTable('players_online');
|
||||
$players = $db->query('SELECT `id`, `name`, `level`, `vocation`, `experience`, `looktype`' . ($db->hasColumn('players', 'lookaddons') ? ', `lookaddons`' : '') . ', `lookhead`, `lookbody`, `looklegs`, `lookfeet`' . ($is_tfs10 ? '' : ', `online`') . ' FROM `players` WHERE `group_id` < ' . config('highscores_groups_hidden') . ' AND `id` NOT IN (' . implode(', ', config('highscores_ids_hidden')) . ') AND `' . $deleted . '` = 0 AND `account_id` != 1 ORDER BY `experience` DESC LIMIT ' . (int)$limit)->fetchAll();
|
||||
|
||||
if($is_tfs10) {
|
||||
foreach($players as &$player) {
|
||||
$query = $db->query('SELECT `player_id` FROM `players_online` WHERE `player_id` = ' . $player['id']);
|
||||
$player['online'] = ($query->rowCount() > 0 ? 1 : 0);
|
||||
}
|
||||
unset($player);
|
||||
if ($db->hasColumn('players', 'lookaddons')) {
|
||||
$columns[] = 'lookaddons';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
foreach($players as &$player) {
|
||||
$player['rank'] = ++$i;
|
||||
if ($db->hasColumn('players', 'online')) {
|
||||
$columns[] = 'online';
|
||||
}
|
||||
unset($player);
|
||||
|
||||
$players = Player::query()
|
||||
->select($columns)
|
||||
->withOnlineStatus()
|
||||
->notDeleted()
|
||||
->where('group_id', '<', setting('core.highscores_groups_hidden'))
|
||||
->whereNotIn('id', setting('core.highscores_ids_hidden'))
|
||||
->where('account_id', '!=', 1)
|
||||
->orderByDesc('experience')
|
||||
->limit($limit)
|
||||
->get()
|
||||
->map(function ($e, $i) {
|
||||
$row = $e->toArray();
|
||||
$row['online'] = $e->online_status;
|
||||
$row['rank'] = $i + 1;
|
||||
|
||||
unset($row['online_table']);
|
||||
|
||||
return $row;
|
||||
})->toArray();
|
||||
|
||||
if($cache->enabled()) {
|
||||
$cache->set('top_' . $limit . '_level', serialize($players), 120);
|
||||
@@ -1097,6 +1127,9 @@ function deleteDirectory($dir, $ignore = array(), $contentOnly = false) {
|
||||
function config($key) {
|
||||
global $config;
|
||||
if (is_array($key)) {
|
||||
if (is_null($key[1])) {
|
||||
unset($config[$key[0]]);
|
||||
}
|
||||
return $config[$key[0]] = $key[1];
|
||||
}
|
||||
|
||||
@@ -1112,6 +1145,21 @@ function configLua($key) {
|
||||
return @$config['lua'][$key];
|
||||
}
|
||||
|
||||
function setting($key)
|
||||
{
|
||||
$settings = Settings::getInstance();
|
||||
|
||||
if (is_array($key)) {
|
||||
if (is_null($key[1])) {
|
||||
unset($settings[$key[0]]);
|
||||
}
|
||||
|
||||
return $settings[$key[0]] = $key[1];
|
||||
}
|
||||
|
||||
return $settings[$key]['value'];
|
||||
}
|
||||
|
||||
function clearCache()
|
||||
{
|
||||
require_once LIBS . 'news.php';
|
||||
@@ -1174,49 +1222,44 @@ function clearCache()
|
||||
return true;
|
||||
}
|
||||
|
||||
function getCustomPageInfo($page)
|
||||
function getCustomPageInfo($name)
|
||||
{
|
||||
global $db, $logged_access;
|
||||
$query =
|
||||
$db->query(
|
||||
'SELECT `id`, `title`, `body`, `php`, `hidden`' .
|
||||
' FROM `' . TABLE_PREFIX . 'pages`' .
|
||||
' WHERE `name` LIKE ' . $db->quote($page) . ' AND `hidden` != 1 AND `access` <= ' . $db->quote($logged_access));
|
||||
if($query->rowCount() > 0) // found page
|
||||
{
|
||||
return $query->fetch(PDO::FETCH_ASSOC);
|
||||
global $logged_access;
|
||||
$page = Pages::isPublic()
|
||||
->where('name', 'LIKE', $name)
|
||||
->where('access', '<=', $logged_access)
|
||||
->first();
|
||||
|
||||
if (!$page) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
return $page->toArray();
|
||||
}
|
||||
function getCustomPage($page, &$success)
|
||||
function getCustomPage($name, &$success): string
|
||||
{
|
||||
global $db, $twig, $title, $ignore, $logged_access;
|
||||
global $twig, $title, $ignore;
|
||||
|
||||
$success = false;
|
||||
$content = '';
|
||||
$query =
|
||||
$db->query(
|
||||
'SELECT `id`, `title`, `body`, `php`, `hidden`' .
|
||||
' FROM `' . TABLE_PREFIX . 'pages`' .
|
||||
' WHERE `name` LIKE ' . $db->quote($page) . ' AND `hidden` != 1 AND `access` <= ' . $db->quote($logged_access));
|
||||
if($query->rowCount() > 0) // found page
|
||||
$page = getCustomPageInfo($name);
|
||||
|
||||
if($page) // found page
|
||||
{
|
||||
$success = $ignore = true;
|
||||
$query = $query->fetch();
|
||||
$title = $query['title'];
|
||||
$title = $page['title'];
|
||||
|
||||
if($query['php'] == '1') // execute it as php code
|
||||
if($page['php'] == '1') // execute it as php code
|
||||
{
|
||||
$tmp = substr($query['body'], 0, 10);
|
||||
$tmp = substr($page['body'], 0, 10);
|
||||
if(($pos = strpos($tmp, '<?php')) !== false) {
|
||||
$tmp = preg_replace('/<\?php/', '', $query['body'], 1);
|
||||
$tmp = preg_replace('/<\?php/', '', $page['body'], 1);
|
||||
}
|
||||
else if(($pos = strpos($tmp, '<?')) !== false) {
|
||||
$tmp = preg_replace('/<\?/', '', $query['body'], 1);
|
||||
$tmp = preg_replace('/<\?/', '', $page['body'], 1);
|
||||
}
|
||||
else
|
||||
$tmp = $query['body'];
|
||||
$tmp = $page['body'];
|
||||
|
||||
$php_errors = array();
|
||||
function error_handler($errno, $errstr) {
|
||||
@@ -1226,7 +1269,7 @@ function getCustomPage($page, &$success)
|
||||
set_error_handler('error_handler');
|
||||
|
||||
global $config;
|
||||
if($config['backward_support']) {
|
||||
if(setting('core.backward_support')) {
|
||||
global $SQL, $main_content, $subtopic;
|
||||
}
|
||||
|
||||
@@ -1244,7 +1287,7 @@ function getCustomPage($page, &$success)
|
||||
$oldLoader = $twig->getLoader();
|
||||
|
||||
$twig_loader_array = new Twig_ArrayLoader(array(
|
||||
'content.html' => $query['body']
|
||||
'content.html' => $page['body']
|
||||
));
|
||||
|
||||
$twig->setLoader($twig_loader_array);
|
||||
@@ -1359,39 +1402,42 @@ function getChangelogWhere($v)
|
||||
|
||||
return 'unknown';
|
||||
}
|
||||
function getPlayerNameByAccount($id)
|
||||
|
||||
function getPlayerNameByAccountId($id)
|
||||
{
|
||||
global $vowels, $ots, $db;
|
||||
if(is_numeric($id))
|
||||
{
|
||||
$player = new OTS_Player();
|
||||
$player->load($id);
|
||||
if($player->isLoaded())
|
||||
return $player->getName();
|
||||
else
|
||||
{
|
||||
$playerQuery = $db->query('SELECT `id` FROM `players` WHERE `account_id` = ' . $id . ' ORDER BY `lastlogin` DESC LIMIT 1;')->fetch();
|
||||
if (!is_numeric($id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$tmp = "*Error*";
|
||||
/*
|
||||
$acco = new OTS_Account();
|
||||
$acco->load($id);
|
||||
if(!$acco->isLoaded())
|
||||
return "Unknown name";
|
||||
|
||||
foreach($acco->getPlayersList() as $p)
|
||||
{
|
||||
$player= new OTS_Player();
|
||||
$player->find($p);*/
|
||||
$player->load($playerQuery['id']);
|
||||
//echo 'id gracza = ' . $p . '<br/>';
|
||||
if($player->isLoaded())
|
||||
$tmp = $player->getName();
|
||||
// break;
|
||||
//}
|
||||
|
||||
return $tmp;
|
||||
$account = \MyAAC\Models\Account::find(intval($id), ['id']);
|
||||
if ($account) {
|
||||
$player = \MyAAC\Models\Player::where('account_id', $account->id)->orderByDesc('lastlogin')->select('name')->first();
|
||||
if (!$player) {
|
||||
return '';
|
||||
}
|
||||
return $player->name;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getPlayerNameByAccount($account) {
|
||||
if (is_numeric($account)) {
|
||||
return getPlayerNameByAccountId($account);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getPlayerNameById($id)
|
||||
{
|
||||
if (!is_numeric($id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$player = \MyAAC\Models\Player::find((int)$id, ['name']);
|
||||
if ($player) {
|
||||
return $player->name;
|
||||
}
|
||||
|
||||
return '';
|
||||
@@ -1399,13 +1445,13 @@ function getPlayerNameByAccount($id)
|
||||
|
||||
function echo_success($message)
|
||||
{
|
||||
echo '<div class="col-12 success mb-2">' . $message . '</div>';
|
||||
echo '<div class="col-12 alert alert-success mb-2">' . $message . '</div>';
|
||||
}
|
||||
|
||||
function echo_error($message)
|
||||
{
|
||||
global $error;
|
||||
echo '<div class="col-12 error mb-2">' . $message . '</div>';
|
||||
echo '<div class="col-12 alert alert-error mb-2">' . $message . '</div>';
|
||||
$error = true;
|
||||
}
|
||||
|
||||
@@ -1480,8 +1526,8 @@ function right($str, $length) {
|
||||
}
|
||||
|
||||
function getCreatureImgPath($creature){
|
||||
$creature_path = config('creatures_images_url');
|
||||
$creature_gfx_name = trim(strtolower($creature)) . config('creatures_images_extension');
|
||||
$creature_path = setting('core.monsters_images_url');
|
||||
$creature_gfx_name = trim(strtolower($creature)) . setting('core.monsters_images_extension');
|
||||
if (!file_exists($creature_path . $creature_gfx_name)) {
|
||||
$creature_gfx_name = str_replace(" ", "", $creature_gfx_name);
|
||||
if (file_exists($creature_path . $creature_gfx_name)) {
|
||||
@@ -1544,6 +1590,40 @@ function escapeHtml($html) {
|
||||
return htmlentities($html, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
|
||||
function getGuildNameById($id)
|
||||
{
|
||||
$guild = Guild::where('id', intval($id))->select('name')->first();
|
||||
if ($guild) {
|
||||
return $guild->name;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getGuildLogoById($id)
|
||||
{
|
||||
$logo = 'default.gif';
|
||||
|
||||
$guild = Guild::where('id', intval($id))->select('logo_name')->first();
|
||||
if ($guild) {
|
||||
$guildLogo = $query->logo_name;
|
||||
|
||||
if (!empty($guildLogo) && file_exists(GUILD_IMAGES_DIR . $guildLogo)) {
|
||||
$logo = $guildLogo;
|
||||
}
|
||||
}
|
||||
|
||||
return BASE_URL . GUILD_IMAGES_DIR . $logo;
|
||||
}
|
||||
|
||||
function displayErrorBoxWithBackButton($errors, $action = null) {
|
||||
global $twig;
|
||||
$twig->display('error_box.html.twig', ['errors' => $errors]);
|
||||
$twig->display('account.back_button.html.twig', [
|
||||
'action' => $action ?: getLink('')
|
||||
]);
|
||||
}
|
||||
|
||||
// validator functions
|
||||
require_once LIBS . 'validator.php';
|
||||
require_once SYSTEM . 'compat/base.php';
|
||||
|
@@ -30,6 +30,7 @@ define('HOOK_CHARACTERS_AFTER_CHARACTERS', ++$i);
|
||||
define('HOOK_LOGIN', ++$i);
|
||||
define('HOOK_LOGIN_ATTEMPT', ++$i);
|
||||
define('HOOK_LOGOUT', ++$i);
|
||||
define('HOOK_ACCOUNT_CHANGE_PASSWORD_POST', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_FORM', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_BOXES', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1', ++$i);
|
||||
@@ -39,6 +40,7 @@ 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_PASSWORD', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_CHARACTER_NAME', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_CHARACTER_NAME', ++$i);
|
||||
@@ -51,6 +53,7 @@ define('HOOK_ACCOUNT_CREATE_POST', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_BEFORE_PAGE', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_BEFORE_ACCOUNT', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_AFTER_ACCOUNT', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_BEFORE_PASSWORD', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_AFTER_PASSWORD', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_AFTER_REMEMBER_ME', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_AFTER_PAGE', ++$i);
|
||||
@@ -64,10 +67,18 @@ define('HOOK_ADMIN_MENU', ++$i);
|
||||
define('HOOK_ADMIN_LOGIN_AFTER_ACCOUNT', ++$i);
|
||||
define('HOOK_ADMIN_LOGIN_AFTER_PASSWORD', ++$i);
|
||||
define('HOOK_ADMIN_LOGIN_AFTER_SIGN_IN', ++$i);
|
||||
define('HOOK_ADMIN_ACCOUNTS_SAVE_POST', ++$i);
|
||||
define('HOOK_ADMIN_SETTINGS_BEFORE_SAVE', ++$i);
|
||||
define('HOOK_CRONJOB', ++$i);
|
||||
define('HOOK_EMAIL_CONFIRMED', ++$i);
|
||||
define('HOOK_GUILDS_BEFORE_GUILD_HEADER', ++$i);
|
||||
define('HOOK_GUILDS_AFTER_GUILD_HEADER', ++$i);
|
||||
define('HOOK_GUILDS_AFTER_GUILD_INFORMATION', ++$i);
|
||||
define('HOOK_GUILDS_AFTER_GUILD_MEMBERS', ++$i);
|
||||
define('HOOK_GUILDS_AFTER_INVITED_CHARACTERS', ++$i);
|
||||
|
||||
const HOOK_FIRST = HOOK_STARTUP;
|
||||
const HOOK_LAST = HOOK_EMAIL_CONFIRMED;
|
||||
define('HOOK_LAST', $i);
|
||||
|
||||
require_once LIBS . 'plugins.php';
|
||||
class Hook
|
||||
@@ -82,15 +93,25 @@ class Hook
|
||||
|
||||
public function execute($params)
|
||||
{
|
||||
extract($params);
|
||||
/*if(is_callable($this->_callback))
|
||||
{
|
||||
$tmp = $this->_callback;
|
||||
$ret = $tmp($params);
|
||||
}*/
|
||||
|
||||
global $db, $config, $template_path, $ots, $content, $twig;
|
||||
$ret = include BASE . $this->_file;
|
||||
|
||||
if(is_callable($this->_file))
|
||||
{
|
||||
$params['db'] = $db;
|
||||
$params['config'] = $config;
|
||||
$params['template_path'] = $template_path;
|
||||
$params['ots'] = $ots;
|
||||
$params['content'] = $content;
|
||||
$params['twig'] = $twig;
|
||||
|
||||
$tmp = $this->_file;
|
||||
$ret = $tmp($params);
|
||||
}
|
||||
else {
|
||||
extract($params);
|
||||
|
||||
$ret = include BASE . $this->_file;
|
||||
}
|
||||
|
||||
return !isset($ret) || $ret == 1 || $ret;
|
||||
}
|
||||
|
@@ -9,22 +9,24 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
// load configuration
|
||||
require_once BASE . 'config.php';
|
||||
if(file_exists(BASE . 'config.local.php')) // user customizations
|
||||
require BASE . 'config.local.php';
|
||||
|
||||
if(!isset($config['installed']) || !$config['installed']) {
|
||||
throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.');
|
||||
}
|
||||
|
||||
date_default_timezone_set($config['date_timezone']);
|
||||
if(config('env') === 'dev') {
|
||||
require SYSTEM . 'exception.php';
|
||||
}
|
||||
|
||||
if(empty($config['server_path'])) {
|
||||
throw new RuntimeException('Server Path has been not set. Go to config.php and set it.');
|
||||
}
|
||||
|
||||
// take care of trailing slash at the end
|
||||
if($config['server_path'][strlen($config['server_path']) - 1] !== '/')
|
||||
$config['server_path'] .= '/';
|
||||
|
||||
// enable gzip compression if supported by the browser
|
||||
if($config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler'))
|
||||
if(isset($config['gzip_output']) && $config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler'))
|
||||
ob_start('ob_gzhandler');
|
||||
|
||||
// cache
|
||||
@@ -92,9 +94,6 @@ if(isset($config['lua']['servername']))
|
||||
if(isset($config['lua']['houserentperiod']))
|
||||
$config['lua']['houseRentPeriod'] = $config['lua']['houserentperiod'];
|
||||
|
||||
if($config['item_images_url'][strlen($config['item_images_url']) - 1] !== '/')
|
||||
$config['item_images_url'] .= '/';
|
||||
|
||||
// localize data/ directory based on data directory set in config.lua
|
||||
foreach(array('dataDirectory', 'data_directory', 'datadir') as $key) {
|
||||
if(!isset($config['lua'][$key][0])) {
|
||||
@@ -118,51 +117,41 @@ if(!isset($foundValue)) {
|
||||
$config['data_path'] = $foundValue;
|
||||
unset($foundValue);
|
||||
|
||||
// new config values for compability
|
||||
if(!isset($config['highscores_ids_hidden']) || count($config['highscores_ids_hidden']) == 0) {
|
||||
$config['highscores_ids_hidden'] = array(0);
|
||||
}
|
||||
|
||||
$config['account_create_character_create'] = config('account_create_character_create') && (!config('mail_enabled') || !config('account_mail_verify'));
|
||||
|
||||
// POT
|
||||
require_once SYSTEM . 'libs/pot/OTS.php';
|
||||
$ots = POT::getInstance();
|
||||
$eloquentConnection = null;
|
||||
require_once SYSTEM . 'database.php';
|
||||
|
||||
// execute migrations
|
||||
require SYSTEM . 'migrate.php';
|
||||
|
||||
// settings
|
||||
require_once LIBS . 'Settings.php';
|
||||
$settings = Settings::getInstance();
|
||||
$settings->load();
|
||||
|
||||
// deprecated config values
|
||||
require_once SYSTEM . 'compat/config.php';
|
||||
|
||||
date_default_timezone_set(setting('core.date_timezone'));
|
||||
|
||||
setting(
|
||||
[
|
||||
'core.account_create_character_create',
|
||||
setting('core.account_create_character_create') && (!setting('core.mail_enabled') || !setting('core.account_mail_verify'))
|
||||
]
|
||||
);
|
||||
|
||||
$settingsItemImagesURL = setting('core.item_images_url');
|
||||
if($settingsItemImagesURL[strlen($settingsItemImagesURL) - 1] !== '/') {
|
||||
setting(['core.item_images_url', $settingsItemImagesURL . '/']);
|
||||
}
|
||||
|
||||
define('USE_ACCOUNT_NAME', $db->hasColumn('accounts', 'name'));
|
||||
define('USE_ACCOUNT_NUMBER', $db->hasColumn('accounts', 'number'));
|
||||
define('USE_ACCOUNT_SALT', $db->hasColumn('accounts', 'salt'));
|
||||
|
||||
// load vocation names
|
||||
$tmp = '';
|
||||
if($cache->enabled() && $cache->fetch('vocations', $tmp)) {
|
||||
$config['vocations'] = unserialize($tmp);
|
||||
}
|
||||
else {
|
||||
if(!class_exists('DOMDocument')) {
|
||||
throw new RuntimeException('Please install PHP xml extension. MyAAC will not work without it.');
|
||||
}
|
||||
|
||||
$vocations = new DOMDocument();
|
||||
$file = $config['data_path'] . 'XML/vocations.xml';
|
||||
if(!@file_exists($file))
|
||||
$file = $config['data_path'] . 'vocations.xml';
|
||||
|
||||
if(!$vocations->load($file))
|
||||
throw new RuntimeException('ERROR: Cannot load <i>vocations.xml</i> - the file is malformed. Check the file with xml syntax validator.');
|
||||
|
||||
$config['vocations'] = array();
|
||||
foreach($vocations->getElementsByTagName('vocation') as $vocation) {
|
||||
$id = $vocation->getAttribute('id');
|
||||
$config['vocations'][$id] = $vocation->getAttribute('name');
|
||||
}
|
||||
|
||||
if($cache->enabled()) {
|
||||
$cache->set('vocations', serialize($config['vocations']), 120);
|
||||
}
|
||||
}
|
||||
unset($tmp, $id, $vocation);
|
||||
|
||||
require LIBS . 'Towns.php';
|
||||
Towns::load();
|
||||
|
@@ -1,61 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Item parser
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
require_once SYSTEM . 'libs/items_images.php';
|
||||
|
||||
Items_Images::$files = array(
|
||||
'otb' => SYSTEM . 'data/items.otb',
|
||||
'spr' => SYSTEM . 'data/Tibia.spr',
|
||||
'dat' => SYSTEM . 'data/Tibia.dat'
|
||||
);
|
||||
Items_Images::$outputDir = BASE . 'images/items/';
|
||||
|
||||
function generateItem($id = 100, $count = 1) {
|
||||
Items_Images::generate($id, $count);
|
||||
}
|
||||
|
||||
function itemImageExists($id, $count = 1)
|
||||
{
|
||||
if(!isset($id))
|
||||
throw new RuntimeException('ERROR - itemImageExists: id has been not set!');
|
||||
|
||||
$file_name = $id;
|
||||
if($count > 1)
|
||||
$file_name .= '-' . $count;
|
||||
|
||||
$file_name = Items_Images::$outputDir . $file_name . '.gif';
|
||||
return file_exists($file_name);
|
||||
}
|
||||
|
||||
function outputItem($id = 100, $count = 1)
|
||||
{
|
||||
if(!(int)$count)
|
||||
$count = 1;
|
||||
|
||||
if(!itemImageExists($id, $count))
|
||||
{
|
||||
//echo 'plik istnieje';
|
||||
Items_Images::generate($id, $count);
|
||||
}
|
||||
|
||||
$expires = 60 * 60 * 24 * 30; // 30 days
|
||||
header('Content-type: image/gif');
|
||||
header('Cache-Control: public');
|
||||
header('Cache-Control: maxage=' . $expires);
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
|
||||
|
||||
$file_name = $id;
|
||||
if($count > 1)
|
||||
$file_name .= '-' . $count;
|
||||
|
||||
$file_name = Items_Images::$outputDir . $file_name . '.gif';
|
||||
readfile($file_name);
|
||||
}
|
||||
?>
|
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use MyAAC\Models\Player;
|
||||
|
||||
/**
|
||||
* CreateCharacter
|
||||
*
|
||||
@@ -18,8 +21,8 @@ class CreateCharacter
|
||||
*/
|
||||
public function checkName($name, &$errors)
|
||||
{
|
||||
$minLength = config('character_name_min_length');
|
||||
$maxLength = config('character_name_max_length');
|
||||
$minLength = setting('core.create_character_name_min_length');
|
||||
$maxLength = setting('core.create_character_name_max_length');
|
||||
|
||||
if(empty($name)) {
|
||||
$errors['name'] = 'Please enter a name for your character!';
|
||||
@@ -52,9 +55,7 @@ class CreateCharacter
|
||||
return false;
|
||||
}
|
||||
|
||||
$player = new OTS_Player();
|
||||
$player->find($name);
|
||||
if($player->isLoaded()) {
|
||||
if(Player::where('name', '=', $name)->exists()) {
|
||||
$errors['name'] = 'Character with this name already exist.';
|
||||
return false;
|
||||
}
|
||||
@@ -138,9 +139,9 @@ class CreateCharacter
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$number_of_players_on_account = $account->getPlayersList(false)->count();
|
||||
if($number_of_players_on_account >= config('characters_per_account'))
|
||||
$errors[] = 'You have too many characters on your account <b>('.$number_of_players_on_account.'/'.config('characters_per_account').')</b>!';
|
||||
$number_of_players_on_account = $account->getPlayersList(true)->count();
|
||||
if($number_of_players_on_account >= setting('core.characters_per_account'))
|
||||
$errors[] = 'You have too many characters on your account <b>('.$number_of_players_on_account . '/' . setting('core.characters_per_account') . ')</b>!';
|
||||
}
|
||||
|
||||
if(empty($errors))
|
||||
@@ -149,7 +150,7 @@ class CreateCharacter
|
||||
$char_to_copy = new OTS_Player();
|
||||
$char_to_copy->find($char_to_copy_name);
|
||||
if(!$char_to_copy->isLoaded())
|
||||
$errors[] = 'Wrong characters configuration. Try again or contact with admin. ADMIN: Edit file config.php and set valid characters to copy names. Character to copy: <b>'.$char_to_copy_name.'</b> doesn\'t exist.';
|
||||
$errors[] = 'Wrong characters configuration. Try again or contact with admin. ADMIN: Go to Admin Panel -> Settings -> Create Character and set valid characters to copy names. Character to copy: <b>'.$char_to_copy_name.'</b> doesn\'t exist.';
|
||||
}
|
||||
|
||||
if(!empty($errors)) {
|
||||
@@ -195,7 +196,7 @@ class CreateCharacter
|
||||
|
||||
for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) {
|
||||
$value = 10;
|
||||
if (config('use_character_sample_skills')) {
|
||||
if (setting('core.use_character_sample_skills')) {
|
||||
$value = $char_to_copy->getSkill($skill);
|
||||
}
|
||||
|
||||
@@ -239,22 +240,24 @@ class CreateCharacter
|
||||
}
|
||||
|
||||
if($db->hasTable('player_skills')) {
|
||||
for($i=0; $i<7; $i++) {
|
||||
for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++) {
|
||||
$value = 10;
|
||||
if (config('use_character_sample_skills')) {
|
||||
$value = $char_to_copy->getSkill($i);
|
||||
if (setting('core.use_character_sample_skills')) {
|
||||
$value = $char_to_copy->getSkill($skill);
|
||||
}
|
||||
$skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $i);
|
||||
$skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $skill);
|
||||
if($skillExists->rowCount() <= 0) {
|
||||
$db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$i.', ' . $value . ', 0)');
|
||||
$db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$skill.', ' . $value . ', 0)');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$loaded_items_to_copy = $db->query("SELECT * FROM player_items WHERE player_id = ".$char_to_copy->getId()."");
|
||||
foreach($loaded_items_to_copy as $save_item) {
|
||||
$blob = $db->quote($save_item['attributes']);
|
||||
$db->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('".$player->getId()."', '".$save_item['pid']."', '".$save_item['sid']."', '".$save_item['itemtype']."', '".$save_item['count']."', $blob);");
|
||||
if ($db->hasTable('player_items') && $db->hasColumn('player_items', 'pid') && $db->hasColumn('player_items', 'sid') && $db->hasColumn('player_items', 'itemtype')) {
|
||||
$loaded_items_to_copy = $db->query("SELECT * FROM player_items WHERE player_id = ".$char_to_copy->getId()."");
|
||||
foreach($loaded_items_to_copy as $save_item) {
|
||||
$blob = $db->quote($save_item['attributes']);
|
||||
$db->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('".$player->getId()."', '".$save_item['pid']."', '".$save_item['sid']."', '".$save_item['itemtype']."', '".$save_item['count']."', $blob);");
|
||||
}
|
||||
}
|
||||
|
||||
global $twig;
|
||||
|
596
system/libs/Settings.php
Normal file
596
system/libs/Settings.php
Normal file
@@ -0,0 +1,596 @@
|
||||
<?php
|
||||
|
||||
use MyAAC\Models\Settings as ModelsSettings;
|
||||
|
||||
/**
|
||||
* CreateCharacter
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2020 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
class Settings implements ArrayAccess
|
||||
{
|
||||
static private $instance;
|
||||
private $settingsFile = [];
|
||||
private $settingsDatabase = [];
|
||||
private $cache = [];
|
||||
private $valuesAsked = [];
|
||||
private $errors = [];
|
||||
|
||||
/**
|
||||
* @return Settings
|
||||
*/
|
||||
public static function getInstance(): Settings
|
||||
{
|
||||
if (!self::$instance) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function load()
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch('settings', $tmp)) {
|
||||
$this->settingsDatabase = unserialize($tmp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$settings = ModelsSettings::all();
|
||||
foreach ($settings as $setting)
|
||||
{
|
||||
$this->settingsDatabase[$setting->name][$setting->key] = $setting->value;
|
||||
}
|
||||
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('settings', serialize($this->settingsDatabase), 600);
|
||||
}
|
||||
}
|
||||
|
||||
public function save($pluginName, $values) {
|
||||
if (!isset($this->settingsFile[$pluginName])) {
|
||||
throw new RuntimeException('Error on save settings: plugin does not exist');
|
||||
}
|
||||
|
||||
$settings = $this->settingsFile[$pluginName];
|
||||
|
||||
global $hooks;
|
||||
if (!$hooks->trigger(HOOK_ADMIN_SETTINGS_BEFORE_SAVE, [
|
||||
'name' => $pluginName,
|
||||
'values' => $values,
|
||||
'settings' => $settings,
|
||||
])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($settings['callbacks']['beforeSave'])) {
|
||||
if (!$settings['callbacks']['beforeSave']($settings, $values)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->errors = [];
|
||||
ModelsSettings::where('name', $pluginName)->delete();
|
||||
foreach ($values as $key => $value) {
|
||||
$errorMessage = '';
|
||||
if (isset($settings['settings'][$key]['callbacks']['beforeSave']) && !$settings['settings'][$key]['callbacks']['beforeSave']($key, $value, $errorMessage)) {
|
||||
$this->errors[] = $errorMessage;
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
ModelsSettings::create([
|
||||
'name' => $pluginName,
|
||||
'key' => $key,
|
||||
'value' => $value
|
||||
]);
|
||||
} catch (PDOException $error) {
|
||||
$this->errors[] = 'Error while saving setting (' . $pluginName . ' - ' . $key . '): ' . $error->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$cache->delete('settings');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function updateInDatabase($pluginName, $key, $value)
|
||||
{
|
||||
ModelsSettings::where(['name' => $pluginName, 'key' => $key])->update(['value' => $value]);
|
||||
}
|
||||
|
||||
public function deleteFromDatabase($pluginName, $key = null)
|
||||
{
|
||||
if (!isset($key)) {
|
||||
ModelsSettings::where('name', $pluginName)->delete();
|
||||
}
|
||||
else {
|
||||
ModelsSettings::where('name', $pluginName)->where('key', $key)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static function display($plugin, $settings): array
|
||||
{
|
||||
$settingsDb = ModelsSettings::where('name', $plugin)->pluck('value', 'key')->toArray();
|
||||
$config = [];
|
||||
require BASE . 'config.local.php';
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
if (is_bool($value)) {
|
||||
$settingsDb[$key] = $value ? 'true' : 'false';
|
||||
}
|
||||
else {
|
||||
$settingsDb[$key] = (string)$value;
|
||||
}
|
||||
}
|
||||
|
||||
$javascript = '';
|
||||
ob_start();
|
||||
?>
|
||||
<ul class="nav nav-tabs" id="myTab">
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach($settings as $setting) {
|
||||
if (isset($setting['script'])) {
|
||||
$javascript .= $setting['script'] . PHP_EOL;
|
||||
}
|
||||
|
||||
if ($setting['type'] === 'category') {
|
||||
?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link<?= ($i === 0 ? ' active' : ''); ?>" id="home-tab-<?= $i++; ?>" data-toggle="tab" href="#tab-<?= str_replace(' ', '', $setting['title']); ?>" type="button"><?= $setting['title']; ?></a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
<div class="tab-content" id="tab-content">
|
||||
<?php
|
||||
|
||||
$checkbox = function ($key, $type, $value) {
|
||||
echo '<label><input type="radio" id="' . $key . '_' . ($type ? 'yes' : 'no') . '" name="settings[' . $key . ']" value="' . ($type ? 'true' : 'false') . '" ' . ($value === $type ? 'checked' : '') . '/>' . ($type ? 'Yes' : 'No') . '</label> ';
|
||||
};
|
||||
|
||||
$i = 0;
|
||||
$j = 0;
|
||||
foreach($settings as $key => $setting) {
|
||||
if ($setting['type'] === 'category') {
|
||||
if ($j++ !== 0) { // close previous category
|
||||
echo '</tbody></table></div>';
|
||||
}
|
||||
?>
|
||||
<div class="tab-pane fade show<?= ($j === 1 ? ' active' : ''); ?>" id="tab-<?= str_replace(' ', '', $setting['title']); ?>">
|
||||
<?php
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($setting['type'] === 'section') {
|
||||
if ($i++ !== 0) { // close previous section
|
||||
echo '</tbody></table>';
|
||||
}
|
||||
?>
|
||||
<h3 id="row_<?= $key ?>" style="text-align: center"><strong><?= $setting['title']; ?></strong></h3>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 13%">Name</th>
|
||||
<th style="width: 30%">Value</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($setting['hidden']) || !$setting['hidden']) {
|
||||
?>
|
||||
<tr id="row_<?= $key ?>">
|
||||
<td><label for="<?= $key ?>" class="control-label"><?= $setting['name'] ?></label></td>
|
||||
<td>
|
||||
<?php
|
||||
}
|
||||
if (isset($setting['hidden']) && $setting['hidden']) {
|
||||
$value = '';
|
||||
if ($setting['type'] === 'boolean') {
|
||||
$value = ($setting['default'] ? 'true' : 'false');
|
||||
}
|
||||
else if (in_array($setting['type'], ['text', 'number', 'email', 'password', 'textarea'])) {
|
||||
$value = $setting['default'];
|
||||
}
|
||||
else if ($setting['type'] === 'options') {
|
||||
$value = $setting['options'][$setting['default']];
|
||||
}
|
||||
|
||||
echo '<input type="hidden" name="settings[' . $key . ']" value="' . $value . '" id="' . $key . '"';
|
||||
}
|
||||
else if ($setting['type'] === 'boolean') {
|
||||
if(isset($settingsDb[$key])) {
|
||||
if($settingsDb[$key] === 'true') {
|
||||
$value = true;
|
||||
}
|
||||
else {
|
||||
$value = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$value = ($setting['default'] ?? false);
|
||||
}
|
||||
|
||||
$checkbox($key, true, $value);
|
||||
$checkbox($key, false, $value);
|
||||
}
|
||||
|
||||
else if (in_array($setting['type'], ['text', 'number', 'email', 'password'])) {
|
||||
if ($setting['type'] === 'number') {
|
||||
$min = (isset($setting['min']) ? ' min="' . $setting['min'] . '"' : '');
|
||||
$max = (isset($setting['max']) ? ' max="' . $setting['max'] . '"' : '');
|
||||
$step = (isset($setting['step']) ? ' step="' . $setting['step'] . '"' : '');
|
||||
}
|
||||
else {
|
||||
$min = $max = $step = '';
|
||||
}
|
||||
|
||||
echo '<input class="form-control" type="' . $setting['type'] . '" name="settings[' . $key . ']" value="' . ($settingsDb[$key] ?? ($setting['default'] ?? '')) . '" id="' . $key . '"' . $min . $max . $step . '/>';
|
||||
}
|
||||
|
||||
else if($setting['type'] === 'textarea') {
|
||||
$value = ($settingsDb[$key] ?? ($setting['default'] ?? ''));
|
||||
$valueWithSpaces = array_map('trim', preg_split('/\r\n|\r|\n/', trim($value)));
|
||||
$rows = count($valueWithSpaces);
|
||||
if ($rows < 2) {
|
||||
$rows = 2; // always min 2 rows for textarea
|
||||
}
|
||||
echo '<textarea class="form-control" rows="' . $rows . '" name="settings[' . $key . ']" id="' . $key . '">' . $value . '</textarea>';
|
||||
}
|
||||
|
||||
else if ($setting['type'] === 'options') {
|
||||
if ($setting['options'] === '$templates') {
|
||||
$templates = [];
|
||||
foreach (get_templates() as $value) {
|
||||
$templates[$value] = $value;
|
||||
}
|
||||
|
||||
$setting['options'] = $templates;
|
||||
}
|
||||
|
||||
else if($setting['options'] === '$clients') {
|
||||
$clients = [];
|
||||
foreach((array)config('clients') as $client) {
|
||||
|
||||
$client_version = (string)($client / 100);
|
||||
if(strpos($client_version, '.') === false)
|
||||
$client_version .= '.0';
|
||||
|
||||
$clients[$client] = $client_version;
|
||||
}
|
||||
|
||||
$setting['options'] = $clients;
|
||||
}
|
||||
else if ($setting['options'] == '$timezones') {
|
||||
$timezones = [];
|
||||
foreach (DateTimeZone::listIdentifiers() as $value) {
|
||||
$timezones[$value] = $value;
|
||||
}
|
||||
|
||||
$setting['options'] = $timezones;
|
||||
}
|
||||
|
||||
else {
|
||||
if (is_string($setting['options'])) {
|
||||
$setting['options'] = explode(',', $setting['options']);
|
||||
foreach ($setting['options'] as &$option) {
|
||||
$option = trim($option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<select class="form-control" name="settings[' . $key . ']" id="' . $key . '">';
|
||||
foreach ($setting['options'] as $value => $option) {
|
||||
$compareTo = ($settingsDb[$key] ?? ($setting['default'] ?? ''));
|
||||
if($value === 'true') {
|
||||
$selected = $compareTo === true;
|
||||
}
|
||||
else if($value === 'false') {
|
||||
$selected = $compareTo === false;
|
||||
}
|
||||
else {
|
||||
$selected = $compareTo == $value;
|
||||
}
|
||||
|
||||
echo '<option value="' . $value . '" ' . ($selected ? 'selected' : '') . '>' . $option . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
}
|
||||
|
||||
if (!isset($setting['hidden']) || !$setting['hidden']) {
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<div class="well setting-default"><?php
|
||||
echo ($setting['desc'] ?? '');
|
||||
echo '<br/>';
|
||||
echo '<strong>Default:</strong> ';
|
||||
|
||||
if ($setting['type'] === 'boolean') {
|
||||
echo ($setting['default'] ? 'Yes' : 'No');
|
||||
}
|
||||
else if (in_array($setting['type'], ['text', 'number', 'email', 'password', 'textarea'])) {
|
||||
echo $setting['default'];
|
||||
}
|
||||
else if ($setting['type'] === 'options') {
|
||||
if (!empty($setting['default'])) {
|
||||
echo $setting['options'][$setting['default']];
|
||||
}
|
||||
}
|
||||
?></div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button name="save" type="submit" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
return ['content' => ob_get_clean(), 'script' => $javascript];
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (is_null($offset)) {
|
||||
throw new \RuntimeException("Settings: You cannot set empty offset with value: $value!");
|
||||
}
|
||||
|
||||
$this->loadPlugin($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
// remove whole plugin settings
|
||||
if (!isset($value)) {
|
||||
$this->offsetUnset($offset);
|
||||
$this->deleteFromDatabase($pluginKeyName, $key);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->settingsDatabase[$pluginKeyName][$key] = $value;
|
||||
$this->updateInDatabase($pluginKeyName, $key, $value);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
$this->loadPlugin($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
// remove specified plugin settings (all)
|
||||
if(is_null($key)) {
|
||||
return isset($this->settingsDatabase[$offset]);
|
||||
}
|
||||
|
||||
return isset($this->settingsDatabase[$pluginKeyName][$key]);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
$this->loadPlugin($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
if (isset($this->cache[$offset])) {
|
||||
unset($this->cache[$offset]);
|
||||
}
|
||||
|
||||
// remove specified plugin settings (all)
|
||||
if(!isset($key)) {
|
||||
unset($this->settingsFile[$pluginKeyName]);
|
||||
unset($this->settingsDatabase[$pluginKeyName]);
|
||||
$this->deleteFromDatabase($pluginKeyName);
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->settingsFile[$pluginKeyName]['settings'][$key]);
|
||||
unset($this->settingsDatabase[$pluginKeyName][$key]);
|
||||
$this->deleteFromDatabase($pluginKeyName, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings
|
||||
* Usage: $setting['plugin_name.key']
|
||||
* Example: $settings['shop_system.paypal_email']
|
||||
*
|
||||
* @param mixed $offset
|
||||
* @return array|mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
// try cache hit
|
||||
if(isset($this->cache[$offset])) {
|
||||
return $this->cache[$offset];
|
||||
}
|
||||
|
||||
$this->loadPlugin($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
// return specified plugin settings (all)
|
||||
if(!isset($key)) {
|
||||
if (!isset($this->settingsFile[$pluginKeyName]['settings'])) {
|
||||
throw new RuntimeException('Unknown plugin settings: ' . $pluginKeyName);
|
||||
}
|
||||
return $this->settingsFile[$pluginKeyName]['settings'];
|
||||
}
|
||||
|
||||
$ret = [];
|
||||
if(isset($this->settingsFile[$pluginKeyName]['settings'][$key])) {
|
||||
$ret = $this->settingsFile[$pluginKeyName]['settings'][$key];
|
||||
}
|
||||
|
||||
if(isset($this->settingsDatabase[$pluginKeyName][$key])) {
|
||||
$value = $this->settingsDatabase[$pluginKeyName][$key];
|
||||
|
||||
$ret['value'] = $value;
|
||||
}
|
||||
else {
|
||||
$ret['value'] = $this->settingsFile[$pluginKeyName]['settings'][$key]['default'];
|
||||
}
|
||||
|
||||
if(isset($ret['type'])) {
|
||||
switch($ret['type']) {
|
||||
case 'boolean':
|
||||
$ret['value'] = getBoolean($ret['value']);
|
||||
break;
|
||||
|
||||
case 'number':
|
||||
if (!isset($ret['step']) || (int)$ret['step'] == 1) {
|
||||
$ret['value'] = (int)$ret['value'];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($ret['callbacks']['get'])) {
|
||||
$ret['value'] = $ret['callbacks']['get']($ret['value']);
|
||||
}
|
||||
|
||||
$this->cache[$offset] = $ret;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function updateValuesAsked($offset)
|
||||
{
|
||||
$pluginKeyName = $offset;
|
||||
if (strpos($offset, '.')) {
|
||||
$explode = explode('.', $offset, 2);
|
||||
|
||||
$pluginKeyName = $explode[0];
|
||||
$key = $explode[1];
|
||||
|
||||
$this->valuesAsked = ['pluginKeyName' => $pluginKeyName, 'key' => $key];
|
||||
}
|
||||
else {
|
||||
$this->valuesAsked = ['pluginKeyName' => $pluginKeyName, 'key' => null];
|
||||
}
|
||||
}
|
||||
|
||||
private function loadPlugin($offset)
|
||||
{
|
||||
$this->updateValuesAsked($offset);
|
||||
|
||||
$pluginKeyName = $this->valuesAsked['pluginKeyName'];
|
||||
$key = $this->valuesAsked['key'];
|
||||
|
||||
if (!isset($this->settingsFile[$pluginKeyName])) {
|
||||
if ($pluginKeyName === 'core') {
|
||||
$settingsFilePath = SYSTEM . 'settings.php';
|
||||
} else {
|
||||
//$pluginSettings = Plugins::getPluginSettings($pluginKeyName);
|
||||
$settings = Plugins::getAllPluginsSettings();
|
||||
if (!isset($settings[$pluginKeyName])) {
|
||||
warning("Setting $pluginKeyName does not exist or does not have settings defined.");
|
||||
return;
|
||||
}
|
||||
|
||||
$settingsFilePath = BASE . $settings[$pluginKeyName]['settingsFilename'];
|
||||
}
|
||||
|
||||
if (!file_exists($settingsFilePath)) {
|
||||
throw new \RuntimeException('Failed to load settings file for plugin: ' . $pluginKeyName);
|
||||
}
|
||||
|
||||
$this->settingsFile[$pluginKeyName] = require $settingsFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
public static function saveConfig($config, $filename, &$content = '')
|
||||
{
|
||||
$content = "<?php" . PHP_EOL .
|
||||
"\$config['installed'] = true;" . PHP_EOL;
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
$content .= "\$config['$key'] = ";
|
||||
$content .= var_export($value, true);
|
||||
$content .= ';' . PHP_EOL;
|
||||
}
|
||||
|
||||
$success = file_put_contents($filename, $content);
|
||||
|
||||
// we saved new config.php, need to revalidate cache (only if opcache is enabled)
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($filename);
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public static function testDatabaseConnection($config): bool
|
||||
{
|
||||
$user = null;
|
||||
$password = null;
|
||||
$dns = [];
|
||||
|
||||
if( isset($config['database_name']) ) {
|
||||
$dns[] = 'dbname=' . $config['database_name'];
|
||||
}
|
||||
|
||||
if( isset($config['database_user']) ) {
|
||||
$user = $config['database_user'];
|
||||
}
|
||||
|
||||
if( isset($config['database_password']) ) {
|
||||
$password = $config['database_password'];
|
||||
}
|
||||
|
||||
if( isset($config['database_host']) ) {
|
||||
$dns[] = 'host=' . $config['database_host'];
|
||||
}
|
||||
|
||||
if( isset($config['database_port']) ) {
|
||||
$dns[] = 'port=' . $config['database_port'];
|
||||
}
|
||||
|
||||
try {
|
||||
$connectionTest = new PDO('mysql:' . implode(';', $dns), $user, $password);
|
||||
$connectionTest->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
error('MySQL connection failed. Settings has been reverted.');
|
||||
error($error->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getErrors() {
|
||||
return $this->errors;
|
||||
}
|
||||
}
|
@@ -23,6 +23,8 @@
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Town;
|
||||
|
||||
/**
|
||||
* Class Towns
|
||||
*/
|
||||
@@ -124,15 +126,6 @@ class Towns
|
||||
*/
|
||||
public static function getFromDatabase()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$query = $db->query('SELECT `id`, `name` FROM `towns`;')->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$towns = [];
|
||||
foreach($query as $town) {
|
||||
$towns[$town['id']] = $town['name'];
|
||||
}
|
||||
|
||||
return $towns;
|
||||
return Town::pluck('name', 'id')->toArray();
|
||||
}
|
||||
}
|
||||
|
@@ -110,4 +110,21 @@ class Cache
|
||||
* @return bool
|
||||
*/
|
||||
public function enabled() {return false;}
|
||||
|
||||
public static function remember($key, $ttl, $callback)
|
||||
{
|
||||
$cache = self::getInstance();
|
||||
if(!$cache->enabled()) {
|
||||
return $callback();
|
||||
}
|
||||
|
||||
$value = null;
|
||||
if ($cache->fetch($key, $value)) {
|
||||
return unserialize($value);
|
||||
}
|
||||
|
||||
$value = $callback();
|
||||
$cache->set($key, serialize($value),$ttl);
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use MyAAC\Models\Changelog as ModelsChangelog;
|
||||
|
||||
class Changelog
|
||||
{
|
||||
static public function verify($body,$date, &$errors)
|
||||
@@ -19,43 +21,61 @@ class Changelog
|
||||
|
||||
static public function add($body, $type, $where, $player_id, $cdate, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(!self::verify($body,$cdate, $errors))
|
||||
return false;
|
||||
|
||||
$db->insert(TABLE_PREFIX . 'changelog', array('body' => $body, 'type' => $type, 'date' => $cdate, 'where' => $where, 'player_id' => isset($player_id) ? $player_id : 0));
|
||||
self::clearCache();
|
||||
return true;
|
||||
$row = new ModelsChangelog;
|
||||
$row->body = $body;
|
||||
$row->type = $type;
|
||||
$row->date = $cdate;
|
||||
$row->where = $where;
|
||||
$row->player_id = $player_id ?? 0;
|
||||
if ($row->save()) {
|
||||
self::clearCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static public function get($id) {
|
||||
global $db;
|
||||
return $db->select(TABLE_PREFIX . 'changelog', array('id' => $id));
|
||||
return ModelsChangelog::find($id);
|
||||
}
|
||||
|
||||
static public function update($id, $body, $type, $where, $player_id, $date, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(!self::verify($body,$date, $errors))
|
||||
return false;
|
||||
|
||||
$db->update(TABLE_PREFIX . 'changelog', array('body' => $body, 'type' => $type, 'where' => $where, 'player_id' => isset($player_id) ? $player_id : 0, 'date' => $date), array('id' => $id));
|
||||
self::clearCache();
|
||||
return true;
|
||||
if (ModelsChangelog::where('id', '=', $id)->update([
|
||||
'body' => $body,
|
||||
'type' => $type,
|
||||
'where' => $where,
|
||||
'player_id' => $player_id ?? 0,
|
||||
'date' => $date
|
||||
])) {
|
||||
self::clearCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static public function delete($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
if($db->select(TABLE_PREFIX . 'changelog', array('id' => $id)) !== false)
|
||||
$db->delete(TABLE_PREFIX . 'changelog', array('id' => $id));
|
||||
else
|
||||
$row = ModelsChangelog::find($id);
|
||||
if ($row) {
|
||||
if (!$row->delete()) {
|
||||
$errors[] = 'Fail during delete Changelog.';
|
||||
}
|
||||
} else {
|
||||
$errors[] = 'Changelog with id ' . $id . ' does not exist.';
|
||||
}
|
||||
else
|
||||
}
|
||||
} else {
|
||||
$errors[] = 'Changelog id not set.';
|
||||
}
|
||||
|
||||
if(count($errors)) {
|
||||
return false;
|
||||
@@ -67,17 +87,18 @@ class Changelog
|
||||
|
||||
static public function toggleHidden($id, &$errors, &$status)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
$query = $db->select(TABLE_PREFIX . 'changelog', array('id' => $id));
|
||||
if($query !== false)
|
||||
{
|
||||
$db->update(TABLE_PREFIX . 'changelog', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
||||
$status = $query['hidden'];
|
||||
}
|
||||
else
|
||||
$row = ModelsChangelog::find($id);
|
||||
if ($row) {
|
||||
$row->hidden = $row->hidden == 1 ? 0 : 1;
|
||||
if (!$row->save()) {
|
||||
$errors[] = 'Fail during toggle hidden Changelog.';
|
||||
}
|
||||
} else {
|
||||
$errors[] = 'Changelog with id ' . $id . ' does not exists.';
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
$errors[] = 'Changelog id not set.';
|
||||
|
@@ -8,6 +8,9 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Monster;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
require_once LIBS . 'items.php';
|
||||
@@ -19,9 +22,9 @@ class Creatures {
|
||||
private static $lastError = '';
|
||||
|
||||
public static function loadFromXML($show = false) {
|
||||
global $db;
|
||||
|
||||
try { $db->exec('DELETE FROM `' . TABLE_PREFIX . 'monsters`;'); } catch(PDOException $error) {}
|
||||
try {
|
||||
Monster::query()->delete();
|
||||
} catch(Exception $error) {}
|
||||
|
||||
if($show) {
|
||||
echo '<h2>Reload monsters.</h2>';
|
||||
@@ -82,6 +85,9 @@ class Creatures {
|
||||
$armor = $monster->getArmor();
|
||||
$defensev = $monster->getDefense();
|
||||
|
||||
//load look
|
||||
$look = $monster->getLook();
|
||||
|
||||
//load monster flags
|
||||
$flags = $monster->getFlags();
|
||||
if(!isset($flags['summonable']))
|
||||
@@ -90,9 +96,9 @@ class Creatures {
|
||||
$flags['convinceable'] = '0';
|
||||
|
||||
if(!isset($flags['pushable']))
|
||||
$flags['pushable'] = '0';
|
||||
$flags['pushable'] = '0';
|
||||
if(!isset($flags['canpushitems']))
|
||||
$flags['canpushitems'] = '0';
|
||||
$flags['canpushitems'] = '0';
|
||||
if(!isset($flags['canpushcreatures']))
|
||||
$flags['canpushcreatures'] = '0';
|
||||
if(!isset($flags['runonhealth']))
|
||||
@@ -109,7 +115,7 @@ class Creatures {
|
||||
$flags['attackable'] = '0';
|
||||
if(!isset($flags['rewardboss']))
|
||||
$flags['rewardboss'] = '0';
|
||||
|
||||
|
||||
$summons = $monster->getSummons();
|
||||
$loot = $monster->getLoot();
|
||||
foreach($loot as &$item) {
|
||||
@@ -121,7 +127,7 @@ class Creatures {
|
||||
}
|
||||
if(!in_array($name, $names_added)) {
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'monsters', array(
|
||||
Monster::create(array(
|
||||
'name' => $name,
|
||||
'mana' => empty($mana) ? 0 : $mana,
|
||||
'exp' => $monster->getExperience(),
|
||||
@@ -129,7 +135,7 @@ class Creatures {
|
||||
'speed_lvl' => $speed_lvl,
|
||||
'use_haste' => $use_haste,
|
||||
'voices' => json_encode($monster->getVoices()),
|
||||
'immunities' => json_encode($monster->getImmunities()),
|
||||
'immunities' => json_encode($monster->getImmunities()),
|
||||
'elements' => json_encode($monster->getElements()),
|
||||
'summonable' => $flags['summonable'] > 0 ? 1 : 0,
|
||||
'convinceable' => $flags['convinceable'] > 0 ? 1 : 0,
|
||||
@@ -147,6 +153,7 @@ class Creatures {
|
||||
'armor' => $armor,
|
||||
'race' => $race,
|
||||
'loot' => json_encode($loot),
|
||||
'look' => json_encode($look),
|
||||
'summons' => json_encode($summons)
|
||||
));
|
||||
|
||||
@@ -154,7 +161,7 @@ class Creatures {
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
catch(Exception $error) {
|
||||
if($show) {
|
||||
warning('Error while adding monster (' . $name . '): ' . $error->getMessage());
|
||||
}
|
||||
|
@@ -41,4 +41,3 @@ class Data
|
||||
return $db->update($this->table, $data, $where);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -10,13 +10,13 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$configForumTablePrefix = config('forum_table_prefix');
|
||||
if(null !== $configForumTablePrefix && !empty(trim($configForumTablePrefix))) {
|
||||
if(!in_array($configForumTablePrefix, array('myaac_', 'z_'))) {
|
||||
$settingForumTablePrefix = setting('core.forum_table_prefix');
|
||||
if(null !== $settingForumTablePrefix && !empty(trim($settingForumTablePrefix))) {
|
||||
if(!in_array($settingForumTablePrefix, array('myaac_', 'z_'))) {
|
||||
throw new RuntimeException('Invalid value for forum_table_prefix in config.php. Can be only: "myaac_" or "z_".');
|
||||
}
|
||||
|
||||
define('FORUM_TABLE_PREFIX', $configForumTablePrefix);
|
||||
define('FORUM_TABLE_PREFIX', $settingForumTablePrefix);
|
||||
}
|
||||
else {
|
||||
if($db->hasTable('z_forum')) {
|
||||
@@ -47,7 +47,7 @@ class Forum
|
||||
return
|
||||
$db->query(
|
||||
'SELECT `id` FROM `players` WHERE `account_id` = ' . $db->quote($account->getId()) .
|
||||
' AND `level` >= ' . $db->quote($config['forum_level_required']) .
|
||||
' AND `level` >= ' . $db->quote(setting('core.forum_level_required')) .
|
||||
' LIMIT 1')->rowCount() > 0;
|
||||
}
|
||||
|
||||
|
@@ -78,8 +78,6 @@ class Items
|
||||
}
|
||||
|
||||
public static function getDescription($id, $count = 1) {
|
||||
global $db;
|
||||
|
||||
$item = self::get($id);
|
||||
|
||||
$attr = $item['attributes'];
|
||||
@@ -112,17 +110,15 @@ class Items
|
||||
$s .= 'an item of type ' . $item['id'];
|
||||
|
||||
if(isset($attr['type']) && strtolower($attr['type']) == 'rune') {
|
||||
$query = $db->query('SELECT `level`, `maglevel`, `vocations` FROM `' . TABLE_PREFIX . 'spells` WHERE `item_id` = ' . $id);
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
|
||||
if($query['level'] > 0 && $query['maglevel'] > 0) {
|
||||
$item = Spells::where('item_id', $id)->first();
|
||||
if($item) {
|
||||
if($item->level > 0 && $item->maglevel > 0) {
|
||||
$s .= '. ' . ($count > 1 ? "They" : "It") . ' can only be used by ';
|
||||
}
|
||||
|
||||
$configVocations = config('vocations');
|
||||
if(!empty(trim($query['vocations']))) {
|
||||
$vocations = json_decode($query['vocations']);
|
||||
if(!empty(trim($item->vocations))) {
|
||||
$vocations = json_decode($item->vocations);
|
||||
if(count($vocations) > 0) {
|
||||
foreach($vocations as $voc => $show) {
|
||||
$vocations[$configVocations[$voc]] = $show;
|
||||
|
@@ -1,265 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Items_Images class
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if ( !function_exists( 'stackId' ) )
|
||||
{
|
||||
function stackId( $count )
|
||||
{
|
||||
if ( $count >= 50 )
|
||||
$stack = 8;
|
||||
elseif ( $count >= 25 )
|
||||
$stack = 7;
|
||||
elseif ( $count >= 10 )
|
||||
$stack = 6;
|
||||
elseif ( $count >= 5 )
|
||||
$stack = 5;
|
||||
elseif ( $count >= 4 )
|
||||
$stack = 4;
|
||||
elseif ( $count >= 3 )
|
||||
$stack = 3;
|
||||
elseif ( $count >= 2 )
|
||||
$stack = 2;
|
||||
else
|
||||
$stack = 1;
|
||||
|
||||
return $stack;
|
||||
}
|
||||
}
|
||||
|
||||
class Items_Images
|
||||
{
|
||||
public static $outputDir = '';
|
||||
public static $files = array();
|
||||
|
||||
private static $otb, $dat, $spr;
|
||||
private static $lastItem;
|
||||
private static $loaded = false;
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if(self::$otb)
|
||||
fclose(self::$otb);
|
||||
if(self::$dat)
|
||||
fclose(self::$dat);
|
||||
if(self::$spr)
|
||||
fclose(self::$spr);
|
||||
}
|
||||
|
||||
public static function generate($id = 100, $count = 1)
|
||||
{
|
||||
if(!self::$loaded)
|
||||
self::load();
|
||||
|
||||
$originalId = $id;
|
||||
if($id < 100)
|
||||
return false;
|
||||
//die('ID cannot be lower than 100.');
|
||||
|
||||
rewind(self::$otb);
|
||||
rewind(self::$dat);
|
||||
rewind(self::$spr);
|
||||
|
||||
$nostand = false;
|
||||
$init = false;
|
||||
$originalId = $id;
|
||||
|
||||
// parse info from otb
|
||||
while( false !== ( $char = fgetc( self::$otb ) ) )
|
||||
{
|
||||
$byte = HEX_PREFIX.bin2hex( $char );
|
||||
|
||||
if ( $byte == 0xFE )
|
||||
$init = true;
|
||||
elseif ( $byte == 0x10 and $init ) {
|
||||
extract( unpack( 'x2/Ssid', fread( self::$otb, 4 ) ) );
|
||||
|
||||
if ( $id == $sid ) {
|
||||
if ( HEX_PREFIX.bin2hex( fread( self::$otb, 1 ) ) == 0x11 ) {
|
||||
extract( unpack( 'x2/Sid', fread( self::$otb, 4 ) ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
$init = false;
|
||||
}
|
||||
}
|
||||
|
||||
self::$lastItem = array_sum( unpack( 'x4/S*', fread( self::$dat, 12 )));
|
||||
if($id > self::$lastItem)
|
||||
return false;
|
||||
|
||||
//ini_set('max_execution_time', 300);
|
||||
// parse info from dat
|
||||
for( $i = 100; $i <= $id; $i++ ) {
|
||||
while( ( $byte = HEX_PREFIX.bin2hex( fgetc( self::$dat ) ) ) != 0xFF ) {
|
||||
$offset = 0;
|
||||
switch( $byte ) {
|
||||
case 0x00:
|
||||
case 0x09:
|
||||
case 0x0A:
|
||||
case 0x1A:
|
||||
case 0x1D:
|
||||
case 0x1E:
|
||||
$offset = 2;
|
||||
break;
|
||||
|
||||
case 0x16:
|
||||
case 0x19:
|
||||
$offset = 4;
|
||||
break;
|
||||
|
||||
case 0x01:
|
||||
case 0x02:
|
||||
case 0x03:
|
||||
case 0x04:
|
||||
case 0x05:
|
||||
case 0x06:
|
||||
case 0x07:
|
||||
case 0x08:
|
||||
case 0x0B:
|
||||
case 0x0C:
|
||||
case 0x0D:
|
||||
case 0x0E:
|
||||
case 0x0F:
|
||||
case 0x10:
|
||||
case 0x11:
|
||||
case 0x12:
|
||||
case 0x13:
|
||||
case 0x14:
|
||||
case 0x15:
|
||||
case 0x17:
|
||||
case 0x18:
|
||||
case 0x1B:
|
||||
case 0x1C:
|
||||
case 0x1F:
|
||||
case 0x20:
|
||||
break;
|
||||
|
||||
default:
|
||||
return false; #trigger_error( sprintf( 'Unknown .DAT byte %s (previous byte: %s; address %x)', $byte, $prev, ftell( $dat ), E_USER_ERROR ) );
|
||||
break;
|
||||
}
|
||||
|
||||
$prev = $byte;
|
||||
fseek( self::$dat, $offset, SEEK_CUR );
|
||||
}
|
||||
extract( unpack( 'Cwidth/Cheight', fread( self::$dat, 2 ) ) );
|
||||
|
||||
if ( $width > 1 or $height > 1 ) {
|
||||
fseek( self::$dat, 1, SEEK_CUR );
|
||||
$nostand = true;
|
||||
}
|
||||
|
||||
$sprites_c = array_product( unpack( 'C*', fread( self::$dat, 5 ) ) ) * $width * $height;
|
||||
$sprites = unpack( 'S*', fread( self::$dat, 2 * $sprites_c ) );
|
||||
}
|
||||
|
||||
if ( array_key_exists( stackId( $count ), $sprites ) ) {
|
||||
$sprites = (array) $sprites[stackId( $count )];
|
||||
}
|
||||
else {
|
||||
$sprites = (array) $sprites[array_rand( $sprites ) ];
|
||||
}
|
||||
|
||||
fseek( self::$spr, 6 );
|
||||
|
||||
$sprite = imagecreatetruecolor( 32 * $width, 32 * $height );
|
||||
imagecolortransparent( $sprite, imagecolorallocate( $sprite, 0, 0, 0 ) );
|
||||
|
||||
foreach( $sprites as $key => $value ) {
|
||||
fseek( self::$spr, 6 + ( $value - 1 ) * 4 );
|
||||
extract( unpack( 'Laddress', fread( self::$spr, 4 ) ) );
|
||||
|
||||
fseek( self::$spr, $address + 3 );
|
||||
extract( unpack( 'Ssize', fread( self::$spr, 2 ) ) );
|
||||
|
||||
list( $num, $bit ) = array( 0, 0 );
|
||||
|
||||
while( $bit < $size ) {
|
||||
$pixels = unpack( 'Strans/Scolored', fread( self::$spr, 4 ) );
|
||||
$num += $pixels['trans'];
|
||||
for( $i = 0; $i < $pixels['colored']; $i++ )
|
||||
{
|
||||
extract( unpack( 'Cred/Cgreen/Cblue', fread( self::$spr, 3 ) ) );
|
||||
|
||||
$red = ( $red == 0 ? ( $green == 0 ? ( $blue == 0 ? 1 : $red ) : $red ) : $red );
|
||||
|
||||
imagesetpixel( $sprite,
|
||||
$num % 32 + ( $key % 2 == 1 ? 32 : 0 ),
|
||||
$num / 32 + ( $key % 4 != 1 and $key % 4 != 0 ? 32 : 0 ),
|
||||
imagecolorallocate( $sprite, $red, $green, $blue ) );
|
||||
|
||||
$num++;
|
||||
}
|
||||
|
||||
$bit += 4 + 3 * $pixels['colored'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $count >= 2 ) {
|
||||
if ( $count > 100 )
|
||||
$count = 100;
|
||||
|
||||
$font = 3;
|
||||
$length = imagefontwidth( $font ) * strlen( $count );
|
||||
|
||||
$pos = array(
|
||||
'x' => ( 32 * $width ) - ( $length + 1 ),
|
||||
'y' => ( 32 * $height ) - 13
|
||||
);
|
||||
imagestring( $sprite, $font, $pos['x'] - 1, $pos['y'] - 1, $count, imagecolorallocate( $sprite, 1, 1, 1 ) );
|
||||
imagestring( $sprite, $font, $pos['x'], $pos['y'] - 1, $count, imagecolorallocate( $sprite, 1, 1, 1 ) );
|
||||
imagestring( $sprite, $font, $pos['x'] - 1, $pos['y'], $count, imagecolorallocate( $sprite, 1, 1, 1 ) );
|
||||
|
||||
imagestring( $sprite, $font, $pos['x'], $pos['y'] + 1, $count, imagecolorallocate( $sprite, 1, 1, 1 ) );
|
||||
imagestring( $sprite, $font, $pos['x'] + 1, $pos['y'], $count, imagecolorallocate( $sprite, 1, 1, 1 ) );
|
||||
imagestring( $sprite, $font, $pos['x'] + 1, $pos['y'] + 1, $count, imagecolorallocate( $sprite, 1, 1, 1 ) );
|
||||
|
||||
imagestring( $sprite, $font, $pos['x'], $pos['y'], $count, imagecolorallocate( $sprite, 219, 219, 219 ) );
|
||||
}
|
||||
|
||||
$imagePath = self::$outputDir . ($count > 1 ? $originalId . '-' . $count : $originalId ) . '.gif';
|
||||
|
||||
// save image
|
||||
imagegif($sprite, $imagePath);
|
||||
}
|
||||
|
||||
public static function load()
|
||||
{
|
||||
if(!defined( 'HEX_PREFIX'))
|
||||
define('HEX_PREFIX', '0x');
|
||||
|
||||
self::$otb = fopen(self::$files['otb'], 'rb');
|
||||
self::$dat = fopen(self::$files['dat'], 'rb');
|
||||
self::$spr = fopen(self::$files['spr'], 'rb');
|
||||
|
||||
if(!self::$otb || !self::$dat || !self::$spr)
|
||||
throw new RuntimeException('ERROR: Cannot load data files.');
|
||||
/*
|
||||
if ( $nostand )
|
||||
{
|
||||
for( $i = 0; $i < count( $sprites ) / 4; $i++ )
|
||||
{
|
||||
$sprites = array_merge( (array) $sprites, array_reverse( array_slice( $sprites, $i * 4, 4 ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sprites = (array) $sprites[array_rand( $sprites ) ];
|
||||
}
|
||||
*/
|
||||
|
||||
self::$loaded = true;
|
||||
}
|
||||
|
||||
public static function loaded() {
|
||||
return self::$loaded;
|
||||
}
|
||||
}
|
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use MyAAC\Models\News as ModelsNews;
|
||||
|
||||
class News
|
||||
{
|
||||
static public function verify($title, $body, $article_text, $article_image, &$errors)
|
||||
@@ -29,38 +31,57 @@ class News
|
||||
|
||||
static public function add($title, $body, $type, $category, $player_id, $comments, $article_text, $article_image, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(!self::verify($title, $body, $article_text, $article_image, $errors))
|
||||
return false;
|
||||
|
||||
$db->insert(TABLE_PREFIX . 'news', array('title' => $title, 'body' => $body, 'type' => $type, 'date' => time(), 'category' => $category, 'player_id' => isset($player_id) ? $player_id : 0, 'comments' => $comments, 'article_text' => ($type == 3 ? $article_text : ''), 'article_image' => ($type == 3 ? $article_image : '')));
|
||||
ModelsNews::create([
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
'type' => $type,
|
||||
'date' => time(),
|
||||
'category' => $category,
|
||||
'player_id' => isset($player_id) ? $player_id : 0,
|
||||
'comments' => $comments,
|
||||
'article_text' => ($type == 3 ? $article_text : ''),
|
||||
'article_image' => ($type == 3 ? $article_image : '')
|
||||
]);
|
||||
self::clearCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function get($id) {
|
||||
global $db;
|
||||
return $db->select(TABLE_PREFIX . 'news', array('id' => $id));
|
||||
return ModelsNews::find($id)->toArray();
|
||||
}
|
||||
|
||||
static public function update($id, $title, $body, $type, $category, $player_id, $comments, $article_text, $article_image, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(!self::verify($title, $body, $article_text, $article_image, $errors))
|
||||
return false;
|
||||
|
||||
$db->update(TABLE_PREFIX . 'news', array('title' => $title, 'body' => $body, 'type' => $type, 'category' => $category, 'last_modified_by' => isset($player_id) ? $player_id : 0, 'last_modified_date' => time(), 'comments' => $comments, 'article_text' => $article_text, 'article_image' => $article_image), array('id' => $id));
|
||||
ModelsNews::where('id', $id)->update([
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
'type' => $type,
|
||||
'category' => $category,
|
||||
'last_modified_by' => isset($player_id) ? $player_id : 0,
|
||||
'last_modified_date' => time(),
|
||||
'comments' => $comments,
|
||||
'article_text' => $article_text,
|
||||
'article_image' => $article_image
|
||||
]);
|
||||
self::clearCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
static public function delete($id, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
if($db->select(TABLE_PREFIX . 'news', array('id' => $id)) !== false)
|
||||
$db->delete(TABLE_PREFIX . 'news', array('id' => $id));
|
||||
$row = ModelsNews::find($id);
|
||||
if($row)
|
||||
if (!$row->delete()) {
|
||||
$errors[] = 'Fail during delete News.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'News with id ' . $id . ' does not exists.';
|
||||
}
|
||||
@@ -77,14 +98,16 @@ class News
|
||||
|
||||
static public function toggleHidden($id, &$errors, &$status)
|
||||
{
|
||||
global $db;
|
||||
if(isset($id))
|
||||
{
|
||||
$query = $db->select(TABLE_PREFIX . 'news', array('id' => $id));
|
||||
if($query !== false)
|
||||
$row = ModelsNews::find($id);
|
||||
if($row)
|
||||
{
|
||||
$db->update(TABLE_PREFIX . 'news', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
||||
$status = $query['hidden'];
|
||||
$row->hidden = $row->hidden == 1 ? 0 : 1;
|
||||
if (!$row->save()) {
|
||||
$errors[] = 'Fail during toggle hidden News.';
|
||||
}
|
||||
$status = $row->hidden;
|
||||
}
|
||||
else
|
||||
$errors[] = 'News with id ' . $id . ' does not exists.';
|
||||
|
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
function is_sub_dir($path = NULL, $parent_folder = SITE_PATH) {
|
||||
function is_sub_dir($path = NULL, $parent_folder = BASE) {
|
||||
|
||||
//Get directory path minus last folder
|
||||
$dir = dirname($path);
|
||||
@@ -39,11 +39,12 @@ function is_sub_dir($path = NULL, $parent_folder = SITE_PATH) {
|
||||
}
|
||||
|
||||
use Composer\Semver\Semver;
|
||||
use MyAAC\Models\Menu;
|
||||
|
||||
class Plugins {
|
||||
private static $warnings = array();
|
||||
private static $warnings = [];
|
||||
private static $error = null;
|
||||
private static $plugin_json = array();
|
||||
private static $plugin_json = [];
|
||||
|
||||
public static function getRoutes()
|
||||
{
|
||||
@@ -56,22 +57,8 @@ class Plugins {
|
||||
}
|
||||
|
||||
$routes = [];
|
||||
foreach(get_plugins() as $filename) {
|
||||
$string = file_get_contents(PLUGINS . $filename . '.json');
|
||||
$string = self::removeComments($string);
|
||||
$plugin = json_decode($string, true);
|
||||
self::$plugin_json = $plugin;
|
||||
if ($plugin == null) {
|
||||
self::$warnings[] = 'Cannot load ' . $filename . '.json. File might be not a valid json code.';
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isset($plugin['enabled']) && !getBoolean($plugin['enabled'])) {
|
||||
self::$warnings[] = 'Skipping ' . $filename . '... The plugin is disabled.';
|
||||
continue;
|
||||
}
|
||||
|
||||
$warningPreTitle = 'Plugin: ' . $filename . ' - ';
|
||||
foreach(self::getAllPluginsJson() as $plugin) {
|
||||
$warningPreTitle = 'Plugin: ' . $plugin['name'] . ' - ';
|
||||
|
||||
if (isset($plugin['routes'])) {
|
||||
foreach ($plugin['routes'] as $_name => $info) {
|
||||
@@ -80,7 +67,8 @@ class Plugins {
|
||||
if ($method !== '*') {
|
||||
$methods = is_string($method) ? explode(',', $info['method']) : $method;
|
||||
foreach ($methods as $method) {
|
||||
if (!in_array($method, ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'])) {
|
||||
$method = strtolower($method);
|
||||
if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete', 'head'])) {
|
||||
self::$warnings[] = $warningPreTitle . 'Not allowed method ' . $method . '... Disabling this route...';
|
||||
}
|
||||
}
|
||||
@@ -161,28 +149,18 @@ class Plugins {
|
||||
}
|
||||
|
||||
$hooks = [];
|
||||
foreach(get_plugins() as $filename) {
|
||||
$string = file_get_contents(PLUGINS . $filename . '.json');
|
||||
$string = self::removeComments($string);
|
||||
$plugin = json_decode($string, true);
|
||||
self::$plugin_json = $plugin;
|
||||
if ($plugin == null) {
|
||||
self::$warnings[] = 'Cannot load ' . $filename . '.json. File might be not a valid json code.';
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isset($plugin['enabled']) && !getBoolean($plugin['enabled'])) {
|
||||
self::$warnings[] = 'Skipping ' . $filename . '... The plugin is disabled.';
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach(self::getAllPluginsJson() as $plugin) {
|
||||
if (isset($plugin['hooks'])) {
|
||||
foreach ($plugin['hooks'] as $_name => $info) {
|
||||
if (str_contains($info['type'], 'HOOK_')) {
|
||||
$info['type'] = str_replace('HOOK_', '', $info['type']);
|
||||
}
|
||||
|
||||
if (defined('HOOK_'. $info['type'])) {
|
||||
$hook = constant('HOOK_'. $info['type']);
|
||||
$hooks[] = ['name' => $_name, 'type' => $hook, 'file' => $info['file']];
|
||||
} else {
|
||||
self::$warnings[] = 'Plugin: ' . $filename . '. Unknown event type: ' . $info['type'];
|
||||
self::$warnings[] = 'Plugin: ' . $plugin['name'] . '. Unknown event type: ' . $info['type'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,7 +173,108 @@ class Plugins {
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
public static function install($file) {
|
||||
public static function getAllPluginsSettings()
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch('plugins_settings', $tmp)) {
|
||||
return unserialize($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
$settings = [];
|
||||
foreach (self::getAllPluginsJson() as $plugin) {
|
||||
if (isset($plugin['settings'])) {
|
||||
$settingsFile = require BASE . $plugin['settings'];
|
||||
if (!isset($settingsFile['key'])) {
|
||||
warning("Settings file for plugin - {$plugin['name']} does not contain 'key' field");
|
||||
continue;
|
||||
}
|
||||
|
||||
$settings[$settingsFile['key']] = ['pluginFilename' => $plugin['filename'], 'settingsFilename' => $plugin['settings']];
|
||||
}
|
||||
}
|
||||
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('plugins_settings', serialize($settings), 600); // cache for 10 minutes
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
public static function getAllPluginsJson($disabled = false)
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch('plugins', $tmp)) {
|
||||
return unserialize($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
$plugins = [];
|
||||
foreach (get_plugins($disabled) as $filename) {
|
||||
$plugin = self::getPluginJson($filename);
|
||||
|
||||
if (!$plugin) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$plugin['filename'] = $filename;
|
||||
$plugins[] = $plugin;
|
||||
}
|
||||
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('plugins', serialize($plugins), 600); // cache for 10 minutes
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
public static function getPluginSettings($filename)
|
||||
{
|
||||
$plugin_json = self::getPluginJson($filename);
|
||||
if (!$plugin_json) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($plugin_json['settings']) || !file_exists(BASE . $plugin_json['settings'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $plugin_json['settings'];
|
||||
}
|
||||
|
||||
public static function getPluginJson($filename = null)
|
||||
{
|
||||
if(!isset($filename)) {
|
||||
return self::$plugin_json;
|
||||
}
|
||||
|
||||
$pathToPlugin = PLUGINS . $filename . '.json';
|
||||
if (!file_exists($pathToPlugin)) {
|
||||
self::$warnings[] = "Cannot load $filename.json. File doesn't exist.";
|
||||
return false;
|
||||
}
|
||||
|
||||
$string = file_get_contents($pathToPlugin);
|
||||
$plugin_json = json_decode($string, true);
|
||||
if ($plugin_json == null) {
|
||||
self::$warnings[] = "Cannot load $filename.json. File might be not a valid json code.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($plugin_json['enabled']) && !getBoolean($plugin_json['enabled'])) {
|
||||
self::$warnings[] = 'Skipping ' . $filename . '... The plugin is disabled.';
|
||||
return false;
|
||||
}
|
||||
|
||||
return $plugin_json;
|
||||
}
|
||||
|
||||
public static function install($file): bool
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(!\class_exists('ZipArchive')) {
|
||||
@@ -234,8 +313,13 @@ class Plugins {
|
||||
return false;
|
||||
}
|
||||
|
||||
$pluginFilename = str_replace('.json', '', basename($json_file));
|
||||
if (self::existDisabled($pluginFilename)) {
|
||||
success('The plugin already existed, but was disabled. It has been enabled again and will be now reinstalled.');
|
||||
self::enable($pluginFilename);
|
||||
}
|
||||
|
||||
$string = file_get_contents($file_name);
|
||||
$string = self::removeComments($string);
|
||||
$plugin_json = json_decode($string, true);
|
||||
self::$plugin_json = $plugin_json;
|
||||
if ($plugin_json == null) {
|
||||
@@ -435,7 +519,45 @@ class Plugins {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function uninstall($plugin_name)
|
||||
public static function isEnabled($pluginFileName): bool
|
||||
{
|
||||
$filenameJson = $pluginFileName . '.json';
|
||||
return !is_file(PLUGINS . 'disabled.' . $filenameJson) && is_file(PLUGINS . $filenameJson);
|
||||
}
|
||||
|
||||
public static function existDisabled($pluginFileName): bool
|
||||
{
|
||||
$filenameJson = $pluginFileName . '.json';
|
||||
return is_file(PLUGINS . 'disabled.' . $filenameJson);
|
||||
}
|
||||
|
||||
public static function enable($pluginFileName): bool {
|
||||
return self::enableDisable($pluginFileName, true);
|
||||
}
|
||||
|
||||
public static function disable($pluginFileName): bool {
|
||||
return self::enableDisable($pluginFileName, false);
|
||||
}
|
||||
|
||||
private static function enableDisable($pluginFileName, $enable): bool
|
||||
{
|
||||
$filenameJson = $pluginFileName . '.json';
|
||||
$fileExist = is_file(PLUGINS . ($enable ? 'disabled.' : '') . $filenameJson);
|
||||
if (!$fileExist) {
|
||||
self::$error = 'Cannot ' . ($enable ? 'enable' : 'disable') . ' plugin: ' . $pluginFileName . '. File does not exist.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = rename(PLUGINS . ($enable ? 'disabled.' : '') . $filenameJson, PLUGINS . ($enable ? '' : 'disabled.') . $filenameJson);
|
||||
if (!$result) {
|
||||
self::$error = 'Cannot ' . ($enable ? 'enable' : 'disable') . ' plugin: ' . $pluginFileName . '. Permission problem.';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function uninstall($plugin_name): bool
|
||||
{
|
||||
$filename = BASE . 'plugins/' . $plugin_name . '.json';
|
||||
if(!file_exists($filename)) {
|
||||
@@ -443,9 +565,8 @@ class Plugins {
|
||||
return false;
|
||||
}
|
||||
$string = file_get_contents($filename);
|
||||
$string = self::removeComments($string);
|
||||
$plugin_info = json_decode($string, true);
|
||||
if($plugin_info == false) {
|
||||
if(!$plugin_info) {
|
||||
self::$error = 'Cannot load plugin info ' . $plugin_name . '.json';
|
||||
return false;
|
||||
}
|
||||
@@ -492,7 +613,8 @@ class Plugins {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function is_installed($plugin_name, $version) {
|
||||
public static function is_installed($plugin_name, $version): bool
|
||||
{
|
||||
$filename = BASE . 'plugins/' . $plugin_name . '.json';
|
||||
if(!file_exists($filename)) {
|
||||
return false;
|
||||
@@ -500,7 +622,7 @@ class Plugins {
|
||||
|
||||
$string = file_get_contents($filename);
|
||||
$plugin_info = json_decode($string, true);
|
||||
if($plugin_info == false) {
|
||||
if(!$plugin_info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -523,26 +645,6 @@ class Plugins {
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
public static function getPluginJson() {
|
||||
return self::$plugin_json;
|
||||
}
|
||||
|
||||
public static function removeComments($string) {
|
||||
$string = preg_replace('!/\*.*?\*/!s', '', $string);
|
||||
$string = preg_replace('/\n\s*\n/', "\n", $string);
|
||||
// Removes multi-line comments and does not create
|
||||
// a blank line, also treats white spaces/tabs
|
||||
$string = preg_replace('!^[ \t]*/\*.*?\*/[ \t]*[\r\n]!s', '', $string);
|
||||
|
||||
// Removes single line '//' comments, treats blank characters
|
||||
$string = preg_replace('![ \t]*//.*[ \t]*[\r\n]!', '', $string);
|
||||
|
||||
// Strip blank lines
|
||||
$string = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install menus
|
||||
* Helper function for plugins
|
||||
@@ -552,11 +654,9 @@ class Plugins {
|
||||
*/
|
||||
public static function installMenus($templateName, $categories)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// check if menus already exist
|
||||
$query = $db->query('SELECT `id` FROM `' . TABLE_PREFIX . 'menu` WHERE `template` = ' . $db->quote($templateName) . ' LIMIT 1;');
|
||||
if ($query->rowCount() > 0) {
|
||||
$menuInstalled = Menu::where('template', $templateName)->select('id')->first();
|
||||
if ($menuInstalled) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -590,7 +690,7 @@ class Plugins {
|
||||
'color' => $color,
|
||||
];
|
||||
|
||||
$db->insert(TABLE_PREFIX . 'menu', $insert_array);
|
||||
Menu::create($insert_array);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,5 +32,3 @@ class E_OTS_ErrorCode extends Exception
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -36,5 +36,3 @@ class E_OTS_Generic extends E_OTS_ErrorCode
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -22,5 +22,3 @@ class E_OTS_NotAContainer extends Exception
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -32,5 +32,3 @@ class E_OTS_OTBMError extends E_OTS_ErrorCode
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -22,5 +22,3 @@ class E_OTS_ReadOnly extends Exception
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -37,5 +37,3 @@ interface IOTS_Cipher
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -89,5 +89,3 @@ interface IOTS_DataDisplay
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -96,5 +96,3 @@ interface IOTS_Display
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -67,5 +67,3 @@ interface IOTS_GuildAction
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -21,7 +21,6 @@
|
||||
* @property string $password Password.
|
||||
* @property string $eMail Email address.
|
||||
* @property int $premiumEnd Timestamp of PACC end.
|
||||
* @property bool $blocked Blocked flag state.
|
||||
* @property bool $deleted Deleted flag state.
|
||||
* @property bool $warned Warned flag state.
|
||||
* @property bool $banned Ban state.
|
||||
@@ -39,7 +38,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
* @var array
|
||||
* @version 0.1.5
|
||||
*/
|
||||
private $data = array('email' => '', 'blocked' => false, 'rlname' => '','location' => '', 'country' => '','web_flags' => 0, 'lastday' => 0, 'premdays' => 0, 'created' => 0);
|
||||
private $data = array('email' => '', 'rlname' => '','location' => '', 'country' => '','web_flags' => 0, 'lastday' => 0, 'premdays' => 0, 'created' => 0);
|
||||
|
||||
public static $cache = array();
|
||||
|
||||
@@ -231,26 +230,22 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
* @param int $id Account number.
|
||||
* @throws PDOException On PDO operation error.
|
||||
*/
|
||||
public function load($id, $fresh = false, $searchOnlyById = false)
|
||||
public function load($id, $fresh = false)
|
||||
{
|
||||
if(!$fresh && isset(self::$cache[$id])) {
|
||||
$this->data = self::$cache[$id];
|
||||
return;
|
||||
}
|
||||
|
||||
$numberColumn = 'id';
|
||||
$nameOrNumber = '';
|
||||
if (!$searchOnlyById) {
|
||||
if (USE_ACCOUNT_NAME) {
|
||||
$nameOrNumber = '`name`,';
|
||||
} else if (USE_ACCOUNT_NUMBER) {
|
||||
$nameOrNumber = '`number`,';
|
||||
$numberColumn = 'number';
|
||||
}
|
||||
if (USE_ACCOUNT_NAME) {
|
||||
$nameOrNumber = '`name`,';
|
||||
} else if (USE_ACCOUNT_NUMBER) {
|
||||
$nameOrNumber = '`number`,';
|
||||
}
|
||||
|
||||
// SELECT query on database
|
||||
$this->data = $this->db->query('SELECT `id`, ' . $nameOrNumber . '`password`, `email`, `blocked`, `rlname`, `location`, `country`, `web_flags`, ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays`, ' : '') . ($this->db->hasColumn('accounts', 'lastday') ? '`lastday`, ' : ($this->db->hasColumn('accounts', 'premend') ? '`premend`,' : ($this->db->hasColumn('accounts', 'premium_ends_at') ? '`premium_ends_at`,' : ''))) . '`created` FROM `accounts` WHERE `' . $numberColumn . '` = ' . (int) $id)->fetch();
|
||||
$this->data = $this->db->query('SELECT `id`, ' . $nameOrNumber . '`password`, `email`, `rlname`, `location`, `country`, `web_flags`, ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays`, ' : '') . ($this->db->hasColumn('accounts', 'lastday') ? '`lastday`, ' : ($this->db->hasColumn('accounts', 'premend') ? '`premend`,' : ($this->db->hasColumn('accounts', 'premium_ends_at') ? '`premium_ends_at`,' : ''))) . '`created` FROM `accounts` WHERE `id` = ' . (int) $id)->fetch();
|
||||
self::$cache[$id] = $this->data;
|
||||
}
|
||||
|
||||
@@ -268,8 +263,13 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*/
|
||||
public function find($name)
|
||||
{
|
||||
$nameOrNumberColumn = 'name';
|
||||
if (USE_ACCOUNT_NUMBER) {
|
||||
$nameOrNumberColumn = 'number';
|
||||
}
|
||||
|
||||
// finds player's ID
|
||||
$id = $this->db->query('SELECT `id` FROM `accounts` WHERE `name` = ' . $this->db->quote($name) )->fetch();
|
||||
$id = $this->db->query('SELECT `id` FROM `accounts` WHERE `' . $nameOrNumberColumn . '` = ' . $this->db->quote($name) )->fetch();
|
||||
|
||||
// if anything was found
|
||||
if( isset($id['id']) )
|
||||
@@ -345,7 +345,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
// UPDATE query on database
|
||||
$this->db->exec('UPDATE `accounts` SET ' . ($this->db->hasColumn('accounts', 'name') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `blocked` = ' . (int) $this->data['blocked'] . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `country` = ' . $this->db->quote($this->data['country']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE `accounts` SET ' . ($this->db->hasColumn('accounts', 'name') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `country` = ' . $this->db->quote($this->data['country']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -650,53 +650,6 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$this->data['email'] = (string) $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if account is blocked.
|
||||
*
|
||||
* <p>
|
||||
* Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
|
||||
* </p>
|
||||
*
|
||||
* @version 0.0.3
|
||||
* @return bool Blocked state.
|
||||
* @throws E_OTS_NotLoaded If account is not loaded.
|
||||
*/
|
||||
public function isBlocked()
|
||||
{
|
||||
if( !isset($this->data['blocked']) )
|
||||
{
|
||||
throw new E_OTS_NotLoaded();
|
||||
}
|
||||
|
||||
return $this->data['blocked'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblocks account.
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Account::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*/
|
||||
public function unblock()
|
||||
{
|
||||
$this->data['blocked'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks account.
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in databaseed to use {@link OTS_Account::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*/
|
||||
public function block()
|
||||
{
|
||||
$this->data['blocked'] = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reads custom field.
|
||||
*
|
||||
@@ -1041,7 +994,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$access = 0;
|
||||
|
||||
// finds ranks of all characters
|
||||
foreach($this->getPlayersList() as $player)
|
||||
foreach($this->getPlayersList(false) as $player)
|
||||
{
|
||||
$rank = $player->getRank();
|
||||
|
||||
@@ -1147,9 +1100,6 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
case 'playersList':
|
||||
return $this->getPlayersList();
|
||||
|
||||
case 'blocked':
|
||||
return $this->isBlocked();
|
||||
|
||||
case 'deleted':
|
||||
return $this->isDeleted();
|
||||
|
||||
@@ -1195,17 +1145,6 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$this->setPremiumEnd($value);
|
||||
break;
|
||||
|
||||
case 'blocked':
|
||||
if($value)
|
||||
{
|
||||
$this->block();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->unblock();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'deleted':
|
||||
if($value)
|
||||
{
|
||||
@@ -1259,5 +1198,3 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -34,5 +34,3 @@ class OTS_AccountBans_List extends OTS_Bans_List
|
||||
$this->setFilter($filter);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -735,5 +735,3 @@ class OTS_Admin
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -100,5 +100,3 @@ class OTS_Bans_List extends OTS_Base_List
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -265,5 +265,3 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -146,5 +146,3 @@ class OTS_BinaryTools
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -149,5 +149,3 @@ class OTS_Container extends OTS_Item implements IteratorAggregate
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -357,5 +357,3 @@ class OTS_FileLoader
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -671,5 +671,3 @@ class OTS_Group extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -837,5 +837,3 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -72,5 +72,3 @@ class OTS_GuildRanks_List extends OTS_Base_List
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -529,5 +529,3 @@ class OTS_House extends OTS_Row_DAO
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -34,5 +34,3 @@ class OTS_IPBans_List extends OTS_Bans_List
|
||||
$this->setFilter($filter);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -387,5 +387,3 @@ class OTS_InfoRespond extends DOMDocument
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -676,5 +676,3 @@ class OTS_ItemsList extends OTS_FileLoader implements IteratorAggregate, Countab
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -130,5 +130,3 @@ class OTS_MapCoords
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -36,6 +36,7 @@
|
||||
* @property-read int $armor Armor rate.
|
||||
* @property-read array $defenses List of defenses.
|
||||
* @property-read array $attacks List of attacks.
|
||||
* @property-read array $look List of looks.
|
||||
*/
|
||||
class OTS_Monster extends DOMDocument
|
||||
{
|
||||
@@ -273,6 +274,34 @@ class OTS_Monster extends DOMDocument
|
||||
return $loot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns look of the monster.
|
||||
*
|
||||
* @return array Look with all the attributes of the look.
|
||||
* @throws DOMException On DOM operation error.
|
||||
*/
|
||||
public function getLook()
|
||||
{
|
||||
$look = array();
|
||||
|
||||
$element = $this->documentElement->getElementsByTagName('look')->item(0);
|
||||
|
||||
if (!$element) {
|
||||
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');
|
||||
|
||||
return $look;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all monster summons.
|
||||
*
|
||||
@@ -560,6 +589,9 @@ class OTS_Monster extends DOMDocument
|
||||
case 'attacks':
|
||||
return $this->getAttacks();
|
||||
|
||||
case 'look':
|
||||
return $this->getLook();
|
||||
|
||||
default:
|
||||
throw new OutOfBoundsException();
|
||||
}
|
||||
|
@@ -174,6 +174,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
* @return OTS_Monster Monster.
|
||||
* @throws DOMException On DOM operation error.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return $this->getMonster( key($this->monsters) );
|
||||
@@ -187,7 +188,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
/**
|
||||
* Moves to next iterator monster.
|
||||
*/
|
||||
public function next()
|
||||
public function next(): void
|
||||
{
|
||||
next($this->monsters);
|
||||
}
|
||||
@@ -197,6 +198,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
*
|
||||
* @return string Current position key.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key()
|
||||
{
|
||||
return key($this->monsters);
|
||||
@@ -207,7 +209,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
*
|
||||
* @return bool If iterator has anything more.
|
||||
*/
|
||||
public function valid()
|
||||
public function valid(): bool
|
||||
{
|
||||
return key($this->monsters) !== null;
|
||||
}
|
||||
@@ -215,7 +217,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
/**
|
||||
* Resets iterator index.
|
||||
*/
|
||||
public function rewind()
|
||||
public function rewind(): void
|
||||
{
|
||||
reset($this->monsters);
|
||||
}
|
||||
@@ -226,6 +228,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
* @param string $offset Array key.
|
||||
* @return bool True if it's set.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset($this->monsters[$offset]);
|
||||
@@ -239,6 +242,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
* @return OTS_Monster Monster instance.
|
||||
* @throws DOMException On DOM operation error.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->getMonster($offset);
|
||||
@@ -251,6 +255,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
* @param mixed $value Field value.
|
||||
* @throws E_OTS_ReadOnly Always - this class is read-only.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
throw new E_OTS_ReadOnly();
|
||||
@@ -262,6 +267,7 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
* @param string|int $offset Array key.
|
||||
* @throws E_OTS_ReadOnly Always - this class is read-only.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
throw new E_OTS_ReadOnly();
|
||||
@@ -293,5 +299,3 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -398,7 +398,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
}
|
||||
|
||||
// UPDATE query on database
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('players') . ' SET ' . $this->db->fieldName('name') . ' = ' . $this->db->quote($this->data['name']) . ', ' . $this->db->fieldName('account_id') . ' = ' . $this->data['account_id'] . ', ' . $this->db->fieldName('group_id') . ' = ' . $this->data['group_id'] . ', ' . $this->db->fieldName('sex') . ' = ' . $this->data['sex'] . ', ' . $this->db->fieldName('vocation') . ' = ' . $this->data['vocation'] . ', ' . $this->db->fieldName('experience') . ' = ' . $this->data['experience'] . ', ' . $this->db->fieldName('level') . ' = ' . $this->data['level'] . ', ' . $this->db->fieldName('maglevel') . ' = ' . $this->data['maglevel'] . ', ' . $this->db->fieldName('health') . ' = ' . $this->data['health'] . ', ' . $this->db->fieldName('healthmax') . ' = ' . $this->data['healthmax'] . ', ' . $this->db->fieldName('mana') . ' = ' . $this->data['mana'] . ', ' . $this->db->fieldName('manamax') . ' = ' . $this->data['manamax'] . ', ' . $this->db->fieldName('manaspent') . ' = ' . $this->data['manaspent'] . ', ' . $this->db->fieldName('soul') . ' = ' . $this->data['soul'] . ', ' . $this->db->fieldName('lookbody') . ' = ' . $this->data['lookbody'] . ', ' . $this->db->fieldName('lookfeet') . ' = ' . $this->data['lookfeet'] . ', ' . $this->db->fieldName('lookhead') . ' = ' . $this->data['lookhead'] . ', ' . $this->db->fieldName('looklegs') . ' = ' . $this->data['looklegs'] . ', ' . $this->db->fieldName('looktype') . ' = ' . $this->data['looktype'] . $lookaddons . ', ' . $this->db->fieldName('posx') . ' = ' . $this->data['posx'] . ', ' . $this->db->fieldName('posy') . ' = ' . $this->data['posy'] . ', ' . $this->db->fieldName('posz') . ' = ' . $this->data['posz'] . ', ' . $this->db->fieldName('cap') . ' = ' . $this->data['cap'] . ', ' . $this->db->fieldName('lastlogin') . ' = ' . $this->data['lastlogin'] . ', ' . $this->db->fieldName('lastlogout') . ' = ' . $this->data['lastlogout'] . ', ' . $this->db->fieldName('lastip') . ' = ' . $this->data['lastip'] . ', ' . $this->db->fieldName('save') . ' = ' . (int) $this->data['save'] . ', ' . $this->db->fieldName('conditions') . ' = ' . $this->db->quote($this->data['conditions']) . ', `' . $skull_time . '` = ' . $this->data['skulltime'] . ', `' . $skull_type . '` = ' . (int) $this->data['skull'] . $guild_info . ', ' . $this->db->fieldName('town_id') . ' = ' . $this->data['town_id'] . $loss . $loss_items . ', ' . $this->db->fieldName('balance') . ' = ' . $this->data['balance'] . $blessings . $stamina . $direction . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
$this->db->query('UPDATE ' . $this->db->tableName('players') . ' SET ' . $this->db->fieldName('name') . ' = ' . $this->db->quote($this->data['name']) . ', ' . $this->db->fieldName('account_id') . ' = ' . $this->data['account_id'] . ', ' . $this->db->fieldName('group_id') . ' = ' . $this->data['group_id'] . ', ' . $this->db->fieldName('sex') . ' = ' . $this->data['sex'] . ', ' . $this->db->fieldName('vocation') . ' = ' . $this->data['vocation'] . ', ' . $this->db->fieldName('experience') . ' = ' . $this->data['experience'] . ', ' . $this->db->fieldName('level') . ' = ' . $this->data['level'] . ', ' . $this->db->fieldName('maglevel') . ' = ' . $this->data['maglevel'] . ', ' . $this->db->fieldName('health') . ' = ' . $this->data['health'] . ', ' . $this->db->fieldName('healthmax') . ' = ' . $this->data['healthmax'] . ', ' . $this->db->fieldName('mana') . ' = ' . $this->data['mana'] . ', ' . $this->db->fieldName('manamax') . ' = ' . $this->data['manamax'] . ', ' . $this->db->fieldName('manaspent') . ' = ' . $this->data['manaspent'] . ', ' . $this->db->fieldName('soul') . ' = ' . $this->data['soul'] . ', ' . $this->db->fieldName('lookbody') . ' = ' . $this->data['lookbody'] . ', ' . $this->db->fieldName('lookfeet') . ' = ' . $this->data['lookfeet'] . ', ' . $this->db->fieldName('lookhead') . ' = ' . $this->data['lookhead'] . ', ' . $this->db->fieldName('looklegs') . ' = ' . $this->data['looklegs'] . ', ' . $this->db->fieldName('looktype') . ' = ' . $this->data['looktype'] . $lookaddons . ', ' . $this->db->fieldName('posx') . ' = ' . $this->data['posx'] . ', ' . $this->db->fieldName('posy') . ' = ' . $this->data['posy'] . ', ' . $this->db->fieldName('posz') . ' = ' . $this->data['posz'] . ', ' . $this->db->fieldName('cap') . ' = ' . $this->data['cap'] . ', ' . $this->db->fieldName('lastlogin') . ' = ' . $this->data['lastlogin'] . ', ' . $this->db->fieldName('lastlogout') . ' = ' . $this->data['lastlogout'] . ', ' . $this->db->fieldName('lastip') . ' = ' . $this->db->quote($this->data['lastip']) . ', ' . $this->db->fieldName('save') . ' = ' . (int) $this->data['save'] . ', ' . $this->db->fieldName('conditions') . ' = ' . $this->db->quote($this->data['conditions']) . ', `' . $skull_time . '` = ' . $this->data['skulltime'] . ', `' . $skull_type . '` = ' . (int) $this->data['skull'] . $guild_info . ', ' . $this->db->fieldName('town_id') . ' = ' . $this->data['town_id'] . $loss . $loss_items . ', ' . $this->db->fieldName('balance') . ' = ' . $this->data['balance'] . $blessings . $stamina . $direction . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
|
||||
}
|
||||
// creates new player
|
||||
else
|
||||
@@ -602,7 +602,7 @@ class OTS_Player extends OTS_Row_DAO
|
||||
}
|
||||
|
||||
$account = new OTS_Account();
|
||||
$account->load($this->data['account_id'], false, true);
|
||||
$account->load($this->data['account_id']);
|
||||
return $account;
|
||||
}
|
||||
|
||||
@@ -3627,5 +3627,3 @@ class OTS_Player extends OTS_Row_DAO
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -34,5 +34,3 @@ class OTS_PlayerBans_List extends OTS_Bans_List
|
||||
$this->setFilter($filter);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -75,5 +75,3 @@ abstract class OTS_Row_DAO extends OTS_Base_DAO
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -121,5 +121,3 @@ class OTS_SQLField
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
/**
|
||||
* Various server status querying methods.
|
||||
*
|
||||
*
|
||||
* @package POT
|
||||
* @property-read OTS_InfoRespond|bool $status status() method wrapper.
|
||||
* @property-read OTS_ServerStatus|bool $info Full info() method wrapper.
|
||||
@@ -23,21 +23,21 @@ class OTS_ServerInfo
|
||||
{
|
||||
/**
|
||||
* Server address.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $server;
|
||||
|
||||
/**
|
||||
* Connection port.
|
||||
*
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $port;
|
||||
|
||||
/**
|
||||
* Creates handler for new server.
|
||||
*
|
||||
*
|
||||
* @param string $server Server IP/domain.
|
||||
* @param int $port OTServ port.
|
||||
*/
|
||||
@@ -49,7 +49,7 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Sends packet to server.
|
||||
*
|
||||
*
|
||||
* @param OTS_Buffer|string $packet Buffer to send.
|
||||
* @return OTS_Buffer|null Respond buffer (null if server is offline).
|
||||
* @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
|
||||
@@ -57,7 +57,7 @@ class OTS_ServerInfo
|
||||
private function send(OTS_Buffer $packet)
|
||||
{
|
||||
// connects to server
|
||||
$socket = @fsockopen($this->server, $this->port, $error, $message, config('status_timeout'));
|
||||
$socket = @fsockopen($this->server, $this->port, $error, $message, setting('core.status_timeout'));
|
||||
|
||||
// if connected then checking statistics
|
||||
if($socket)
|
||||
@@ -75,7 +75,7 @@ class OTS_ServerInfo
|
||||
|
||||
// reads respond
|
||||
//$data = stream_get_contents($socket);
|
||||
$data = '';
|
||||
$data = '';
|
||||
while (!feof($socket))
|
||||
$data .= fgets($socket, 1024);
|
||||
|
||||
@@ -97,11 +97,11 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Queries server status.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Sends 'info' packet to OTS server and return output. Returns {@link OTS_InfoRespond OTS_InfoRespond} (wrapper for XML data) with results or <var>false</var> if server is online.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @return OTS_InfoRespond|bool Respond content document (false when server is offline).
|
||||
* @throws DOMException On DOM operation error.
|
||||
* @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
|
||||
@@ -123,7 +123,7 @@ class OTS_ServerInfo
|
||||
{
|
||||
// loads respond XML
|
||||
$info = new OTS_InfoRespond();
|
||||
if(!$info->loadXML( utf8_encode($status->getBuffer())))
|
||||
if(!$info->loadXML( $status->getBuffer()))
|
||||
return false;
|
||||
|
||||
return $info;
|
||||
@@ -135,11 +135,11 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Queries server information.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method uses binary info protocol. It provides more infromation then {@link OTS_Toolbox::serverStatus() XML way}.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param int $flags Requested info flags.
|
||||
* @return OTS_ServerStatus|bool Respond content document (false when server is offline).
|
||||
* @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
|
||||
@@ -169,11 +169,11 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Checks player online status.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* This method uses binary info protocol.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param string $name Player name.
|
||||
* @return bool True if player is online, false if player or server is online.
|
||||
* @throws E_OTS_OutOfBuffer When there is read attemp after end of packet stream.
|
||||
@@ -204,7 +204,7 @@ class OTS_ServerInfo
|
||||
|
||||
/**
|
||||
* Magic PHP5 method.
|
||||
*
|
||||
*
|
||||
* @param string $name Property name.
|
||||
* @param mixed $value Property value.
|
||||
* @throws OutOfBoundsException For non-supported properties.
|
||||
@@ -227,5 +227,3 @@ class OTS_ServerInfo
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -482,5 +482,3 @@ class OTS_Spell
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -308,7 +308,7 @@ class OTS_SpellsList implements IteratorAggregate, Countable
|
||||
* @since 0.1.5
|
||||
* @return AppendIterator Iterator for all spells.
|
||||
*/
|
||||
public function getIterator()
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
$iterator = new AppendIterator();
|
||||
$iterator->append( new ArrayIterator($this->runes) );
|
||||
|
@@ -113,5 +113,3 @@ class OTS_Toolbox
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -151,5 +151,3 @@ class OTS_XTEA implements IOTS_Cipher
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -282,4 +282,3 @@ class TokenAuth6238 {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -8,6 +8,9 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Spell;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Spells {
|
||||
@@ -31,9 +34,11 @@ class Spells {
|
||||
}
|
||||
|
||||
public static function loadFromXML($show = false) {
|
||||
global $config, $db;
|
||||
global $config;
|
||||
|
||||
try { $db->exec('DELETE FROM `' . TABLE_PREFIX . 'spells`;'); } catch(PDOException $error) {}
|
||||
try {
|
||||
Spell::query()->delete();
|
||||
} catch(Exception $error) {}
|
||||
|
||||
if($show) {
|
||||
echo '<h2>Reload spells.</h2>';
|
||||
@@ -63,7 +68,7 @@ class Spells {
|
||||
continue;
|
||||
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
Spell::create(array(
|
||||
'name' => $name,
|
||||
'words' => $words,
|
||||
'type' => 2,
|
||||
@@ -105,7 +110,7 @@ class Spells {
|
||||
continue;
|
||||
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
Spell::create(array(
|
||||
'name' => $name,
|
||||
'words' => $words,
|
||||
'type' => 1,
|
||||
@@ -142,7 +147,7 @@ class Spells {
|
||||
$name = $spell->getName() . ' Rune';
|
||||
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
Spell::create(array(
|
||||
'name' => $name,
|
||||
'words' => $spell->getWords(),
|
||||
'type' => 3,
|
||||
@@ -178,4 +183,4 @@ class Spells {
|
||||
public static function getLastError() {
|
||||
return self::$lastError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -106,8 +106,8 @@ WHERE TABLE_SCHEMA = "' . $config['database_name'] . '";');
|
||||
}
|
||||
$ret['templates'] = get_templates();
|
||||
|
||||
$ret['date_timezone'] = $config['date_timezone'];
|
||||
$ret['backward_support'] = $config['backward_support'];
|
||||
$ret['date_timezone'] = setting('core.date_timezone');
|
||||
$ret['backward_support'] = setting('core.backward_support');
|
||||
|
||||
$cache_engine = strtolower($config['cache_engine']);
|
||||
if($cache_engine == 'auto') {
|
||||
@@ -117,4 +117,4 @@ WHERE TABLE_SCHEMA = "' . $config['database_name'] . '";');
|
||||
$ret['cache_engine'] = $cache_engine;
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,10 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Monster;
|
||||
use MyAAC\Models\Spell;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Validator
|
||||
@@ -117,7 +121,7 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
if(config('account_mail_block_plus_sign')) {
|
||||
if(setting('core.account_mail_block_plus_sign')) {
|
||||
$explode = explode('@', $email);
|
||||
if(isset($explode[0]) && (strpos($explode[0],'+') !== false)) {
|
||||
self::$lastError = 'Please do not use plus (+) sign in your e-mail.';
|
||||
@@ -180,15 +184,16 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
$minLength = config('character_name_min_length');
|
||||
$maxLength = config('character_name_max_length');
|
||||
|
||||
// installer doesn't know config.php yet
|
||||
// that's why we need to ignore the nulls
|
||||
if(is_null($minLength) || is_null($maxLength)) {
|
||||
if(defined('MYAAC_INSTALL')) {
|
||||
$minLength = 4;
|
||||
$maxLength = 21;
|
||||
}
|
||||
else {
|
||||
$minLength = setting('core.create_character_name_min_length');
|
||||
$maxLength = setting('core.create_character_name_max_length');
|
||||
}
|
||||
|
||||
$length = strlen($name);
|
||||
if($length < $minLength)
|
||||
@@ -221,16 +226,6 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
$npcCheck = config('character_name_npc_check');
|
||||
if ($npcCheck) {
|
||||
require_once LIBS . 'npc.php';
|
||||
NPCS::load();
|
||||
if(NPCS::$npcs && in_array(strtolower($name), NPCS::$npcs)) {
|
||||
self::$lastError = "Invalid name format. Do not use NPC Names";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -247,9 +242,8 @@ class Validator
|
||||
|
||||
$name_lower = strtolower($name);
|
||||
|
||||
$first_words_blocked = array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ', "'", '-');
|
||||
foreach($first_words_blocked as $word)
|
||||
{
|
||||
$first_words_blocked = array_merge(["'", '-'], setting('core.create_character_name_blocked_prefix'));
|
||||
foreach($first_words_blocked as $word) {
|
||||
if($word == substr($name_lower, 0, strlen($word))) {
|
||||
self::$lastError = 'Your name contains blocked words.';
|
||||
return false;
|
||||
@@ -271,8 +265,7 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
if(preg_match('/ {2,}/', $name))
|
||||
{
|
||||
if(preg_match('/ {2,}/', $name)) {
|
||||
self::$lastError = 'Invalid character name format. Use only A-Z and numbers 0-9 and no double spaces.';
|
||||
return false;
|
||||
}
|
||||
@@ -282,18 +275,16 @@ class Validator
|
||||
return false;
|
||||
}
|
||||
|
||||
$names_blocked = array('admin', 'administrator', 'gm', 'cm', 'god', 'tutor');
|
||||
foreach($names_blocked as $word)
|
||||
{
|
||||
$names_blocked = setting('core.create_character_name_blocked_names');
|
||||
foreach($names_blocked as $word) {
|
||||
if($word == $name_lower) {
|
||||
self::$lastError = 'Your name contains blocked words.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$words_blocked = array('admin', 'administrator', 'gamemaster', 'game master', 'game-master', "game'master", '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor');
|
||||
foreach($words_blocked as $word)
|
||||
{
|
||||
$words_blocked = array_merge(['--', "''","' ", " '", '- ', ' -', "-'", "'-"], setting('core.create_character_name_blocked_words'));
|
||||
foreach($words_blocked as $word) {
|
||||
if(!(strpos($name_lower, $word) === false)) {
|
||||
self::$lastError = 'Your name contains illegal words.';
|
||||
return false;
|
||||
@@ -309,7 +300,7 @@ class Validator
|
||||
}
|
||||
}
|
||||
|
||||
//check if was namelocked previously
|
||||
// check if was namelocked previously
|
||||
if($db->hasTable('player_namelocks') && $db->hasColumn('player_namelocks', 'name')) {
|
||||
$namelock = $db->query('SELECT `player_id` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name));
|
||||
if($namelock->rowCount() > 0) {
|
||||
@@ -318,39 +309,38 @@ class Validator
|
||||
}
|
||||
}
|
||||
|
||||
$monsters = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'monsters` WHERE `name` LIKE ' . $db->quote($name_lower));
|
||||
if($monsters->rowCount() > 0) {
|
||||
self::$lastError = 'Your name cannot contains monster name.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$spells_name = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'spells` WHERE `name` LIKE ' . $db->quote($name_lower));
|
||||
if($spells_name->rowCount() > 0) {
|
||||
self::$lastError = 'Your name cannot contains spell name.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$spells_words = $db->query('SELECT `words` FROM `' . TABLE_PREFIX . 'spells` WHERE `words` = ' . $db->quote($name_lower));
|
||||
if($spells_words->rowCount() > 0) {
|
||||
self::$lastError = 'Your name cannot contains spell name.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($config['npc']))
|
||||
{
|
||||
if(in_array($name_lower, $config['npc'])) {
|
||||
self::$lastError = 'Your name cannot contains NPC name.';
|
||||
$monstersCheck = setting('core.create_character_name_monsters_check');
|
||||
if ($monstersCheck) {
|
||||
if (Monster::where('name', 'like', $name_lower)->exists()) {
|
||||
self::$lastError = 'Your name cannot contains monster name.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$npcCheck = config('character_name_npc_check');
|
||||
$spellsCheck = setting('core.create_character_name_spells_check');
|
||||
if ($spellsCheck) {
|
||||
if (Spell::where('name', 'like', $name_lower)->exists()) {
|
||||
self::$lastError = 'Your name cannot contains spell name.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Spell::where('words', $name_lower)->exists()) {
|
||||
self::$lastError = 'Your name cannot contains spell name.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$npcCheck = setting('core.create_character_name_npc_check');
|
||||
if ($npcCheck) {
|
||||
require_once LIBS . 'npc.php';
|
||||
NPCS::load();
|
||||
if(NPCS::$npcs && in_array($name_lower, NPCS::$npcs)) {
|
||||
self::$lastError = "Invalid name format. Do not use NPC Names";
|
||||
return false;
|
||||
if(NPCS::$npcs) {
|
||||
foreach (NPCs::$npcs as $npc) {
|
||||
if(strpos($name_lower, $npc) !== false) {
|
||||
self::$lastError = 'Your name cannot contains NPC name.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,4 +441,3 @@ class Validator
|
||||
return self::$lastError;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -7,6 +7,9 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Visitor;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Visitors
|
||||
@@ -34,10 +37,12 @@ class Visitors
|
||||
$this->cleanVisitors();
|
||||
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
$userAgentShortened = substr($_SERVER['HTTP_USER_AGENT'] ?? 'unknown', 0, 255);
|
||||
|
||||
if($this->visitorExists($ip))
|
||||
$this->updateVisitor($ip, $_SERVER['REQUEST_URI']);
|
||||
$this->updateVisitor($ip, $_SERVER['REQUEST_URI'], $userAgentShortened);
|
||||
else
|
||||
$this->addVisitor($ip, $_SERVER['REQUEST_URI']);
|
||||
$this->addVisitor($ip, $_SERVER['REQUEST_URI'], $userAgentShortened);
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
@@ -52,9 +57,7 @@ class Visitors
|
||||
return isset($this->data[$ip]);
|
||||
}
|
||||
|
||||
global $db;
|
||||
$users = $db->query('SELECT COUNT(`ip`) as count FROM `' . TABLE_PREFIX . 'visitors' . '` WHERE ' . $db->fieldName('ip') . ' = ' . $db->quote($ip))->fetch();
|
||||
return ($users['count'] > 0);
|
||||
return Visitor::where('ip', $ip)->exists();
|
||||
}
|
||||
|
||||
private function cleanVisitors()
|
||||
@@ -71,30 +74,27 @@ class Visitors
|
||||
return;
|
||||
}
|
||||
|
||||
global $db;
|
||||
$db->exec('DELETE FROM ' . $db->tableName(TABLE_PREFIX . 'visitors') . ' WHERE ' . $db->fieldName('lastvisit') . ' < ' . (time() - $this->sessionTime * 60));
|
||||
Visitor::where('lastvisit', '<', (time() - $this->sessionTime * 60))->delete();
|
||||
}
|
||||
|
||||
private function updateVisitor($ip, $page)
|
||||
private function updateVisitor($ip, $page, $userAgent)
|
||||
{
|
||||
if($this->cacheEnabled) {
|
||||
$this->data[$ip] = array('page' => $page, 'lastvisit' => time());
|
||||
$this->data[$ip] = array('page' => $page, 'lastvisit' => time(), 'user_agent' => $userAgent);
|
||||
return;
|
||||
}
|
||||
|
||||
global $db;
|
||||
$db->exec('UPDATE ' . $db->tableName(TABLE_PREFIX . 'visitors') . ' SET ' . $db->fieldName('lastvisit') . ' = ' . time() . ', ' . $db->fieldName('page') . ' = ' . $db->quote($page) . ' WHERE ' . $db->fieldName('ip') . ' = ' . $db->quote($ip));
|
||||
Visitor::where('ip', $ip)->update(['lastvisit' => time(), 'page' => $page, 'user_agent' => $userAgent]);
|
||||
}
|
||||
|
||||
private function addVisitor($ip, $page)
|
||||
private function addVisitor($ip, $page, $userAgent)
|
||||
{
|
||||
if($this->cacheEnabled) {
|
||||
$this->data[$ip] = array('page' => $page, 'lastvisit' => time());
|
||||
$this->data[$ip] = array('page' => $page, 'lastvisit' => time(), 'user_agent' => $userAgent);
|
||||
return;
|
||||
}
|
||||
|
||||
global $db;
|
||||
$db->exec('INSERT INTO ' . $db->tableName(TABLE_PREFIX . 'visitors') . ' (' . $db->fieldName('ip') . ' ,' . $db->fieldName('lastvisit') . ', ' . $db->fieldName('page') . ') VALUE (' . $db->quote($ip) . ', ' . time() . ', ' . $db->quote($page) . ')');
|
||||
Visitor::create(['ip' => $ip, 'lastvisit' => time(), 'page' => $page, 'user_agent' => $userAgent]);
|
||||
}
|
||||
|
||||
public function getVisitors()
|
||||
@@ -106,8 +106,7 @@ class Visitors
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
global $db;
|
||||
return $db->query('SELECT ' . $db->fieldName('ip') . ', ' . $db->fieldName('lastvisit') . ', ' . $db->fieldName('page') . ' FROM ' . $db->tableName(TABLE_PREFIX . 'visitors') . ' ORDER BY ' . $db->fieldName('lastvisit') . ' DESC')->fetchAll();
|
||||
return Visitor::orderByDesc('lastvisit')->get()->toArray();
|
||||
}
|
||||
|
||||
public function getAmountVisitors()
|
||||
@@ -116,9 +115,7 @@ class Visitors
|
||||
return count($this->data);
|
||||
}
|
||||
|
||||
global $db;
|
||||
$users = $db->query('SELECT COUNT(`ip`) as count FROM `' . TABLE_PREFIX . 'visitors`')->fetch();
|
||||
return $users['count'];
|
||||
return Visitor::count();
|
||||
}
|
||||
|
||||
public function show() {
|
||||
|
@@ -8,6 +8,9 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Weapon;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Weapons {
|
||||
@@ -15,10 +18,10 @@ class Weapons {
|
||||
|
||||
public static function loadFromXML($show = false)
|
||||
{
|
||||
global $config, $db;
|
||||
global $config;
|
||||
|
||||
try {
|
||||
$db->exec("DELETE FROM `myaac_weapons`;");
|
||||
Weapon::query()->delete();
|
||||
} catch (PDOException $error) {
|
||||
}
|
||||
|
||||
@@ -45,7 +48,7 @@ class Weapons {
|
||||
}
|
||||
|
||||
public static function parseNode($node, $show = false) {
|
||||
global $config, $db;
|
||||
global $config;
|
||||
|
||||
$id = (int)$node->getAttribute('id');
|
||||
$vocations_ids = array_flip($config['vocations']);
|
||||
@@ -64,18 +67,19 @@ class Weapons {
|
||||
$vocations[$voc_id] = strlen($show) == 0 || $show != '0';
|
||||
}
|
||||
|
||||
$exist = $db->query('SELECT `id` FROM `' . TABLE_PREFIX . 'weapons` WHERE `id` = ' . $id);
|
||||
if($exist->rowCount() > 0) {
|
||||
if(Weapon::find($id)) {
|
||||
if($show) {
|
||||
warning('Duplicated weapon with id: ' . $id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$db->insert(TABLE_PREFIX . 'weapons', array('id' => $id, 'level' => $level, 'maglevel' => $maglevel, 'vocations' => json_encode($vocations)));
|
||||
Weapon::create([
|
||||
'id' => $id, 'level' => $level, 'maglevel' => $maglevel, 'vocations' => json_encode($vocations)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getError() {
|
||||
return self::$error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
*/
|
||||
$locale['title'] = 'MyAAC Admin';
|
||||
?>
|
||||
|
@@ -20,7 +20,7 @@ $locale['not_loaded'] = 'Nicht geladen';
|
||||
$locale['loading_spinner'] = 'Bitte warten, installieren...';
|
||||
$locale['importing_spinner'] = 'Bitte warte, Daten werden importiert...';
|
||||
$locale['please_fill_all'] = 'Bitte füllen Sie alle Felder aus!';
|
||||
$locale['already_installed'] = 'MyAAC wurde bereits installiert. Bitte löschen <b>install/<b/> Verzeichnis. Wenn Sie MyAAC neu installieren möchten, löschen Sie die Datei <strong>config.local.php</strong> aus dem Hauptverzeichnis und aktualisieren Sie die Seite.';
|
||||
$locale['already_installed'] = 'MyAAC wurde bereits installiert. Bitte löschen <b>install/</b> Verzeichnis. Wenn Sie MyAAC neu installieren möchten, löschen Sie die Datei <strong>config.local.php</strong> aus dem Hauptverzeichnis und aktualisieren Sie die Seite.';
|
||||
|
||||
// welcome
|
||||
$locale['step_welcome'] = 'Willkommen';
|
||||
|
@@ -11,5 +11,4 @@ $locale['encoding'] = 'utf-8';
|
||||
$locale['direction']= 'ltr';
|
||||
|
||||
$locale['error404'] = 'Diese Seite konnte nicht gefunden werden.';
|
||||
$locale['news'] = 'Neuesten Nachrichten';
|
||||
?>
|
||||
$locale['news'] = 'Neuesten Nachrichten';
|
@@ -131,4 +131,3 @@ $locale['step_finish_title'] = 'Installation finished!';
|
||||
$locale['step_finish_desc'] = 'Congratulations! <b>MyAAC</b> is ready to use!<br/>You can now login to $ADMIN_PANEL$, or visit $HOMEPAGE$.<br/><br/>
|
||||
<span style="color: red">Please delete install/ directory.</span><br/><br/>
|
||||
Post bugs and suggestions at $LINK$, thanks!';
|
||||
?>
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
*/
|
||||
$locale['title'] = 'MyAAC Admin';
|
||||
?>
|
||||
|
@@ -12,4 +12,4 @@ $locale['direction']= 'ltr';
|
||||
|
||||
$locale['error404'] = 'Strona nie została odnaleziona.';
|
||||
$locale['news'] = 'Ostatnie newsy';
|
||||
$locale['loaded_in_ms'] = 'w $TIME$ ms';
|
||||
$locale['loaded_in_ms'] = 'w $TIME$ ms';
|
||||
|
@@ -118,4 +118,3 @@ $locale['step_finish'] = 'Finalizar';
|
||||
$locale['step_finish_title'] = 'Instalação terminada!';
|
||||
$locale['step_finish_desc'] = 'Parabéns! <b>MyAAC</b> está pronto para uso!<br/>Agora você pode fazer login em $ADMIN_PANEL$ ou visitar $HOMEPAGE$.<br/><br/>
|
||||
<span style = "color: red">Por favor remova a pasta install/.</span><br/><br/>Postar bugs e sugestões em $LINK$, obrigado!';
|
||||
?>
|
||||
|
@@ -6,4 +6,3 @@
|
||||
* @author Sizaro <sizaro@live.se>
|
||||
*/
|
||||
$locale['title'] = 'MyAAC Admin';
|
||||
?>
|
||||
|
@@ -12,4 +12,3 @@ $locale['direction']= 'ltr';
|
||||
|
||||
$locale['error404'] = 'Sidan kunde inte hittas.';
|
||||
$locale['news'] = 'Senaste nyheterna';
|
||||
?>
|
@@ -10,12 +10,12 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$logged = false;
|
||||
$logged_flags = 0;
|
||||
$account_logged = new OTS_Account();
|
||||
|
||||
// stay-logged with sessions
|
||||
$current_session = getSession('account');
|
||||
if($current_session !== false)
|
||||
{
|
||||
$account_logged = new OTS_Account();
|
||||
$account_logged->load($current_session);
|
||||
if($account_logged->isLoaded() && $account_logged->getPassword() == getSession('password')
|
||||
//&& (!isset($_SESSION['admin']) || admin())
|
||||
|
@@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Logout from account
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(isset($account_logged) && $account_logged->isLoaded()) {
|
||||
if($hooks->trigger(HOOK_LOGOUT, ['account_id' => $account_logged->getId()])) {
|
||||
|
@@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Database migrations
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
// database migrations
|
||||
$tmp = '';
|
||||
@@ -19,4 +28,4 @@ else { // register first version
|
||||
require SYSTEM . 'migrations/' . $i . '.php';
|
||||
updateDatabaseConfig('database_version', $i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,4 +13,4 @@
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
|
||||
");
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -17,4 +17,3 @@
|
||||
'thumb' => str_replace('/screenshots/', '/gallery/', $item['thumb']),
|
||||
), array('id' => $item['id']));
|
||||
}
|
||||
?>
|
||||
|
@@ -1,4 +1,3 @@
|
||||
<?php
|
||||
if($db->hasColumn(TABLE_PREFIX . 'spells', 'spell'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` DROP COLUMN `spell`;");
|
||||
?>
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` DROP COLUMN `spell`;");
|
@@ -8,4 +8,3 @@ if(!$db->hasColumn(TABLE_PREFIX . 'forum_boards', 'guild')) {
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'forum_boards', 'access')) {
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "forum_boards` ADD `access` TINYINT(1) NOT NULL DEFAULT 0 AFTER `guild`;");
|
||||
}
|
||||
?>
|
@@ -15,75 +15,7 @@ CREATE TABLE `myaac_menu`
|
||||
) 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);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'News Archive', 'news/archive', 1, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Changelog', 'changelog', 1, 2);
|
||||
/* MENU_CATEGORY_ACCOUNT kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Account Management', 'account/manage', 2, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Create Account', 'account/create', 2, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Lost Account?', 'account/lost', 2, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Server Rules', 'rules', 2, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Downloads', 'downloads', 5, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Report Bug', 'bugtracker', 2, 5);
|
||||
/* MENU_CATEGORY_COMMUNITY kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Who is Online?', 'online', 3, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Characters', 'characters', 3, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Guilds', 'guilds', 3, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Highscores', 'highscores', 3, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Last Deaths', 'lastkills', 3, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Houses', 'houses', 3, 5);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Bans', 'bans', 3, 6);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Forum', 'forum', 3, 7);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Team', 'team', 3, 8);
|
||||
/* MENU_CATEGORY_LIBRARY kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Monsters', 'creatures', 5, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Spells', 'spells', 5, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Server Info', 'serverInfo', 5, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Commands', 'commands', 5, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Gallery', 'gallery', 5, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Experience Table', 'experienceTable', 5, 5);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'FAQ', 'faq', 5, 6);
|
||||
/* MENU_CATEGORY_SHOP kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Buy Points', 'points', 6, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Shop Offer', 'gifts', 6, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Shop History', 'gifts/history', 6, 2);
|
||||
/* MENU_CATEGORY_NEWS tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Latest News', 'news', 1, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'News Archive', 'news/archive', 1, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Changelog', 'changelog', 1, 2);
|
||||
/* MENU_CATEGORY_ACCOUNT tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Account Management', 'account/manage', 2, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Create Account', 'account/create', 2, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Lost Account?', 'account/lost', 2, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Server Rules', 'rules', 2, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Downloads', 'downloads', 2, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Report Bug', 'bugtracker', 2, 5);
|
||||
/* MENU_CATEGORY_COMMUNITY tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Characters', 'characters', 3, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Who Is Online?', 'online', 3, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Highscores', 'highscores', 3, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Last Kills', 'lastkills', 3, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Houses', 'houses', 3, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Guilds', 'guilds', 3, 5);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Polls', 'polls', 3, 6);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Bans', 'bans', 3, 7);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Support List', 'team', 3, 8);
|
||||
/* MENU_CATEGORY_FORUM tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Forum', 'forum', 4, 0);
|
||||
/* MENU_CATEGORY_LIBRARY tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Creatures', 'creatures', 5, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Spells', 'spells', 5, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Commands', 'commands', 5, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Exp Stages', 'experienceStages', 5, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Gallery', 'gallery', 5, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Server Info', 'serverInfo', 5, 5);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Experience Table', 'experienceTable', 5, 6);
|
||||
/* MENU_CATEGORY_SHOP tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Buy Points', 'points', 6, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Shop Offer', 'gifts', 6, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Shop History', 'gifts/history', 6, 2);
|
||||
");
|
||||
require_once LIBS . 'plugins.php';
|
||||
Plugins::installMenus('kathrine', require TEMPLATES . 'kathrine/menus.php');
|
||||
Plugins::installMenus('tibiacom', require TEMPLATES . 'tibiacom/menus.php');
|
||||
}
|
||||
?>
|
@@ -1,3 +1,2 @@
|
||||
<?php
|
||||
// this migration has been removed, but file kept for compability
|
||||
?>
|
||||
// this migration has been removed, but file kept for compatibility
|
||||
|
@@ -3,4 +3,3 @@
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "movies` MODIFY `title` VARCHAR(100) NOT NULL DEFAULT '';");
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "news` MODIFY `title` VARCHAR(100) NOT NULL DEFAULT '';");
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "news` MODIFY `body` TEXT NOT NULL DEFAULT '';");
|
||||
?>
|
||||
|
@@ -1,48 +1,15 @@
|
||||
<?php
|
||||
|
||||
if(!isset($database_migration_20)) {
|
||||
databaseMigration20();
|
||||
$query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . " OR `name` = " . $db->quote("Account Manager") . ") ORDER BY `id`;");
|
||||
|
||||
$highscores_ignored_ids = array();
|
||||
if($query->rowCount() > 0) {
|
||||
foreach($query->fetchAll() as $result)
|
||||
$highscores_ignored_ids[] = $result['id'];
|
||||
}
|
||||
else {
|
||||
$highscores_ignored_ids[] = 0;
|
||||
}
|
||||
|
||||
function databaseMigration20(&$content = '') {
|
||||
global $db;
|
||||
|
||||
$config_file = BASE . 'config.local.php';
|
||||
if(!is_writable($config_file)) { // we can't do anything, just ignore
|
||||
return false;
|
||||
}
|
||||
|
||||
$content_of_file = trim(file_get_contents($config_file));
|
||||
if(strpos($content_of_file, 'highscores_ids_hidden') !== false) { // already present
|
||||
return true;
|
||||
}
|
||||
|
||||
$query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . " OR `name` = " . $db->quote("Account Manager") . ") ORDER BY `id`;");
|
||||
|
||||
$highscores_ignored_ids = array();
|
||||
if($query->rowCount() > 0) {
|
||||
foreach($query->fetchAll() as $result)
|
||||
$highscores_ignored_ids[] = $result['id'];
|
||||
}
|
||||
else {
|
||||
$highscores_ignored_ids[] = 0;
|
||||
}
|
||||
|
||||
$php_on_end = substr($content_of_file, -2, 2) == '?>';
|
||||
$content = PHP_EOL;
|
||||
if($php_on_end) {
|
||||
$content .= '<?php';
|
||||
}
|
||||
|
||||
$content .= PHP_EOL;
|
||||
$content .= '$config[\'highscores_ids_hidden\'] = array(' . implode(', ', $highscores_ignored_ids) . ');';
|
||||
$content .= PHP_EOL;
|
||||
|
||||
if($php_on_end) {
|
||||
$content .= '?>';
|
||||
}
|
||||
|
||||
file_put_contents($config_file, $content, FILE_APPEND);
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
$settings = Settings::getInstance();
|
||||
$settings->updateInDatabase('core', 'highscores_ids_hidden', implode(', ', $highscores_ignored_ids));
|
||||
|
4
system/migrations/34.php
Normal file
4
system/migrations/34.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
// add user_agent column into visitors
|
||||
|
||||
$db->exec('ALTER TABLE `' . TABLE_PREFIX . "visitors` ADD `user_agent` VARCHAR(255) NOT NULL DEFAULT '';");
|
3
system/migrations/35.php
Normal file
3
system/migrations/35.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
// add look column
|
||||
$db->exec('ALTER TABLE `' . TABLE_PREFIX . "monsters` ADD `look` VARCHAR(255) NOT NULL DEFAULT '' AFTER `health`;");
|
14
system/migrations/36.php
Normal file
14
system/migrations/36.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// add settings table
|
||||
if(!$db->hasTable(TABLE_PREFIX . 'settings')) {
|
||||
$db->exec("CREATE TABLE `" . TABLE_PREFIX . "settings`
|
||||
(
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`key` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`value` TEXT NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `key` (`key`)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;");
|
||||
}
|
@@ -1,4 +1,3 @@
|
||||
<?php
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'monsters', 'id'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `id` int(11) NOT NULL AUTO_INCREMENT primary key FIRST;");
|
||||
?>
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` ADD `id` int(11) NOT NULL AUTO_INCREMENT primary key FIRST;");
|
@@ -1,4 +1,3 @@
|
||||
<?php
|
||||
if(!$db->hasColumn(TABLE_PREFIX . 'hooks', 'enabled'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "hooks` ADD `enabled` INT(1) NOT NULL DEFAULT 1;");
|
||||
?>
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "hooks` ADD `enabled` INT(1) NOT NULL DEFAULT 1;");
|
@@ -14,5 +14,4 @@
|
||||
|
||||
foreach($boards as $id => $board)
|
||||
$db->query('UPDATE `' . TABLE_PREFIX . 'forum_boards` SET `ordering` = ' . $id . ' WHERE `name` = ' . $db->quote($board));
|
||||
}
|
||||
?>
|
||||
}
|
@@ -8,6 +8,9 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Player;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$title = 'Change Comment';
|
||||
@@ -17,29 +20,36 @@ if(!$logged) {
|
||||
return;
|
||||
}
|
||||
|
||||
$player = null;
|
||||
$player_name = isset($_REQUEST['name']) ? stripslashes(urldecode($_REQUEST['name'])) : null;
|
||||
$new_comment = isset($_POST['comment']) ? htmlspecialchars(stripslashes(substr($_POST['comment'],0,2000))) : NULL;
|
||||
$new_hideacc = isset($_POST['accountvisible']) ? (int)$_POST['accountvisible'] : NULL;
|
||||
|
||||
if($player_name != null) {
|
||||
if (Validator::characterName($player_name)) {
|
||||
$player = new OTS_Player();
|
||||
$player->find($player_name);
|
||||
if ($player->isLoaded()) {
|
||||
$player_account = $player->getAccount();
|
||||
if ($account_logged->getId() == $player_account->getId()) {
|
||||
if (isset($_POST['changecommentsave']) && $_POST['changecommentsave'] == 1) {
|
||||
$player->setCustomField("hidden", $new_hideacc);
|
||||
$player->setCustomField("comment", $new_comment);
|
||||
$account_logged->logAction('Changed comment for character <b>' . $player->getName() . '</b>.');
|
||||
$player = Player::query()
|
||||
->where('name', $player_name)
|
||||
->where('account_id', $account_logged->getId())
|
||||
->first();
|
||||
|
||||
if ($player) {
|
||||
if ($player->is_deleted) {
|
||||
$errors[] = 'This character is deleted.';
|
||||
$player = null;
|
||||
}
|
||||
|
||||
if (isset($_POST['changecommentsave']) && $_POST['changecommentsave'] == 1) {
|
||||
if(empty($errors)) {
|
||||
$player->hidden = $new_hideacc;
|
||||
$player->comment = $new_comment;
|
||||
$player->save();
|
||||
$account_logged->logAction('Changed comment for character <b>' . $player->name . '</b>.');
|
||||
$twig->display('success.html.twig', array(
|
||||
'title' => 'Character Information Changed',
|
||||
'description' => 'The character information has been changed.'
|
||||
));
|
||||
$show_form = false;
|
||||
}
|
||||
} else {
|
||||
$errors[] = 'Error. Character <b>' . $player_name . '</b> is not on your account.';
|
||||
}
|
||||
} else {
|
||||
$errors[] = "Error. Character with this name doesn't exist.";
|
||||
@@ -57,9 +67,9 @@ if($show_form) {
|
||||
$twig->display('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
if(isset($player)) {
|
||||
if(isset($player) && $player) {
|
||||
$twig->display('account.change_comment.html.twig', array(
|
||||
'player' => $player
|
||||
'player' => $player->toArray()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ if($email_new_time < 10) {
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$email_new_time = time() + $config['account_mail_change'] * 24 * 3600;
|
||||
$email_new_time = time() + setting('core.account_mail_change') * 24 * 3600;
|
||||
$account_logged->setCustomField("email_new", $email_new);
|
||||
$account_logged->setCustomField("email_new_time", $email_new_time);
|
||||
$twig->display('success.html.twig', array(
|
||||
@@ -166,4 +166,3 @@ if(isset($_POST['emailchangecancel']) && $_POST['emailchangecancel'] == 1) {
|
||||
'custom_buttons' => $custom_buttons
|
||||
));
|
||||
}
|
||||
?>
|
||||
|
@@ -8,6 +8,9 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Account;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$title = 'Change Info';
|
||||
@@ -17,9 +20,11 @@ if(!$logged) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($config['account_country'])
|
||||
if(setting('core.account_country'))
|
||||
require SYSTEM . 'countries.conf.php';
|
||||
|
||||
$account = Account::find($account_logged->getId());
|
||||
|
||||
$show_form = true;
|
||||
$new_rlname = isset($_POST['info_rlname']) ? htmlspecialchars(stripslashes($_POST['info_rlname'])) : NULL;
|
||||
$new_location = isset($_POST['info_location']) ? htmlspecialchars(stripslashes($_POST['info_location'])) : NULL;
|
||||
@@ -30,9 +35,10 @@ if(isset($_POST['changeinfosave']) && $_POST['changeinfosave'] == 1) {
|
||||
|
||||
if(empty($errors)) {
|
||||
//save data from form
|
||||
$account_logged->setCustomField("rlname", $new_rlname);
|
||||
$account_logged->setCustomField("location", $new_location);
|
||||
$account_logged->setCustomField("country", $new_country);
|
||||
$account->rlname = $new_rlname;
|
||||
$account->location = $new_location;
|
||||
$account->country = $new_country;
|
||||
$account->save();
|
||||
$account_logged->logAction('Changed Real Name to <b>' . $new_rlname . '</b>, Location to <b>' . $new_location . '</b> and Country to <b>' . $config['countries'][$new_country] . '</b>.');
|
||||
$twig->display('success.html.twig', array(
|
||||
'title' => 'Public Information Changed',
|
||||
@@ -47,10 +53,10 @@ if(isset($_POST['changeinfosave']) && $_POST['changeinfosave'] == 1) {
|
||||
|
||||
//show form
|
||||
if($show_form) {
|
||||
$account_rlname = $account_logged->getCustomField("rlname");
|
||||
$account_location = $account_logged->getCustomField("location");
|
||||
if ($config['account_country']) {
|
||||
$account_country = $account_logged->getCustomField("country");
|
||||
$account_rlname = $account->rlname;
|
||||
$account_location = $account->location;
|
||||
if (setting('core.account_country')) {
|
||||
$account_country = $account->country;
|
||||
|
||||
$countries = array();
|
||||
foreach (array('pl', 'se', 'br', 'us', 'gb',) as $country)
|
||||
|
@@ -19,17 +19,17 @@ if(!$logged) {
|
||||
|
||||
$player_id = isset($_POST['player_id']) ? (int)$_POST['player_id'] : NULL;
|
||||
$name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : NULL;
|
||||
if((!$config['account_change_character_name']))
|
||||
if((!setting('core.account_change_character_name')))
|
||||
echo 'Changing character name for premium points is disabled on this server.';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
$points = $account_logged->getCustomField(setting('core.donate_column'));
|
||||
if(isset($_POST['changenamesave']) && $_POST['changenamesave'] == 1) {
|
||||
if($points < $config['account_change_character_name_points'])
|
||||
$errors[] = 'You need ' . $config['account_change_character_name_points'] . ' premium points to change name. You have <b>'.$points.'<b> premium points.';
|
||||
if($points < setting('core.account_change_character_name_price'))
|
||||
$errors[] = 'You need ' . setting('core.account_change_character_name_price') . ' premium points to change name. You have <b>'.$points.'<b> premium points.';
|
||||
|
||||
$minLength = config('character_name_min_length');
|
||||
$maxLength = config('character_name_max_length');
|
||||
$minLength = setting('core.create_character_name_min_length');
|
||||
$maxLength = setting('core.create_character_name_max_length');
|
||||
|
||||
if(empty($errors) && empty($name))
|
||||
$errors[] = 'Please enter a new name for your character!';
|
||||
@@ -50,6 +50,10 @@ else
|
||||
if($player->isLoaded()) {
|
||||
$player_account = $player->getAccount();
|
||||
if($account_logged->getId() == $player_account->getId()) {
|
||||
if ($player->isDeleted()) {
|
||||
$errors[] = 'This character is deleted.';
|
||||
}
|
||||
|
||||
if($player->isOnline()) {
|
||||
$errors[] = 'This character is online.';
|
||||
}
|
||||
@@ -82,7 +86,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
$account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
|
||||
$account_logged->setCustomField(setting('core.donate_column'), $points - setting('core.account_change_character_name_price'));
|
||||
$account_logged->logAction('Changed name from <b>' . $old_name . '</b> to <b>' . $player->getName() . '</b>.');
|
||||
$twig->display('success.html.twig', array(
|
||||
'title' => 'Character Name Changed',
|
||||
@@ -91,7 +95,7 @@ else
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character <b>' . $player_name . '</b> is not on your account.';
|
||||
$errors[] = 'Character is not on your account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -112,5 +116,3 @@ else
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -26,11 +26,11 @@ if(empty($new_password) && empty($new_password2) && empty($old_password)) {
|
||||
else
|
||||
{
|
||||
if(empty($new_password) || empty($new_password2) || empty($old_password)){
|
||||
$errors[] = "Please fill in form.";
|
||||
$errors[] = 'Please fill in form.';
|
||||
}
|
||||
$password_strlen = strlen($new_password);
|
||||
if($new_password != $new_password2) {
|
||||
$errors[] = "The new passwords do not match!";
|
||||
$errors[] = 'The new passwords do not match!';
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
@@ -41,9 +41,12 @@ else
|
||||
/** @var OTS_Account $account_logged */
|
||||
$old_password = encrypt((USE_ACCOUNT_SALT ? $account_logged->getCustomField('salt') : '') . $old_password);
|
||||
if($old_password != $account_logged->getPassword()) {
|
||||
$errors[] = "Current password is incorrect!";
|
||||
$errors[] = 'Current password is incorrect!';
|
||||
}
|
||||
|
||||
$hooks->trigger(HOOK_ACCOUNT_CHANGE_PASSWORD_POST);
|
||||
}
|
||||
|
||||
if(!empty($errors)){
|
||||
//show errors
|
||||
$twig->display('error_box.html.twig', array('errors' => $errors));
|
||||
@@ -51,12 +54,10 @@ else
|
||||
//show form
|
||||
$twig->display('account.change_password.html.twig');
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
$org_pass = $new_password;
|
||||
|
||||
if(USE_ACCOUNT_SALT)
|
||||
{
|
||||
if(USE_ACCOUNT_SALT) {
|
||||
$salt = generateRandomString(10, false, true, true);
|
||||
$new_password = $salt . $new_password;
|
||||
$account_logged->setCustomField('salt', $salt);
|
||||
@@ -68,17 +69,18 @@ else
|
||||
$account_logged->logAction('Account password changed.');
|
||||
|
||||
$message = '';
|
||||
if($config['mail_enabled'] && $config['send_mail_when_change_password'])
|
||||
{
|
||||
if(setting('core.mail_enabled') && setting('core.mail_send_when_change_password')) {
|
||||
$mailBody = $twig->render('mail.password_changed.html.twig', array(
|
||||
'new_password' => $org_pass,
|
||||
'ip' => get_browser_real_ip(),
|
||||
));
|
||||
|
||||
if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - Changed password", $mailBody))
|
||||
$message = '<br/><small>Your new password were send on email address <b>'.$account_logged->getEMail().'</b>.</small>';
|
||||
else
|
||||
if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - Changed password", $mailBody)) {
|
||||
$message = '<br/><small>Your new password were send on email address <b>' . $account_logged->getEMail() . '</b>.</small>';
|
||||
}
|
||||
else {
|
||||
$message = '<br/><p class="error">An error occurred while sending email. For Admin: More info can be found in system/logs/mailer-error.log</p>';
|
||||
}
|
||||
}
|
||||
|
||||
$twig->display('success.html.twig', array(
|
||||
@@ -88,5 +90,3 @@ else
|
||||
setSession('password', $new_password);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -20,14 +20,14 @@ if(!$logged) {
|
||||
$sex_changed = false;
|
||||
$player_id = isset($_POST['player_id']) ? (int)$_POST['player_id'] : NULL;
|
||||
$new_sex = isset($_POST['new_sex']) ? (int)$_POST['new_sex'] : NULL;
|
||||
if((!$config['account_change_character_sex']))
|
||||
if((!setting('core.account_change_character_sex')))
|
||||
echo 'You cant change your character sex';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
$points = $account_logged->getCustomField(setting('core.donate_column'));
|
||||
if(isset($_POST['changesexsave']) && $_POST['changesexsave'] == 1) {
|
||||
if($points < $config['account_change_character_sex_points'])
|
||||
$errors[] = 'You need ' . $config['account_change_character_sex_points'] . ' premium points to change sex. You have <b>'.$points.'</b> premium points.';
|
||||
if($points < setting('core.account_change_character_sex_price'))
|
||||
$errors[] = 'You need ' . setting('core.account_change_character_sex_price') . ' premium points to change sex. You have <b>'.$points.'</b> premium points.';
|
||||
|
||||
if(empty($errors) && !isset($config['genders'][$new_sex])) {
|
||||
$errors[] = 'This sex is invalid.';
|
||||
@@ -41,6 +41,10 @@ else
|
||||
$player_account = $player->getAccount();
|
||||
|
||||
if($account_logged->getId() == $player_account->getId()) {
|
||||
if ($player->isDeleted()) {
|
||||
$errors[] = 'This character is deleted.';
|
||||
}
|
||||
|
||||
if($player->isOnline()) {
|
||||
$errors[] = 'This character is online.';
|
||||
}
|
||||
@@ -62,7 +66,7 @@ else
|
||||
$new_sex_str = $config['genders'][$new_sex];
|
||||
|
||||
$player->save();
|
||||
$account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
|
||||
$account_logged->setCustomField(setting('core.donate_column'), $points - setting('core.account_change_character_name_price'));
|
||||
$account_logged->logAction('Changed sex on character <b>' . $player->getName() . '</b> from <b>' . $old_sex_str . '</b> to <b>' . $new_sex_str . '</b>.');
|
||||
$twig->display('success.html.twig', array(
|
||||
'title' => 'Character Sex Changed',
|
||||
@@ -71,7 +75,7 @@ else
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character <b>'.$player_name.'</b> is not on your account.';
|
||||
$errors[] = 'Character is not on your account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -85,11 +89,9 @@ else
|
||||
$twig->display('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
$twig->display('account.change_sex.html.twig', array(
|
||||
'players' => $account_logged->getPlayersList(),
|
||||
'players' => $account_logged->getPlayersList(false),
|
||||
'player_sex' => isset($player) ? $player->getSex() : -1,
|
||||
'points' => $points
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -7,6 +7,9 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
use MyAAC\Models\Account;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$title = 'Confirm Email';
|
||||
@@ -17,14 +20,12 @@ if(empty($hash)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$res = $db->query('SELECT `email_hash` FROM `accounts` WHERE `email_hash` = ' . $db->quote($hash));
|
||||
if(!$res->rowCount()) {
|
||||
if(!Account::where('email_hash', $hash)->exists()) {
|
||||
note("Your email couldn't be verified. Please contact staff to do it manually.");
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $db->query('SELECT id FROM accounts WHERE email_hash = ' . $db->quote($hash) . ' AND email_verified = 0');
|
||||
if ($query->rowCount() == 1) {
|
||||
if (Account::where('email_hash', $hash)->where('email_verified', 0)->exists()) {
|
||||
$query = $query->fetch(PDO::FETCH_ASSOC);
|
||||
$account = new OTS_Account();
|
||||
$account->load($query['id']);
|
||||
@@ -33,7 +34,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
$db->update('accounts', array('email_verified' => '1'), array('email_hash' => $hash));
|
||||
Account::where('email_hash', $hash)->update('email_verified', 1);
|
||||
success('You have now verified your e-mail, this will increase the security of your account. Thank you for doing this.');
|
||||
}
|
||||
?>
|
||||
|
@@ -11,7 +11,7 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Create Account';
|
||||
|
||||
if($config['account_country'])
|
||||
if (setting('core.account_country'))
|
||||
require SYSTEM . 'countries.conf.php';
|
||||
|
||||
if($logged)
|
||||
@@ -20,14 +20,19 @@ if($logged)
|
||||
return;
|
||||
}
|
||||
|
||||
if(config('account_create_character_create')) {
|
||||
if(setting('core.account_create_character_create')) {
|
||||
require_once LIBS . 'CreateCharacter.php';
|
||||
$createCharacter = new CreateCharacter();
|
||||
}
|
||||
|
||||
$account_type = 'number';
|
||||
if(USE_ACCOUNT_NAME) {
|
||||
$account_type = 'name';
|
||||
if (config('account_login_by_email')) {
|
||||
$account_type = 'Email Address';
|
||||
}
|
||||
else {
|
||||
if(USE_ACCOUNT_NAME) {
|
||||
$account_type = 'name';
|
||||
}
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
@@ -63,7 +68,7 @@ if($save)
|
||||
|
||||
// country
|
||||
$country = '';
|
||||
if($config['account_country'])
|
||||
if (setting('core.account_country'))
|
||||
{
|
||||
$country = $_POST['country'];
|
||||
if(!isset($country))
|
||||
@@ -88,7 +93,7 @@ if($save)
|
||||
$errors['password'] = 'Password may not be the same as account name.';
|
||||
}
|
||||
|
||||
if($config['account_mail_unique'])
|
||||
if(setting('core.account_mail_unique'))
|
||||
{
|
||||
$test_email_account = new OTS_Account();
|
||||
$test_email_account->findByEMail($email);
|
||||
@@ -110,7 +115,7 @@ if($save)
|
||||
}
|
||||
|
||||
if($account_db->isLoaded()) {
|
||||
if (config('account_login_by_email') && !config('account_mail_unique')) {
|
||||
if (config('account_login_by_email') && !setting('core.account_mail_unique')) {
|
||||
$errors['account'] = 'Account with this email already exist.';
|
||||
}
|
||||
else if (!config('account_login_by_email')) {
|
||||
@@ -145,7 +150,7 @@ if($save)
|
||||
return;
|
||||
}
|
||||
|
||||
if(config('account_create_character_create')) {
|
||||
if(setting('core.account_create_character_create')) {
|
||||
$character_name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : null;
|
||||
$character_sex = isset($_POST['sex']) ? (int)$_POST['sex'] : null;
|
||||
$character_vocation = isset($_POST['vocation']) ? (int)$_POST['vocation'] : null;
|
||||
@@ -156,9 +161,12 @@ if($save)
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$hasBeenCreatedByEMail = false;
|
||||
|
||||
$new_account = new OTS_Account();
|
||||
if (config('account_login_by_email')) {
|
||||
$new_account->createWithEmail($email);
|
||||
$hasBeenCreatedByEMail = true;
|
||||
}
|
||||
else {
|
||||
if(USE_ACCOUNT_NAME)
|
||||
@@ -175,7 +183,6 @@ if($save)
|
||||
|
||||
$new_account->setPassword(encrypt($password));
|
||||
$new_account->setEMail($email);
|
||||
$new_account->unblock();
|
||||
$new_account->save();
|
||||
|
||||
if(USE_ACCOUNT_SALT)
|
||||
@@ -184,27 +191,28 @@ if($save)
|
||||
$new_account->setCustomField('created', time());
|
||||
$new_account->logAction('Account created.');
|
||||
|
||||
if($config['account_country']) {
|
||||
if(setting('core.account_country')) {
|
||||
$new_account->setCustomField('country', $country);
|
||||
}
|
||||
|
||||
if($config['account_premium_days'] && $config['account_premium_days'] > 0) {
|
||||
$settingAccountPremiumDays = setting('core.account_premium_days');
|
||||
if($settingAccountPremiumDays && $settingAccountPremiumDays > 0) {
|
||||
if($db->hasColumn('accounts', 'premend')) { // othire
|
||||
$new_account->setCustomField('premend', time() + $config['account_premium_days'] * 86400);
|
||||
$new_account->setCustomField('premend', time() + $settingAccountPremiumDays * 86400);
|
||||
}
|
||||
else { // rest
|
||||
if ($db->hasColumn('accounts', 'premium_ends_at')) { // TFS 1.4+
|
||||
$new_account->setCustomField('premium_ends_at', time() + $config['account_premium_days'] * (60 * 60 * 24));
|
||||
$new_account->setCustomField('premium_ends_at', time() + $settingAccountPremiumDays * (60 * 60 * 24));
|
||||
}
|
||||
else {
|
||||
$new_account->setCustomField('premdays', $config['account_premium_days']);
|
||||
$new_account->setCustomField('premdays', $settingAccountPremiumDays);
|
||||
$new_account->setCustomField('lastday', time());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($config['account_premium_points']) {
|
||||
$new_account->setCustomField('premium_points', $config['account_premium_points']);
|
||||
if(setting('core.account_premium_points') && setting('core.account_premium_points') > 0) {
|
||||
$new_account->setCustomField('premium_points', setting('core.account_premium_points'));
|
||||
}
|
||||
|
||||
$tmp_account = $email;
|
||||
@@ -212,7 +220,7 @@ if($save)
|
||||
$tmp_account = (USE_ACCOUNT_NAME ? $account_name : $account_id);
|
||||
}
|
||||
|
||||
if($config['mail_enabled'] && $config['account_mail_verify'])
|
||||
if(setting('core.mail_enabled') && setting('core.account_mail_verify'))
|
||||
{
|
||||
$hash = md5(generateRandomString(16, true, true) . $email);
|
||||
$new_account->setCustomField('email_hash', $hash);
|
||||
@@ -231,7 +239,7 @@ if($save)
|
||||
'description' => 'Your account ' . $account_type . ' is <b>' . $tmp_account . '</b><br/>You will need the account ' . $account_type . ' and your password to play on ' . configLua('serverName') . '.
|
||||
Please keep your account ' . $account_type . ' and password in a safe place and
|
||||
never give your account ' . $account_type . ' or password to anybody.',
|
||||
'custom_buttons' => config('account_create_character_create') ? '' : null
|
||||
'custom_buttons' => setting('core.account_create_character_create') ? '' : null
|
||||
));
|
||||
}
|
||||
else
|
||||
@@ -242,24 +250,31 @@ if($save)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(config('account_create_character_create')) {
|
||||
if(setting('core.account_create_character_create')) {
|
||||
// character creation
|
||||
$character_created = $createCharacter->doCreate($character_name, $character_sex, $character_vocation, $character_town, $new_account, $errors);
|
||||
if (!$character_created) {
|
||||
error('There was an error creating your character. Please create your character later in account management page.');
|
||||
error(implode(' ', $errors));
|
||||
}
|
||||
}
|
||||
|
||||
if($config['account_create_auto_login']) {
|
||||
$_POST['account_login'] = USE_ACCOUNT_NAME ? $account_name : $account_id;
|
||||
if(setting('core.account_create_auto_login')) {
|
||||
if ($hasBeenCreatedByEMail) {
|
||||
$_POST['account_login'] = $email;
|
||||
}
|
||||
else {
|
||||
$_POST['account_login'] = USE_ACCOUNT_NAME ? $account_name : $account_id;
|
||||
}
|
||||
|
||||
$_POST['password_login'] = $password2;
|
||||
|
||||
require SYSTEM . 'login.php';
|
||||
require PAGES . 'account/login.php';
|
||||
header('Location: ' . getLink('account/manage'));
|
||||
}
|
||||
|
||||
echo 'Your account';
|
||||
if(config('account_create_character_create')) {
|
||||
if(setting('core.account_create_character_create')) {
|
||||
echo ' and character have';
|
||||
}
|
||||
else {
|
||||
@@ -267,7 +282,7 @@ if($save)
|
||||
}
|
||||
|
||||
echo ' been created.';
|
||||
if(!config('account_create_character_create')) {
|
||||
if(!setting('core.account_create_character_create')) {
|
||||
echo ' Now you can login and create your first character.';
|
||||
}
|
||||
|
||||
@@ -277,10 +292,10 @@ if($save)
|
||||
'description' => 'Your account ' . $account_type . ' is <b>' . $tmp_account . '</b><br/>You will need the account ' . $account_type . ' and your password to play on ' . configLua('serverName') . '.
|
||||
Please keep your account ' . $account_type . ' and password in a safe place and
|
||||
never give your account ' . $account_type . ' or password to anybody.',
|
||||
'custom_buttons' => config('account_create_character_create') ? '' : null
|
||||
'custom_buttons' => setting('core.account_create_character_create') ? '' : null
|
||||
));
|
||||
|
||||
if($config['mail_enabled'] && $config['account_welcome_mail'])
|
||||
if(setting('core.mail_enabled') && setting('core.account_welcome_mail'))
|
||||
{
|
||||
$mailBody = $twig->render('account.welcome_mail.html.twig', array(
|
||||
'account' => $tmp_account
|
||||
@@ -299,7 +314,7 @@ if($save)
|
||||
}
|
||||
|
||||
$country_recognized = null;
|
||||
if($config['account_country_recognize']) {
|
||||
if(setting('core.account_country_recognize')) {
|
||||
$country_session = getSession('country');
|
||||
if($country_session !== false) { // get from session
|
||||
$country_recognized = $country_session;
|
||||
@@ -316,7 +331,7 @@ if($config['account_country_recognize']) {
|
||||
if(!empty($errors))
|
||||
$twig->display('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
if($config['account_country']) {
|
||||
if (setting('core.account_country')) {
|
||||
$countries = array();
|
||||
foreach (array('pl', 'se', 'br', 'us', 'gb') as $c)
|
||||
$countries[$c] = $config['countries'][$c];
|
||||
@@ -339,7 +354,7 @@ $params = array(
|
||||
'save' => $save
|
||||
);
|
||||
|
||||
if($save && config('account_create_character_create')) {
|
||||
if($save && setting('core.account_create_character_create')) {
|
||||
$params = array_merge($params, array(
|
||||
'name' => $character_name,
|
||||
'sex' => $character_sex,
|
||||
|
@@ -61,6 +61,14 @@ if(isset($_POST['deletecharactersave']) && $_POST['deletecharactersave'] == 1) {
|
||||
}
|
||||
}
|
||||
|
||||
$ownerid = 'ownerid';
|
||||
if($db->hasColumn('guilds', 'owner_id'))
|
||||
$ownerid = 'owner_id';
|
||||
$guild = $db->query('SELECT `name` FROM `guilds` WHERE `' . $ownerid . '` = '.$player->getId());
|
||||
if($guild->rowCount() > 0) {
|
||||
$errors[] = 'You cannot delete a character when they own a guild.';
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
//dont show table "delete character" again
|
||||
$show_form = false;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user