mirror of
https://github.com/slawkens/myaac.git
synced 2025-09-14 04:23:34 +02:00
Compare commits
35 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9f946d4bc4 | ||
![]() |
5266f33af5 | ||
![]() |
85c9a1e84d | ||
![]() |
5951fe21ec | ||
![]() |
c6b6638705 | ||
![]() |
8ab7be9fb8 | ||
![]() |
762fa31c28 | ||
![]() |
c2678aa91f | ||
![]() |
d4900eac84 | ||
![]() |
f9b6e9fa2e | ||
![]() |
cfb460c137 | ||
![]() |
f9e6966687 | ||
![]() |
913b4297cf | ||
![]() |
23c1df72aa | ||
![]() |
cde42ec3fa | ||
![]() |
0104d2fd36 | ||
![]() |
85d1f3419a | ||
![]() |
e45d27b5c7 | ||
![]() |
a3d94db6eb | ||
![]() |
ef904c854b | ||
![]() |
7a7eb4e553 | ||
![]() |
c7f549742d | ||
![]() |
1850ef70d8 | ||
![]() |
0b693a02bd | ||
![]() |
508db95cba | ||
![]() |
bbae0c3ade | ||
![]() |
0239f940a0 | ||
![]() |
1df0c2b313 | ||
![]() |
a9d9ace532 | ||
![]() |
cb83e17710 | ||
![]() |
1727df7082 | ||
![]() |
3d585a3d02 | ||
![]() |
69f822b69c | ||
![]() |
abfe3b08af | ||
![]() |
66a3c46aaf |
51
CHANGELOG
51
CHANGELOG
@@ -1,3 +1,54 @@
|
||||
[0.6.4 - 20.10.2017]
|
||||
- reverted OTS_Account::getLastLogin() cause its used by tibia11-login plugin
|
||||
|
||||
[0.6.3 - 20.10.2017]
|
||||
- fixed creating account
|
||||
- fixed viewing thread without being logged
|
||||
- fixed showing premium account status
|
||||
|
||||
[0.6.2 - 20.10.2017]
|
||||
- added forums for guilds and groups
|
||||
- added nice looking menu for my account page in default template
|
||||
- new command line tool: install_plugin.php - can be used to install plugins from command line. Usage: "php install_plugin.php path_to_file"
|
||||
- added new tooltip to view characters equipment item name and monster loot
|
||||
- added items.xml loader class and weapons.xml loader class
|
||||
- minimum PHP version to install AAC is now 5.3.0 cause of Anonymous functions used by Twig
|
||||
- Added 'Are you sure?' popup when uninstalling plugin
|
||||
- added some warnings when plugin json file is incomplete
|
||||
- fixed showing in characters ban expires when is unlimited
|
||||
- fixed displaying monster loot when item.name in loot is used instead of item.id
|
||||
- load also runes into spells table
|
||||
- display plugin uninstall option only if its possible
|
||||
- after changing template you will be redirected to latest viewed page
|
||||
- display gallery add image form only on main gallery page
|
||||
- (internal) moved most of guilds html-in-php code to twig
|
||||
- (internal) moved spells page to twig template
|
||||
- (internal) removed useless spells.spell column that was duplicate of spells.words
|
||||
- (internal) save monster loot in database in json format instead loading it every time from xml file
|
||||
- (internal) store monster voices and immunities in json format
|
||||
- (internal) moved buttons to separate template
|
||||
- (internal) moved online search form to twig
|
||||
- (internal) added new function getItemNameById($id)
|
||||
- (internal) Moved plugin install logic to a new class: Plugins
|
||||
- (internal) changed spells.vocations database field to store json data instead of comma separated
|
||||
- (internal) removed $hook_types array, using defined() and constant() functions now
|
||||
- (internal) removed useless monsters.gfx_name field from database
|
||||
- (internal) renamed database field monsters.hide_creature to hidden
|
||||
- (internal) renamed existing Items class to Items_Images
|
||||
- (internal) optimized Spells class
|
||||
- (internal) new function: OTS_Guild::hasMember(OTS_Player $player)
|
||||
- (internal) new function: Forum::hasAccess($board_id)
|
||||
|
||||
[0.6.1 - 17.10.2017]
|
||||
- fixed signatures loading
|
||||
- new configurable: session_prefix, to allow more websites on one machine (must be unique for every website on your dedicated server!)
|
||||
- better error handling for monsters and spells loader (save errors to system/logs/error.log)
|
||||
- check if file exist before loading (monsters and spells)
|
||||
- (internal) Account::getAccess() = Account::getGroupId()
|
||||
- (internal) moved account actions (pages) to account/ directory
|
||||
- (internal) moved forum actions (pages) to forum/ directory
|
||||
- (internal) moved forum.edit_post to twig templates
|
||||
|
||||
[0.6.0 - 16.10.2017]
|
||||
- added faq management - add/edit/move/hide/delete from website
|
||||
- new account.login view for tibiacom template
|
||||
|
@@ -5,7 +5,7 @@ Official website: https://my-aac.org
|
||||
|
||||
### REQUIREMENTS
|
||||
|
||||
- PHP 5.2.0 or later
|
||||
- PHP 5.3.0 or later
|
||||
- MySQL database
|
||||
- PDO PHP Extension
|
||||
- XML PHP Extension
|
||||
|
@@ -28,7 +28,7 @@ h1, h2, h3, h4, h5, h6 {color: #313334; font-weight: bold;}
|
||||
margin-left:5px;
|
||||
}
|
||||
|
||||
.button { background:#eee url(images/button.gif) repeat-x 0 0; border:solid 1px #b1a874; color:#7f7f7f; font-size:11px; padding:2px 6px 2px 6px; cursor:pointer; line-height:14px !important; }
|
||||
.button { background:#eee repeat-x 0 0; border:solid 1px #b1a874; color:#7f7f7f; font-size:11px; padding:2px 6px 2px 6px; cursor:pointer; line-height:14px !important; }
|
||||
.button:hover { color:#333; border-color:#857b42; }
|
||||
|
||||
.field, .button { -moz-border-radius:4px; -webkit-border-radius:4px; }
|
||||
@@ -126,7 +126,7 @@ a.ico:hover { color:#333;}
|
||||
font-size: 12px;
|
||||
}
|
||||
#status .success {
|
||||
margin: 0px:
|
||||
margin: 0px;
|
||||
}
|
||||
#version {
|
||||
position: absolute; top: 10px; right: 10px;
|
||||
|
@@ -43,6 +43,7 @@
|
||||
'Statistics' => 'statistics',
|
||||
'Visitors' => 'visitors',
|
||||
'Players' => 'players',
|
||||
'Items' => 'items',
|
||||
'Tools' => array(
|
||||
'phpinfo' => 'phpinfo'
|
||||
),
|
||||
|
26
common.php
26
common.php
@@ -21,14 +21,14 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
session_start();
|
||||
|
||||
define('MYAAC', true);
|
||||
define('MYAAC_VERSION', '0.6.0');
|
||||
define('DATABASE_VERSION', 11);
|
||||
define('MYAAC_VERSION', '0.6.3');
|
||||
define('DATABASE_VERSION', 15);
|
||||
define('TABLE_PREFIX', 'myaac_');
|
||||
define('START_TIME', microtime(true));
|
||||
define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX'));
|
||||
@@ -60,6 +60,7 @@ define('CACHE', SYSTEM . 'cache/');
|
||||
define('LOCALE', SYSTEM . 'locale/');
|
||||
define('LIBS', SYSTEM . 'libs/');
|
||||
define('LOGS', SYSTEM . 'logs/');
|
||||
define('PAGES', SYSTEM . 'pages/');
|
||||
define('PLUGINS', BASE . 'plugins/');
|
||||
define('TEMPLATES', BASE . 'templates/');
|
||||
define('TOOLS', BASE . 'tools/');
|
||||
@@ -85,12 +86,15 @@ $basedir = str_replace('/admin', '', $basedir);
|
||||
$basedir = str_replace('/install', '', $basedir);
|
||||
define('BASE_DIR', $basedir);
|
||||
|
||||
if(isset($_SERVER['HTTPS'][0]) && $_SERVER['HTTPS'] == 'on')
|
||||
define('SERVER_URL', 'https://' . $_SERVER['HTTP_HOST']);
|
||||
else
|
||||
define('SERVER_URL', 'http://' . $_SERVER['HTTP_HOST']);
|
||||
|
||||
define('BASE_URL', SERVER_URL . BASE_DIR . '/');
|
||||
define('ADMIN_URL', SERVER_URL . BASE_DIR . '/admin/');
|
||||
//define('CURRENT_URL', BASE_URL . $_SERVER['REQUEST_URI']);
|
||||
if(isset($_SERVER['HTTP_HOST'])) {
|
||||
if (isset($_SERVER['HTTPS'][0]) && $_SERVER['HTTPS'] == 'on')
|
||||
define('SERVER_URL', 'https://' . $_SERVER['HTTP_HOST']);
|
||||
else
|
||||
define('SERVER_URL', 'http://' . $_SERVER['HTTP_HOST']);
|
||||
|
||||
define('BASE_URL', SERVER_URL . BASE_DIR . '/');
|
||||
define('ADMIN_URL', SERVER_URL . BASE_DIR . '/admin/');
|
||||
|
||||
//define('CURRENT_URL', BASE_URL . $_SERVER['REQUEST_URI']);
|
||||
}
|
||||
?>
|
||||
|
@@ -13,7 +13,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
|
||||
@@ -30,6 +30,7 @@ $config = array(
|
||||
// used for the Downloads page and some templates aswell
|
||||
'client' => 1098, // 954 = client 9.54
|
||||
|
||||
'session_prefix' => 'myaac_', // must be unique for every site on your server
|
||||
'friendly_urls' => false, // mod_rewrite is required for this, it makes links looks more elegant to eye, and also are SEO friendly (example: http://my-aac.org/guilds/Testing instead of http://my-aac.org/?subtopic=guilds&name=Testing). Remember to rename .htaccess.dist to .htaccess
|
||||
'gzip_output' => false, // gzip page content before sending it to the browser, uses less bandwidth but more cpu cycles
|
||||
|
||||
|
51
index.php
51
index.php
@@ -21,7 +21,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
// ini_set('display_startup_errors', 1);
|
||||
// error_reporting(E_ALL);
|
||||
|
||||
if(preg_match("/^(.*)\.(gif|png|jpg|jpeg|tiff|bmp|css|js|less|map|html|php|zip|rar|gz)$/i", $_SERVER['REQUEST_URI'])) {
|
||||
if(preg_match("/^(.*)\.(gif|jpg|jpeg|tiff|bmp|css|js|less|map|html|php|zip|rar|gz)$/i", $_SERVER['REQUEST_URI'])) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
@@ -54,13 +54,21 @@ if(!empty($tmp))
|
||||
else
|
||||
$uri = str_replace_first('/', '', $uri);
|
||||
|
||||
$uri = strtolower(str_replace(array('index.php/', '?'), '', $uri));
|
||||
$uri = str_replace(array('index.php/', '?'), '', $uri);
|
||||
|
||||
$found = false;
|
||||
if(empty($uri) || isset($_REQUEST['template'])) {
|
||||
$_REQUEST['p'] = 'news';
|
||||
$found = true;
|
||||
}
|
||||
else if(preg_match("/^[A-Za-z0-9-_%\'+]+\.png$/i", $uri)) {
|
||||
$tmp = explode('.', $uri);
|
||||
$_REQUEST['name'] = urldecode($tmp[0]);
|
||||
|
||||
chdir(TOOLS . 'signature');
|
||||
include(TOOLS . 'signature/index.php');
|
||||
exit();
|
||||
}
|
||||
else if(!preg_match('/[^A-z0-9_\-]/', $uri) && file_exists(SYSTEM . 'pages/' . $uri . '.php')) {
|
||||
$_REQUEST['p'] = $uri;
|
||||
$found = true;
|
||||
@@ -71,17 +79,17 @@ else {
|
||||
'/^account\/create\/?$/' => array('subtopic' => 'createaccount'),
|
||||
'/^account\/lost\/?$/' => array('subtopic' => 'lostaccount'),
|
||||
'/^account\/logout\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'logout'),
|
||||
'/^account\/password\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changepassword'),
|
||||
'/^account\/register\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'registeraccount'),
|
||||
'/^account\/register\/new\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'registernew'),
|
||||
'/^account\/email\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changeemail'),
|
||||
'/^account\/info\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changeinfo'),
|
||||
'/^account\/character\/create\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'createcharacter'),
|
||||
'/^account\/character\/name\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changename'),
|
||||
'/^account\/character\/sex\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changesex'),
|
||||
'/^account\/character\/delete\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'deletecharacter'),
|
||||
'/^account\/character\/comment\/[A-Za-z]+\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changecomment', 'name' => '$3'),
|
||||
'/^account\/character\/comment\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changecomment'),
|
||||
'/^account\/password\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_password'),
|
||||
'/^account\/register\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'register'),
|
||||
'/^account\/register\/new\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'register_new'),
|
||||
'/^account\/email\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_email'),
|
||||
'/^account\/info\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_info'),
|
||||
'/^account\/character\/create\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'create_character'),
|
||||
'/^account\/character\/name\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_name'),
|
||||
'/^account\/character\/sex\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_sex'),
|
||||
'/^account\/character\/delete\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'delete_character'),
|
||||
'/^account\/character\/comment\/[A-Za-z]+\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_comment', 'name' => '$3'),
|
||||
'/^account\/character\/comment\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_comment'),
|
||||
'/^characters\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'characters', 'name' => '$1'),
|
||||
'/^commands\/add\/?$/' => array('subtopic' => 'commands', 'action' => 'add'),
|
||||
'/^commands\/edit\/?$/' => array('subtopic' => 'commands', 'action' => 'edit'),
|
||||
@@ -106,22 +114,15 @@ else {
|
||||
'/^news\/edit\/?$/' => array('subtopic' => 'news', 'action' => 'edit'),
|
||||
'/^news\/archive\/?$/' => array('subtopic' => 'newsarchive'),
|
||||
'/^news\/archive\/[0-9]+\/?$/' => array('subtopic' => 'newsarchive', 'id' => '$2'),
|
||||
'/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1')
|
||||
'/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1'),
|
||||
'/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2'),
|
||||
);
|
||||
|
||||
if (preg_match("/^[A-Za-z0-9-_%\'+]+\.png$/i", $uri)) {
|
||||
$tmp = explode('.', $uri);
|
||||
$_REQUEST['name'] = urldecode($tmp[0]);
|
||||
|
||||
chdir(TOOLS . 'signature');
|
||||
include('index.php');
|
||||
exit();
|
||||
}
|
||||
|
||||
foreach($rules as $rule => $redirect) {
|
||||
if (preg_match($rule, $uri)) {
|
||||
$tmp = explode('/', $uri);
|
||||
foreach($redirect as $key => $value) {
|
||||
|
||||
if(strpos($value, '$') !== false) {
|
||||
$value = str_replace('$' . $value[1], $tmp[$value[1]], $value);
|
||||
}
|
||||
@@ -154,9 +155,9 @@ define('PAGE', $page);
|
||||
$template_place_holders = array();
|
||||
|
||||
require_once(SYSTEM . 'init.php');
|
||||
require_once(SYSTEM . 'template.php');
|
||||
require_once(SYSTEM . 'login.php');
|
||||
require_once(SYSTEM . 'status.php');
|
||||
require_once(SYSTEM . 'template.php');
|
||||
|
||||
$twig->addGlobal('config', $config);
|
||||
$twig->addGlobal('status', $status);
|
||||
|
@@ -85,6 +85,8 @@ CREATE TABLE `myaac_forum_boards`
|
||||
`description` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
`closed` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`guild` INT(11) NOT NULL DEFAULT 0,
|
||||
`access` INT(11) NOT NULL DEFAULT 0,
|
||||
`hidden` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
@@ -128,22 +130,31 @@ CREATE TABLE `myaac_hooks`
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_items`
|
||||
(
|
||||
`id` INT(11) NOT NULL,
|
||||
`article` VARCHAR(5) NOT NULL DEFAULT '',
|
||||
`name` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
`plural` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
`attributes` VARCHAR(500) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_monsters` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`hide_creature` tinyint(1) NOT NULL default '0',
|
||||
`hidden` tinyint(1) NOT NULL default 0,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`mana` int(11) NOT NULL,
|
||||
`mana` int(11) NOT NULL DEFAULT 0,
|
||||
`exp` int(11) NOT NULL,
|
||||
`health` int(11) NOT NULL,
|
||||
`speed_lvl` int(11) NOT NULL default '1',
|
||||
`speed_lvl` int(11) NOT NULL default 1,
|
||||
`use_haste` tinyint(1) NOT NULL,
|
||||
`voices` text NOT NULL,
|
||||
`immunities` varchar(255) NOT NULL,
|
||||
`summonable` tinyint(1) NOT NULL,
|
||||
`convinceable` tinyint(1) NOT NULL,
|
||||
`race` varchar(255) NOT NULL,
|
||||
`gfx_name` varchar(255) NOT NULL,
|
||||
`file_path` varchar(255) NOT NULL,
|
||||
`loot` varchar(500) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
@@ -235,17 +246,18 @@ CREATE TABLE `myaac_spells`
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`words` VARCHAR(255) NOT NULL,
|
||||
`category` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - attack, 2 - healing, 3 - summon, 4 - supply, 5 - support',
|
||||
`type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - instant, 2 - rune',
|
||||
`type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - instant, 2 - conjure, 3 - rune',
|
||||
`level` INT(11) NOT NULL DEFAULT 0,
|
||||
`maglevel` INT(11) NOT NULL DEFAULT 0,
|
||||
`mana` INT(11) NOT NULL DEFAULT 0,
|
||||
`soul` TINYINT(3) NOT NULL DEFAULT 0,
|
||||
`conjure_count` TINYINT(3) NOT NULL DEFAULT 0,
|
||||
`item_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`premium` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`vocations` VARCHAR(32) NOT NULL,
|
||||
`vocations` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
`hidden` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`spell`)
|
||||
UNIQUE (`name`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_visitors`
|
||||
@@ -255,3 +267,12 @@ CREATE TABLE `myaac_visitors`
|
||||
`page` VARCHAR(100) NOT NULL,
|
||||
UNIQUE (`ip`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_weapons`
|
||||
(
|
||||
`id` INT(11) NOT NULL,
|
||||
`level` INT(11) NOT NULL DEFAULT 0,
|
||||
`maglevel` INT(11) NOT NULL DEFAULT 0,
|
||||
`vocations` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
@@ -78,7 +78,7 @@ else {
|
||||
else
|
||||
$player_db->setAccountId($account_db->getId());
|
||||
|
||||
$_SESSION['account'] = $account_db->getId();
|
||||
setSession('account', $account_db->getId());
|
||||
}
|
||||
else {
|
||||
$new_account = new OTS_Account();
|
||||
@@ -108,12 +108,12 @@ else {
|
||||
else
|
||||
$player_db->setAccountId($new_account->getId());
|
||||
|
||||
$_SESSION['account'] = $new_account->getId();
|
||||
setSession('account', $new_account->getId());
|
||||
}
|
||||
|
||||
success($locale['step_database_created_account']);
|
||||
$_SESSION['password'] = encrypt($password);
|
||||
$_SESSION['remember_me'] = true;
|
||||
setSession('password', encrypt($password));
|
||||
setSession('remember_me', true);
|
||||
|
||||
if($player_db->isLoaded()) {
|
||||
$player_db->save();
|
||||
@@ -143,31 +143,31 @@ INSERT INTO `myaac_news` (`id`, `type`, `date`, `category`, `title`, `body`, `pl
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Rook Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Rook Sample', 4, " . $_SESSION['account'] . ", 1, 0, 150, 150, 4200, 118, 114, 38, 57, 130, 0, 0, 0, 0, 100, 11, 2200, 1298, 7, '', 400, 1, 1255179613, 2453925456, 1, 1255179614, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
if(!query($insert_into_players . "(null, 'Rook Sample', 4, " . getSession('account') . ", 1, 0, 150, 150, 4200, 118, 114, 38, 57, 130, 0, 0, 0, 0, 100, 11, 2200, 1298, 7, '', 400, 1, 1255179613, 2453925456, 1, 1255179614, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Sorcerer Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Sorcerer Sample', 4, " . $_SESSION['account'] . ", 8, 1, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179571, 2453925456, 1, 1255179612, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
if(!query($insert_into_players . "(null, 'Sorcerer Sample', 4, " . getSession('account') . ", 8, 1, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179571, 2453925456, 1, 1255179612, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Druid Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Druid Sample', 4, " . $_SESSION['account'] . ", 8, 2, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179655, 2453925456, 1, 1255179658, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
if(!query($insert_into_players . "(null, 'Druid Sample', 4, " . getSession('account') . ", 8, 2, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179655, 2453925456, 1, 1255179658, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Paladin Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Paladin Sample', 4, " . $_SESSION['account'] . ", 8, 3, 185, 185, 4200, 118, 114, 38, 57, 129, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179854, 2453925456, 1, 1255179858, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
if(!query($insert_into_players . "(null, 'Paladin Sample', 4, " . getSession('account') . ", 8, 3, 185, 185, 4200, 118, 114, 38, 57, 129, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179854, 2453925456, 1, 1255179858, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Knight Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Knight Sample', 4, " . $_SESSION['account'] . ", 8, 4, 185, 185, 4200, 118, 114, 38, 57, 131, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179620, 2453925456, 1, 1255179654, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
if(!query($insert_into_players . "(null, 'Knight Sample', 4, " . getSession('account') . ", 8, 4, 185, 185, 4200, 118, 114, 38, 57, 131, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179620, 2453925456, 1, 1255179654, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
}
|
||||
|
||||
@@ -175,13 +175,26 @@ INSERT INTO `myaac_news` (`id`, `type`, `date`, `category`, `title`, `body`, `pl
|
||||
success($locale['step_database_imported_players']);
|
||||
}
|
||||
|
||||
require LIBS . 'creatures.php';
|
||||
if(Creatures::loadFromXML())
|
||||
success($locale['step_database_loaded_creatures']);
|
||||
require(LIBS . 'creatures.php');
|
||||
if(Creatures::loadFromXML()) {
|
||||
success($locale['step_database_loaded_monsters']);
|
||||
|
||||
if(Creatures::getMonstersList()->hasErrors()) {
|
||||
$locale['step_database_error_monsters'] = str_replace('$LOG$', 'system/logs/error.log', $locale['step_database_error_monsters']);
|
||||
warning($locale['step_database_error_monsters']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
error(Creatures::getLastError());
|
||||
}
|
||||
|
||||
require LIBS . 'spells.php';
|
||||
if(Spells::loadFromXML())
|
||||
require(LIBS . 'spells.php');
|
||||
if(Spells::loadFromXML()) {
|
||||
success($locale['step_database_loaded_spells']);
|
||||
}
|
||||
else {
|
||||
error(Spells::getLastError());
|
||||
}
|
||||
|
||||
$locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(ADMIN_URL, $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']);
|
||||
$locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(BASE_URL, $locale['step_finish_homepage'], true), $locale['step_finish_desc']);
|
||||
|
@@ -22,7 +22,7 @@ function version_check($name, $ok, $info = '', $warning = false)
|
||||
$failed = false;
|
||||
|
||||
// start validating
|
||||
version_check($locale['step_requirements_php_version'], (PHP_VERSION_ID >= 50200), PHP_VERSION);
|
||||
version_check($locale['step_requirements_php_version'], (PHP_VERSION_ID >= 50300), PHP_VERSION);
|
||||
foreach(array('config.local.php', 'images/guilds', 'images/houses', 'images/gallery') as $value)
|
||||
{
|
||||
$perms = (int) substr(decoct(fileperms(BASE . $value)), 2);
|
||||
|
38
system/bin/install_plugin.php
Normal file
38
system/bin/install_plugin.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
if(php_sapi_name() != "cli") {
|
||||
die('This script can be run only in command line mode.');
|
||||
}
|
||||
|
||||
require_once('../../common.php');
|
||||
require_once(SYSTEM . 'functions.php');
|
||||
require_once(SYSTEM . 'init.php');
|
||||
require_once(LIBS . 'plugins.php');
|
||||
|
||||
if($argc != 2) {
|
||||
exit('This command expects one parameter: zip file name (plugin)' . PHP_EOL);
|
||||
}
|
||||
|
||||
$path_to_file = $argv[1];
|
||||
$ext = strtolower(pathinfo($path_to_file, PATHINFO_EXTENSION));
|
||||
if($ext != 'zip') {// check if it is zipped/compressed file
|
||||
exit('Please install only .zip files.' . PHP_EOL);
|
||||
}
|
||||
|
||||
if(!file_exists($path_to_file)) {
|
||||
exit('ERROR: File ' . $path_to_file . ' does not exist' . PHP_EOL);
|
||||
}
|
||||
|
||||
if(Plugins::install($path_to_file)) {
|
||||
foreach(Plugins::getWarnings() as $warning) {
|
||||
echo 'WARNING: ' . $warning;
|
||||
}
|
||||
|
||||
$info = Plugins::getPluginInfo();
|
||||
echo (isset($info['name']) ? $info['name'] . ' p' : 'P') . 'lugin has been successfully installed.';
|
||||
}
|
||||
else
|
||||
echo 'ERROR: ' . Plugins::getError();
|
||||
|
||||
echo PHP_EOL;
|
||||
?>
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Database connection
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(!isset($config['database_type'][0]) || !isset($config['database_user'][0]) || !isset($config['database_password'][0]) || !isset($config['database_name'][0]))
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -117,14 +117,32 @@ function getGuildLink($name, $generate = true)
|
||||
return generateLink($url, $name);
|
||||
}
|
||||
|
||||
function getItemNameById($id) {
|
||||
global $db;
|
||||
$query = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'items` WHERE `id` = ' . $db->quote($id) . ' LIMIT 1;');
|
||||
if($query->rowCount() == 1) {
|
||||
$item = $query->fetch();
|
||||
return $item['name'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getItemImage($id, $count = 1)
|
||||
{
|
||||
$tooltip = '';
|
||||
|
||||
$name = getItemNameById($id);
|
||||
if(!empty($name)) {
|
||||
$tooltip = ' class="tooltip" title="' . $name . '"';
|
||||
}
|
||||
|
||||
$file_name = $id;
|
||||
if($count > 1)
|
||||
$file_name .= '-' . $count;
|
||||
|
||||
global $config;
|
||||
return '<img src="' . $config['item_images_url'] . $file_name . '.gif" width="32" height="32" border="0" alt=" ' .$id . '" />';
|
||||
return '<img src="' . $config['item_images_url'] . $file_name . '.gif"' . $tooltip . ' width="32" height="32" border="0" alt=" ' .$id . '" />';
|
||||
}
|
||||
|
||||
function getFlagImage($country)
|
||||
@@ -197,7 +215,7 @@ function generateRandomString($length, $lowCase = true, $upCase = false, $numeri
|
||||
function getForumBoards()
|
||||
{
|
||||
global $db, $canEdit;
|
||||
$sections = $db->query('SELECT `id`, `name`, `description`, `closed`' . ($canEdit ? ', `hidden`, `ordering`' : '') . ' FROM `' . TABLE_PREFIX . 'forum_boards` ' . (!$canEdit ? ' WHERE `hidden` != 1' : '') .
|
||||
$sections = $db->query('SELECT `id`, `name`, `description`, `closed`, `guild`, `access`' . ($canEdit ? ', `hidden`, `ordering`' : '') . ' FROM `' . TABLE_PREFIX . 'forum_boards` ' . (!$canEdit ? ' WHERE `hidden` != 1' : '') .
|
||||
' ORDER BY `ordering`;');
|
||||
if($sections)
|
||||
return $sections->fetchAll();
|
||||
@@ -676,7 +694,7 @@ function getSkillName($skillId, $suffix = true)
|
||||
*/
|
||||
function hasFlag($flag) {
|
||||
global $logged, $logged_flags;
|
||||
return $logged && ($logged_flags & $flag) == $flag;
|
||||
return ($logged && ($logged_flags & $flag) == $flag);
|
||||
}
|
||||
/**
|
||||
* Check if current logged user have got admin flag set.
|
||||
@@ -943,6 +961,19 @@ function str_replace_first($search, $replace, $subject) {
|
||||
return $subject;
|
||||
}
|
||||
|
||||
function setSession($key, $data) {
|
||||
global $config;
|
||||
$_SESSION[$config['session_prefix'] . $key] = $data;
|
||||
}
|
||||
function getSession($key) {
|
||||
global $config;
|
||||
return (isset($_SESSION[$config['session_prefix'] . $key])) ? $_SESSION[$config['session_prefix'] . $key] : false;
|
||||
}
|
||||
function unsetSession($key) {
|
||||
global $config;
|
||||
unset($_SESSION[$config['session_prefix'] . $key]);
|
||||
}
|
||||
|
||||
// validator functions
|
||||
require_once(LIBS . 'validator.php');
|
||||
?>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -25,21 +25,6 @@ define('HOOK_CHARACTERS_AFTER_CHARACTERS', 12);
|
||||
define('HOOK_FIRST', HOOK_STARTUP);
|
||||
define('HOOK_LAST', HOOK_CHARACTERS_AFTER_CHARACTERS);
|
||||
|
||||
$hook_types = array(
|
||||
'STARTUP' => HOOK_STARTUP,
|
||||
'BEFORE_PAGE' => HOOK_BEFORE_PAGE,
|
||||
'AFTER_PAGE' => HOOK_AFTER_PAGE,
|
||||
'FINISH' => HOOK_FINISH,
|
||||
'TIBIACOM_ARTICLE' => HOOK_TIBIACOM_ARTICLE,
|
||||
'TIBIACOM_BORDER_3' => HOOK_TIBIACOM_BORDER_3,
|
||||
'CHARACTERS_BEFORE_INFORMATIONS' => HOOK_CHARACTERS_BEFORE_INFORMATIONS,
|
||||
'CHARACTERS_AFTER_INFORMATIONS' => HOOK_CHARACTERS_AFTER_INFORMATIONS,
|
||||
'CHARACTERS_BEFORE_SIGNATURE' => HOOK_CHARACTERS_BEFORE_SIGNATURE,
|
||||
'CHARACTERS_AFTER_SIGNATURE' => HOOK_CHARACTERS_AFTER_SIGNATURE,
|
||||
'CHARACTERS_AFTER_ACCOUNT' => HOOK_CHARACTERS_AFTER_ACCOUNT,
|
||||
'CHARACTERS_AFTER_CHARACTERS' => HOOK_CHARACTERS_AFTER_CHARACTERS
|
||||
);
|
||||
|
||||
class Hook
|
||||
{
|
||||
private $_name, $_type, $_file;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -15,6 +15,7 @@ if(file_exists(BASE . 'config.local.php')) // user customizations
|
||||
require(BASE . 'config.local.php');
|
||||
|
||||
if(!isset($config['installed']) || !$config['installed']) {
|
||||
header('Location: ' . BASE_URL);
|
||||
die('AAC has not been installed yet or there was error during installation. Please install again.');
|
||||
}
|
||||
|
||||
|
@@ -5,21 +5,21 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
require_once(SYSTEM . 'libs/items.php');
|
||||
require_once(SYSTEM . 'libs/items_images.php');
|
||||
|
||||
Items::$files = array(
|
||||
Items_Images::$files = array(
|
||||
'otb' => SYSTEM . 'data/items.otb',
|
||||
'spr' => SYSTEM . 'data/Tibia.spr',
|
||||
'dat' => SYSTEM . 'data/Tibia.dat'
|
||||
);
|
||||
Items::$outputDir = BASE . 'images/items/';
|
||||
Items_Images::$outputDir = BASE . 'images/items/';
|
||||
|
||||
function generateItem($id = 100, $count = 1) {
|
||||
Items::generate($id, $count);
|
||||
Items_Images::generate($id, $count);
|
||||
}
|
||||
|
||||
function itemImageExists($id, $count = 1)
|
||||
@@ -31,7 +31,7 @@ function itemImageExists($id, $count = 1)
|
||||
if($count > 1)
|
||||
$file_name .= '-' . $count;
|
||||
|
||||
$file_name = Items::$outputDir . $file_name . '.gif';
|
||||
$file_name = Items_Images::$outputDir . $file_name . '.gif';
|
||||
return file_exists($file_name);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ function outputItem($id = 100, $count = 1)
|
||||
if(!itemImageExists($id, $count))
|
||||
{
|
||||
//echo 'plik istnieje';
|
||||
Items::generate($id, $count);
|
||||
Items_Images::generate($id, $count);
|
||||
}
|
||||
|
||||
$expires = 60 * 60 * 24 * 30; // 30 days
|
||||
@@ -56,7 +56,7 @@ function outputItem($id = 100, $count = 1)
|
||||
if($count > 1)
|
||||
$file_name .= '-' . $count;
|
||||
|
||||
$file_name = Items::$outputDir . $file_name . '.gif';
|
||||
$file_name = Items_Images::$outputDir . $file_name . '.gif';
|
||||
readfile($file_name);
|
||||
}
|
||||
?>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @author Mark Samman (Talaturen) <marksamman@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @author Mark Samman (Talaturen) <marksamman@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @author Mark Samman (Talaturen) <marksamman@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @author Mark Samman (Talaturen) <marksamman@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,12 +6,15 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Creatures {
|
||||
private static $monstersList = null;
|
||||
private static $lastError = '';
|
||||
|
||||
public static function loadFromXML($show = false) {
|
||||
global $config, $db;
|
||||
|
||||
@@ -22,22 +25,35 @@ class Creatures {
|
||||
echo "<h2>All records deleted from table 'myaac_monsters' in database.</h2>";
|
||||
}
|
||||
|
||||
$allmonsters = new OTS_MonstersList($config['data_path'].'monster/');
|
||||
try {
|
||||
self::$monstersList = new OTS_MonstersList($config['data_path'].'monster/');
|
||||
}
|
||||
catch(Exception $e) {
|
||||
self::$lastError = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
$items = array();
|
||||
$items_db = $db->query('SELECT `id`, `name` FROM `' . TABLE_PREFIX . 'items`;');
|
||||
foreach($items_db->fetchAll() as $item) {
|
||||
$items[$item['name']] = $item['id'];
|
||||
}
|
||||
|
||||
//$names_added must be an array
|
||||
$names_added[] = '';
|
||||
//add monsters
|
||||
foreach($allmonsters as $lol) {
|
||||
$monster = $allmonsters->current();
|
||||
foreach(self::$monstersList as $lol) {
|
||||
$monster = self::$monstersList->current();
|
||||
if(!$monster->loaded()) {
|
||||
if($show) {
|
||||
warning('Error while adding monster: ' . $allmonsters->currentFile());
|
||||
warning('Error while adding monster: ' . self::$monstersList->currentFile());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//load monster mana needed to summon/convince
|
||||
$mana = $monster->getManaCost();
|
||||
//load monster experience
|
||||
$exp = $monster->getExperience();
|
||||
|
||||
//load monster name
|
||||
$name = $monster->getName();
|
||||
//load monster health
|
||||
@@ -57,51 +73,44 @@ class Creatures {
|
||||
$use_haste = 1;
|
||||
}
|
||||
}
|
||||
//load monster flags
|
||||
$flags = $monster->getFlags();
|
||||
//create string with immunities
|
||||
$immunities = $monster->getImmunities();
|
||||
$imu_nr = 0;
|
||||
$imu_count = count($immunities);
|
||||
$immunities_string = '';
|
||||
foreach($immunities as $immunitie) {
|
||||
$immunities_string .= $immunitie;
|
||||
$imu_nr++;
|
||||
if($imu_count != $imu_nr) {
|
||||
$immunities_string .= ", ";
|
||||
}
|
||||
}
|
||||
|
||||
//create string with voices
|
||||
$voices = $monster->getVoices();
|
||||
$voice_nr = 0;
|
||||
$voice_count = count($voices);
|
||||
$voices_string = '';
|
||||
foreach($voices as $voice) {
|
||||
$voices_string .= '"'.$voice.'"';
|
||||
$voice_nr++;
|
||||
if($voice_count != $voice_nr) {
|
||||
$voices_string .= ", ";
|
||||
}
|
||||
}
|
||||
//load race
|
||||
$race = $monster->getRace();
|
||||
//create monster gfx name
|
||||
//$gfx_name = str_replace(" ", "", trim(mb_strtolower($name))).".gif";
|
||||
$gfx_name = trim(mb_strtolower($name)).".gif";
|
||||
//don't add 2 monsters with same name, like Butterfly
|
||||
|
||||
|
||||
//load monster flags
|
||||
$flags = $monster->getFlags();
|
||||
if(!isset($flags['summonable']))
|
||||
$flags['summonable'] = '0';
|
||||
if(!isset($flags['convinceable']))
|
||||
$flags['convinceable'] = '0';
|
||||
|
||||
$loot = $monster->getLoot();
|
||||
foreach($loot as &$item) {
|
||||
if(!Validator::number($item['id'])) {
|
||||
if(isset($items[$item['id']])) {
|
||||
$item['id'] = $items[$item['id']];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!in_array($name, $names_added)) {
|
||||
try {
|
||||
$db->query("INSERT INTO `myaac_monsters` (`hide_creature`, `name`, `mana`, `exp`, `health`, `speed_lvl`, `use_haste`, `voices`, `immunities`, `summonable`, `convinceable`, `race`, `gfx_name`, `file_path`) VALUES (0, " . $db->quote($name) . ", " . $db->quote(empty($mana) ? 0 : $mana) . ", " . $db->quote($exp) . ", " . $db->quote($health) . ", " . $db->quote($speed_lvl) . ", " . $db->quote($use_haste) . ", " . $db->quote($voices_string) . ", " . $db->quote($immunities_string) . ", " . $db->quote($flags['summonable'] > 0 ? 1 : 0) . ", " . $db->quote($flags['convinceable'] > 0 ? 1 : 0) . ", ".$db->quote($race).", ".$db->quote($gfx_name).", " . $db->quote($allmonsters->currentFile()) . ")");
|
||||
$db->insert(TABLE_PREFIX . 'monsters', array(
|
||||
'name' => $name,
|
||||
'mana' => empty($mana) ? 0 : $mana,
|
||||
'exp' => $monster->getExperience(),
|
||||
'health' => $health,
|
||||
'speed_lvl' => $speed_lvl,
|
||||
'use_haste' => $use_haste,
|
||||
'voices' => json_encode($monster->getVoices()),
|
||||
'immunities' => json_encode($monster->getImmunities()),
|
||||
'summonable' => $flags['summonable'] > 0 ? 1 : 0,
|
||||
'convinceable' => $flags['convinceable'] > 0 ? 1 : 0,
|
||||
'race' => $race,
|
||||
'loot' => json_encode($loot)
|
||||
));
|
||||
|
||||
if($show) {
|
||||
success("Added: ".$name."<br/>");
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
@@ -116,4 +125,12 @@ class Creatures {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getMonstersList() {
|
||||
return self::$monstersList;
|
||||
}
|
||||
|
||||
public static function getLastError() {
|
||||
return self::$lastError;
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -3,264 +3,143 @@
|
||||
* Items class
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if ( !function_exists( 'stackId' ) )
|
||||
{
|
||||
function stackId( $count )
|
||||
class Items {
|
||||
private static $error = '';
|
||||
|
||||
public static function loadFromXML($show = false)
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
global $config, $db;
|
||||
|
||||
try {
|
||||
$db->query("DELETE FROM `myaac_items`;");
|
||||
} catch (PDOException $error) {
|
||||
}
|
||||
|
||||
self::$lastItem = array_sum( unpack( 'x4/S*', fread( self::$dat, 12 )));
|
||||
if($id > self::$lastItem)
|
||||
|
||||
$file_path = $config['data_path'] . 'items/items.xml';
|
||||
if (!file_exists($file_path)) {
|
||||
self::$error = 'Cannot load file ' . $file_path;
|
||||
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 )];
|
||||
|
||||
$xml = new DOMDocument;
|
||||
$xml->load($file_path);
|
||||
|
||||
foreach ($xml->getElementsByTagName('item') as $item) {
|
||||
if ($item->getAttribute('fromid')) {
|
||||
for ($id = $item->getAttribute('fromid'); $id <= $item->getAttribute('toid'); $id++) {
|
||||
self::parseNode($id, $item, $show);
|
||||
}
|
||||
} else
|
||||
self::parseNode($item->getAttribute('id'), $item, $show);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function parseNode($id, $node, $show = false) {
|
||||
global $db;
|
||||
|
||||
$name = $node->getAttribute('name');
|
||||
$article = $node->getAttribute('article');
|
||||
$plural = $node->getAttribute('plural');
|
||||
|
||||
$attributes = array();
|
||||
foreach($node->getElementsByTagName('attribute') as $attr) {
|
||||
$attributes[strtolower($attr->getAttribute('key'))] = $attr->getAttribute('value');
|
||||
}
|
||||
|
||||
$exist = $db->query('SELECT `id` FROM `' . TABLE_PREFIX . 'items` WHERE `id` = ' . $id);
|
||||
if($exist->rowCount() > 0) {
|
||||
if($show) {
|
||||
warning('Duplicated item with id: ' . $id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sprites = (array) $sprites[array_rand( $sprites ) ];
|
||||
$db->insert(TABLE_PREFIX . 'items', array('id' => $id, 'article' => $article, 'name' => $name, 'plural' => $plural, 'attributes' => json_encode($attributes)));
|
||||
}
|
||||
|
||||
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)
|
||||
die('ERROR: Cannot load data files.');
|
||||
/*
|
||||
if ( $nostand )
|
||||
{
|
||||
for( $i = 0; $i < sizeof( $sprites ) / 4; $i++ )
|
||||
{
|
||||
$sprites = array_merge( (array) $sprites, array_reverse( array_slice( $sprites, $i * 4, 4 ) ) );
|
||||
|
||||
public static function getError() {
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
public static function getItem($id) {
|
||||
global $db;
|
||||
|
||||
$item = $db->select(TABLE_PREFIX . 'items', array('id' => $id));
|
||||
$item['attributes'] = json_decode($item['attributes']);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getDescription($id, $count = 1) {
|
||||
global $config, $db;
|
||||
|
||||
$item = self::getItem($id);
|
||||
|
||||
$attr = $item['attributes'];
|
||||
$s = '';
|
||||
if(!empty($item['name'])) {
|
||||
if($count > 1) {
|
||||
if($attr['showcount']) {
|
||||
$s .= $count . ' ';
|
||||
}
|
||||
|
||||
if(!empty($item['plural'])) {
|
||||
$s .= $item['plural'];
|
||||
}
|
||||
else if((int)$attr['showcount'] == 0) {
|
||||
$s .= $item['name'];
|
||||
}
|
||||
else {
|
||||
$s .= $item['name'] . 's';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!empty($item['aticle'])) {
|
||||
$s .= $item['article'] . ' ';
|
||||
}
|
||||
|
||||
$s .= $item['name'];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sprites = (array) $sprites[array_rand( $sprites ) ];
|
||||
$s .= 'an item of type ' . $item['id'];
|
||||
|
||||
if(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) {
|
||||
$s .= '. ' . ($count > 1 ? "They" : "It") . ' can only be used by ';
|
||||
}
|
||||
|
||||
if(!empty(trim($query['vocations']))) {
|
||||
$vocations = json_decode($query['vocations']);
|
||||
if(count($vocations) > 0) {
|
||||
foreach($vocations as $voc => $show) {
|
||||
$vocations[$config['vocations'][$voc]] = $show;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$s .= 'players';
|
||||
}
|
||||
|
||||
$s .= ' with';
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
self::$loaded = true;
|
||||
return $s;
|
||||
}
|
||||
|
||||
public static function loaded() {
|
||||
return self::$loaded;
|
||||
}
|
||||
}
|
||||
}
|
266
system/libs/items_images.php
Normal file
266
system/libs/items_images.php
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
/**
|
||||
* Items_Images class
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://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)
|
||||
die('ERROR: Cannot load data files.');
|
||||
/*
|
||||
if ( $nostand )
|
||||
{
|
||||
for( $i = 0; $i < sizeof( $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;
|
||||
}
|
||||
}
|
152
system/libs/plugins.php
Normal file
152
system/libs/plugins.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugins class
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Plugins {
|
||||
private static $warnings = array();
|
||||
private static $error = null;
|
||||
private static $pluginInfo = array();
|
||||
|
||||
public static function install($file) {
|
||||
global $db, $cache;
|
||||
|
||||
$zip = new ZipArchive();
|
||||
if($zip->open($file)) {
|
||||
for ($i = 0; $i < $zip->numFiles; $i++) {
|
||||
$tmp = $zip->getNameIndex($i);
|
||||
if(pathinfo($tmp, PATHINFO_DIRNAME) == 'plugins' && pathinfo($tmp, PATHINFO_EXTENSION) == 'json')
|
||||
$json_file = $tmp;
|
||||
}
|
||||
|
||||
if(!isset($json_file)) {
|
||||
self::$error = 'Cannot find plugin info .json file. Installation is discontinued.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if($zip->extractTo(BASE)) { // place in the directory with same name
|
||||
$file_name = BASE . $json_file;
|
||||
if(!file_exists($file_name)) {
|
||||
self::$error = "Cannot load " . $file_name . ". File doesn't exist.";
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$string = file_get_contents($file_name);
|
||||
$plugin = json_decode($string, true);
|
||||
self::$pluginInfo = $plugin;
|
||||
if ($plugin == null) {
|
||||
self::$warnings[] = 'Cannot load ' . $file_name . '. File might be not a valid json code.';
|
||||
}
|
||||
else {
|
||||
$continue = true;
|
||||
|
||||
if(!isset($plugin['name'])) {
|
||||
self::$warnings[] = 'Plugin "name" tag is not set.';
|
||||
}
|
||||
if(!isset($plugin['description'])) {
|
||||
self::$warnings[] = 'Plugin "description" tag is not set.';
|
||||
}
|
||||
if(!isset($plugin['version'])) {
|
||||
self::$warnings[] = 'Plugin "version" tag is not set.';
|
||||
}
|
||||
if(!isset($plugin['author'])) {
|
||||
self::$warnings[] = 'Plugin "author" tag is not set.';
|
||||
}
|
||||
if(!isset($plugin['contact'])) {
|
||||
self::$warnings[] = 'Plugin "contact" tag is not set.';
|
||||
}
|
||||
|
||||
if(isset($plugin['require'])) {
|
||||
$require = $plugin['require'];
|
||||
if(isset($require['myaac'])) {
|
||||
$require_myaac = $require['myaac'];
|
||||
if(version_compare(MYAAC_VERSION, $require_myaac, '<')) {
|
||||
self::$warnings[] = "This plugin requires MyAAC version " . $require_myaac . ", you're using version " . MYAAC_VERSION . " - please update.";
|
||||
$continue = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($require['php'])) {
|
||||
$require_php = $require['php'];
|
||||
if(version_compare(phpversion(), $require_php, '<')) {
|
||||
self::$warnings[] = "This plugin requires PHP version " . $require_php . ", you're using version " . phpversion() . " - please update.";
|
||||
$continue = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($require['database'])) {
|
||||
$require_database = $require['database'];
|
||||
if($require_database < DATABASE_VERSION) {
|
||||
self::$warnings[] = "This plugin requires database version " . $require_database . ", you're using version " . DATABASE_VERSION . " - please update.";
|
||||
$continue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($continue) {
|
||||
if (isset($plugin['install'])) {
|
||||
if (file_exists(BASE . $plugin['install']))
|
||||
require(BASE . $plugin['install']);
|
||||
else
|
||||
self::$warnings[] = 'Cannot load install script. Your plugin might be not working correctly.';
|
||||
}
|
||||
|
||||
if (isset($plugin['hooks'])) {
|
||||
foreach ($plugin['hooks'] as $_name => $info) {
|
||||
if (defined('HOOK_'. $info['type'])) {
|
||||
$hook = constant('HOOK_'. $info['type']);
|
||||
$query = $db->query('SELECT `id` FROM `' . TABLE_PREFIX . 'hooks` WHERE `name` = ' . $db->quote($_name) . ';');
|
||||
if ($query->rowCount() == 1) { // found something
|
||||
$query = $query->fetch();
|
||||
$db->update(TABLE_PREFIX . 'hooks', array('type' => $hook, 'file' => $info['file']), array('id' => (int)$query['id']));
|
||||
} else {
|
||||
$db->insert(TABLE_PREFIX . 'hooks', array('id' => 'NULL', 'name' => $_name, 'type' => $hook, 'file' => $info['file']));
|
||||
}
|
||||
} else
|
||||
self::$warnings[] = 'Unknown event type: ' . $info['type'];
|
||||
}
|
||||
}
|
||||
|
||||
if($cache->enabled()) {
|
||||
$cache->delete('templates');
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
self::$error = 'There was a problem with extracting zip archive.';
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
}
|
||||
else {
|
||||
self::$error = 'There was a problem with opening zip archive.';
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getWarnings() {
|
||||
return self::$warnings;
|
||||
}
|
||||
|
||||
public static function getError() {
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
public static function getPluginInfo() {
|
||||
return self::$pluginInfo;
|
||||
}
|
||||
}
|
@@ -334,14 +334,17 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
throw new E_OTS_NotLoaded();
|
||||
}
|
||||
|
||||
if(fieldExist('premdays', 'accounts'))
|
||||
return $this->data['premdays'];
|
||||
|
||||
if($this->data['lastday'] == 0)
|
||||
return 0;
|
||||
|
||||
return round(($this->data['lastday'] - time()) / (24 * 60 * 60), 3);
|
||||
//return $this->data['premdays'] - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->data['lastday']))) - date("z", $this->data['lastday']));
|
||||
}
|
||||
|
||||
public function getLastLogin()
|
||||
|
||||
public function getLastLogin()
|
||||
{
|
||||
if( !isset($this->data['lastday']) )
|
||||
{
|
||||
@@ -350,11 +353,14 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
|
||||
return $this->data['lastday'];
|
||||
}
|
||||
|
||||
|
||||
public function isPremium()
|
||||
{
|
||||
global $config;
|
||||
if(isset($config['lua']['freePremium']) && getBoolean($config['lua']['freePremium'])) return true;
|
||||
if(fieldExist('premdays', 'accounts'))
|
||||
return $this->data['premdays'] > 0;
|
||||
|
||||
return $this->data['lastday'] > time();
|
||||
//return ($this->data['premdays'] - (date("z", time()) + (365 * (date("Y", time()) - date("Y", $this->data['lastday']))) - date("z", $this->data['lastday'])) > 0);
|
||||
}
|
||||
@@ -818,34 +824,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*/
|
||||
public function getAccess()
|
||||
{
|
||||
global $groups;
|
||||
if(!isset($groups))
|
||||
$groups = new OTS_Groups_List();
|
||||
|
||||
// by default
|
||||
$access = 0;
|
||||
if(fieldExist('group_id', 'accounts')) {
|
||||
$query = $this->db->query('SELECT `group_id` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch();
|
||||
// if anything was found
|
||||
|
||||
$group = $groups->getGroup($query['group_id']);
|
||||
if(!$group) return 0;
|
||||
return $group->getAccess();
|
||||
}
|
||||
|
||||
// finds groups of all characters
|
||||
foreach( $this->getPlayersList() as $player)
|
||||
{
|
||||
$group = $player->getGroup();
|
||||
|
||||
// checks if group's access level is higher then previouls found highest
|
||||
if( $group->getAccess() > $access)
|
||||
{
|
||||
$access = $group->getAccess();
|
||||
}
|
||||
}
|
||||
|
||||
return $access;
|
||||
return $this->getGroupId();
|
||||
}
|
||||
|
||||
public function getGroupId()
|
||||
@@ -858,10 +837,12 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
return $query['group_id'];
|
||||
}
|
||||
|
||||
$db->query('SELECT `group_id` FROM `players` WHERE `account_id` = ' . $this->getId() . ' ORDER BY `group_id` DESC LIMIT 1')->fetch();
|
||||
if(isset($query['group_id']))
|
||||
$query = $this->db->query('SELECT `group_id` FROM `players` WHERE `account_id` = ' . (int) $this->getId() . ' ORDER BY `group_id` DESC LIMIT 1');
|
||||
if($query->rowCount() == 1)
|
||||
{
|
||||
$query = $query->fetch();
|
||||
return $query['group_id'];
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -74,6 +74,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*
|
||||
* @version 0.1.3
|
||||
*/
|
||||
/*
|
||||
public function __clone()
|
||||
{
|
||||
unset($this->data['id']);
|
||||
@@ -90,7 +91,7 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$this->requests->__construct($this);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/**
|
||||
* Assigns invites handler.
|
||||
*
|
||||
@@ -282,6 +283,26 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$this->data['ownerid'] = $owner->getId();
|
||||
}
|
||||
|
||||
public function hasMember(OTS_Player $player) {
|
||||
global $db;
|
||||
|
||||
if(!$player || !$player->isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$player_rank = $player->getRank();
|
||||
if(!$player_rank->isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($this->getGuildRanksList() as $rank) {
|
||||
if($rank->getId() == $player_rank->getId()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Guild creation data.
|
||||
*
|
||||
|
@@ -194,7 +194,6 @@ class OTS_Monster extends DOMDocument
|
||||
|
||||
/**
|
||||
* @return array List of item IDs.
|
||||
* @deprecated 0.1.0 Use getItems().
|
||||
*/
|
||||
public function getLoot()
|
||||
{
|
||||
@@ -208,13 +207,25 @@ class OTS_Monster extends DOMDocument
|
||||
// adds all items
|
||||
foreach( $element->getElementsByTagName('item') as $item)
|
||||
{
|
||||
$id = $item->getAttribute('id');
|
||||
|
||||
// avoid redundancy
|
||||
if( !in_array($id, $loot) )
|
||||
{
|
||||
$loot[] = $id;
|
||||
$chance = $item->getAttribute('chance');
|
||||
if(empty($chance)) {
|
||||
$chance = $item->getAttribute('chance1');
|
||||
if(empty($chance)) {
|
||||
$chance = 100000;
|
||||
}
|
||||
}
|
||||
|
||||
$count = $item->getAttribute('countmax');
|
||||
if(empty($count)) {
|
||||
$count = 1;
|
||||
}
|
||||
|
||||
$id = $item->getAttribute('id');
|
||||
if(empty($id)) {
|
||||
$id = $item->getAttribute('name');
|
||||
}
|
||||
|
||||
$loot[] = array('id' => $id, 'count' => $count, 'chance' => $chance);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -36,6 +36,8 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
*/
|
||||
private $monsters = array();
|
||||
|
||||
private $lastMonsterFile = '';
|
||||
private $hasErrors = false;
|
||||
/**
|
||||
* Loads monsters mapping file.
|
||||
*
|
||||
@@ -57,9 +59,18 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
$this->monstersPath .= '/';
|
||||
}
|
||||
|
||||
// check if monsters.xml exist
|
||||
if(!@file_exists($this->monstersPath . 'monsters.xml')) {
|
||||
log_append('error.log', '[OTS_MonstersList.php] Fatal error: Cannot load monsters.xml. File does not exist. (' . $this->monstersPath . 'monsters.xml' . '). Error: ' . print_r(error_get_last(), true));
|
||||
throw new Exception('Error: Cannot load monsters.xml. File not found. More info in system/logs/error.log file.');
|
||||
}
|
||||
|
||||
// loads monsters mapping file
|
||||
$monsters = new DOMDocument();
|
||||
$monsters->load($this->monstersPath . 'monsters.xml');
|
||||
if(!@$monsters->load($this->monstersPath . 'monsters.xml')) {
|
||||
log_append('error.log', '[OTS_MonstersList.php] Fatal error: Cannot load monsters.xml (' . $this->monstersPath . 'monsters.xml' . '). Error: ' . print_r(error_get_last(), true));
|
||||
throw new Exception('Error: Cannot load monsters.xml. File is invalid. More info in system/logs/error.log file.');
|
||||
}
|
||||
|
||||
foreach( $monsters->getElementsByTagName('monster') as $monster)
|
||||
{
|
||||
@@ -101,6 +112,16 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
return isset($this->monsters[$name]);
|
||||
}
|
||||
|
||||
function xmlErrorHandler($errno, $errstr, $errfile, $errline)
|
||||
{
|
||||
if($errno==E_WARNING && (substr_count($errstr,"DOMDocument::loadXML()")>0)) {
|
||||
//throw new DOMException($errstr);
|
||||
log_append('error.log', '[OTS_MonstersList.php] Fatal error: Cannot load ' . $this->lastMonsterFile . ' - ' . $errstr);
|
||||
$this->hasErrors = true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Returns loaded data of given monster.
|
||||
*
|
||||
@@ -112,21 +133,31 @@ class OTS_MonstersList implements Iterator, Countable, ArrayAccess
|
||||
*/
|
||||
public function getMonster($name)
|
||||
{
|
||||
global $lastMonsterFile;
|
||||
// checks if monster exists
|
||||
if( isset($this->monsters[$name]) )
|
||||
{
|
||||
// loads file
|
||||
$monster = new OTS_Monster();
|
||||
//echo $this->monstersPath . $this->monsters[$name];
|
||||
|
||||
// check if monster file exist
|
||||
if(file_exists($this->monstersPath . $this->monsters[$name])) {
|
||||
$monster->loadXML(trim(file_get_contents($this->monstersPath . $this->monsters[$name])));
|
||||
set_error_handler(array($this, 'xmlErrorHandler'));
|
||||
$this->lastMonsterFile = $this->monstersPath . $this->monsters[$name];
|
||||
@$monster->loadXML(trim(file_get_contents($this->monstersPath . $this->monsters[$name])));
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
return $monster;
|
||||
}
|
||||
|
||||
throw new OutOfBoundsException();
|
||||
}
|
||||
|
||||
public function hasErrors() {
|
||||
return $this->hasErrors;
|
||||
}
|
||||
/**
|
||||
* Returns amount of monsters loaded.
|
||||
*
|
||||
|
@@ -315,19 +315,50 @@ class OTS_Spell
|
||||
*/
|
||||
public function getVocations()
|
||||
{
|
||||
$vocations = array();
|
||||
global $config;
|
||||
if(!isset($config['vocation_ids']))
|
||||
$config['vocations_ids'] = array_flip($config['vocations']);
|
||||
|
||||
$vocations = array();
|
||||
|
||||
foreach( $this->element->getElementsByTagName('vocation') as $vocation)
|
||||
{
|
||||
if($vocation->getAttribute('id') != NULL)
|
||||
$vocations[] = $vocation->getAttribute('id');
|
||||
else
|
||||
$vocations[] = $vocation->getAttribute('name');
|
||||
if($vocation->getAttribute('id') != NULL) {
|
||||
$voc_id = $vocation->getAttribute('id');
|
||||
}
|
||||
else {
|
||||
$voc_id = $config['vocations_ids'][$vocation->getAttribute('name')];
|
||||
}
|
||||
|
||||
$vocations[] = $voc_id;
|
||||
}
|
||||
|
||||
return $vocations;
|
||||
}
|
||||
|
||||
|
||||
public function getVocationsFull()
|
||||
{
|
||||
global $config;
|
||||
if(!isset($config['vocation_ids']))
|
||||
$config['vocations_ids'] = array_flip($config['vocations']);
|
||||
|
||||
$vocations = array();
|
||||
|
||||
foreach( $this->element->getElementsByTagName('vocation') as $vocation)
|
||||
{
|
||||
$show = $vocation->getAttribute('showInDescription');
|
||||
if($vocation->getAttribute('id') != NULL) {
|
||||
$voc_id = $vocation->getAttribute('id');
|
||||
}
|
||||
else {
|
||||
$voc_id = $config['vocations_ids'][$vocation->getAttribute('name')];
|
||||
}
|
||||
|
||||
$vocations[$voc_id] = strlen($show) == 0 || $show != '0';
|
||||
}
|
||||
|
||||
return $vocations;
|
||||
}
|
||||
/**
|
||||
* Creates conjure item.
|
||||
*
|
||||
|
@@ -93,9 +93,18 @@ class OTS_SpellsList implements IteratorAggregate, Countable
|
||||
*/
|
||||
public function __construct($file)
|
||||
{
|
||||
// loads DOM document
|
||||
// check if spells.xml exist
|
||||
if(!@file_exists($file)) {
|
||||
log_append('error.log', '[OTS_SpellsList.php] Fatal error: Cannot load spells.xml. File does not exist. (' . $file . '). Error: ' . print_r(error_get_last(), true));
|
||||
throw new Exception('Error: Cannot load spells.xml. File not found. More info in system/logs/error.log file.');
|
||||
}
|
||||
|
||||
// loads monsters mapping file
|
||||
$spells = new DOMDocument();
|
||||
$spells->load($file);
|
||||
if(!@$spells->load($file)) {
|
||||
log_append('error.log', '[OTS_SpellsList.php] Fatal error: Cannot load spells.xml (' . $file . '). Error: ' . print_r(error_get_last(), true));
|
||||
throw new Exception('Error: Cannot load spells.xml. File is invalid. More info in system/logs/error.log file.');
|
||||
}
|
||||
|
||||
// loads runes
|
||||
foreach( $spells->getElementsByTagName('rune') as $rune)
|
||||
|
@@ -6,12 +6,15 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Spells {
|
||||
private static $spellsList = null;
|
||||
private static $lastError = '';
|
||||
|
||||
public static function loadFromXML($show = false) {
|
||||
global $config, $db;
|
||||
|
||||
@@ -22,62 +25,45 @@ class Spells {
|
||||
echo '<h2>All records deleted from table <b>' . TABLE_PREFIX . 'spells</b> in database.</h2>';
|
||||
}
|
||||
|
||||
foreach($config['vocations'] as $voc_id => $voc_name) {
|
||||
$vocations_ids[$voc_name] = $voc_id;
|
||||
try {
|
||||
self::$spellsList = new OTS_SpellsList($config['data_path'].'spells/spells.xml');
|
||||
}
|
||||
catch(Exception $e) {
|
||||
self::$lastError = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
$allspells = new OTS_SpellsList($config['data_path'].'spells/spells.xml');
|
||||
//add conjure spells
|
||||
$conjurelist = $allspells->getConjuresList();
|
||||
$conjurelist = self::$spellsList->getConjuresList();
|
||||
if($show) {
|
||||
echo "<h3>Conjure:</h3>";
|
||||
}
|
||||
|
||||
foreach($conjurelist as $spellname) {
|
||||
$spell = $allspells->getConjure($spellname);
|
||||
$lvl = $spell->getLevel();
|
||||
$mlvl = $spell->getMagicLevel();
|
||||
$mana = $spell->getMana();
|
||||
$spell = self::$spellsList->getConjure($spellname);
|
||||
$name = $spell->getName();
|
||||
$soul = $spell->getSoul();
|
||||
$spell_txt = $spell->getWords();
|
||||
$vocations = $spell->getVocations();
|
||||
$nr_of_vocations = count($vocations);
|
||||
$vocations_to_db = "";
|
||||
$voc_nr = 0;
|
||||
foreach($vocations as $vocation_to_add) {
|
||||
if(Validator::number($vocation_to_add)) {
|
||||
$vocations_to_db .= $vocation_to_add;
|
||||
}
|
||||
else
|
||||
$vocations_to_db .= $vocations_ids[$vocation_to_add];
|
||||
$voc_nr++;
|
||||
|
||||
if($voc_nr != $nr_of_vocations) {
|
||||
$vocations_to_db .= ',';
|
||||
}
|
||||
}
|
||||
|
||||
$enabled = $spell->isEnabled();
|
||||
if($enabled) {
|
||||
$hide_spell = 0;
|
||||
}
|
||||
else {
|
||||
$hide_spell = 1;
|
||||
}
|
||||
$pacc = $spell->isPremium();
|
||||
if($pacc) {
|
||||
$pacc = '1';
|
||||
}
|
||||
else {
|
||||
$pacc = '0';
|
||||
}
|
||||
$type = 2;
|
||||
$count = $spell->getConjureCount();
|
||||
$words = $spell->getWords();
|
||||
if(strpos($words, '#') !== false)
|
||||
continue;
|
||||
|
||||
try {
|
||||
$db->query('INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (' . $db->quote($spell_txt) . ', ' . $db->quote($name) . ', ' . $db->quote($spell_txt) . ', ' . $db->quote($type) . ', ' . $db->quote($mana) . ', ' . $db->quote($lvl) . ', ' . $db->quote($mlvl) . ', ' . $db->quote($soul) . ', ' . $db->quote($pacc) . ', ' . $db->quote($vocations_to_db) . ', ' . $db->quote($count) . ', ' . $db->quote($hide_spell) . ')');
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
'name' => $name,
|
||||
'words' => $words,
|
||||
'type' => 2,
|
||||
'mana' => $spell->getMana(),
|
||||
'level' => $spell->getLevel(),
|
||||
'maglevel' => $spell->getMagicLevel(),
|
||||
'soul' => $spell->getSoul(),
|
||||
'premium' => $spell->isPremium() ? 1 : 0,
|
||||
'vocations' => json_encode($spell->getVocations()),
|
||||
'conjure_count' => $spell->getConjureCount(),
|
||||
'hidden' => $spell->isEnabled() ? 0 : 1
|
||||
));
|
||||
|
||||
if($show) {
|
||||
success("Added: " . $name . "<br>");
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
@@ -87,59 +73,75 @@ class Spells {
|
||||
}
|
||||
}
|
||||
|
||||
//add instant spells
|
||||
$instantlist = $allspells->getInstantsList();
|
||||
// add instant spells
|
||||
$instantlist = self::$spellsList->getInstantsList();
|
||||
if($show) {
|
||||
echo "<h3>Instant:</h3>";
|
||||
}
|
||||
|
||||
foreach($instantlist as $spellname) {
|
||||
$spell = $allspells->getInstant($spellname);
|
||||
$lvl = $spell->getLevel();
|
||||
$mlvl = $spell->getMagicLevel();
|
||||
$mana = $spell->getMana();
|
||||
$spell = self::$spellsList->getInstant($spellname);
|
||||
$name = $spell->getName();
|
||||
$soul = $spell->getSoul();
|
||||
$spell_txt = $spell->getWords();
|
||||
if(strpos($spell_txt, '###') !== false)
|
||||
|
||||
$words = $spell->getWords();
|
||||
if(strpos($words, '#') !== false)
|
||||
continue;
|
||||
|
||||
$vocations = $spell->getVocations();
|
||||
$nr_of_vocations = count($vocations);
|
||||
$vocations_to_db = "";
|
||||
$voc_nr = 0;
|
||||
foreach($vocations as $vocation_to_add) {
|
||||
if(Validator::number($vocation_to_add)) {
|
||||
$vocations_to_db .= $vocation_to_add;
|
||||
}
|
||||
else
|
||||
$vocations_to_db .= $vocations_ids[$vocation_to_add];
|
||||
$voc_nr++;
|
||||
|
||||
if($voc_nr != $nr_of_vocations) {
|
||||
$vocations_to_db .= ',';
|
||||
}
|
||||
}
|
||||
$enabled = $spell->isEnabled();
|
||||
if($enabled) {
|
||||
$hide_spell = 0;
|
||||
}
|
||||
else {
|
||||
$hide_spell = 1;
|
||||
}
|
||||
$pacc = $spell->isPremium();
|
||||
if($pacc) {
|
||||
$pacc = '1';
|
||||
}
|
||||
else {
|
||||
$pacc = '0';
|
||||
}
|
||||
$type = 1;
|
||||
$count = 0;
|
||||
try {
|
||||
$db->query("INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (".$db->quote($spell_txt).", ".$db->quote($name).", ".$db->quote($spell_txt).", '".$type."', '".$mana."', '".$lvl."', '".$mlvl."', '".$soul."', '".$pacc."', '".$vocations_to_db."', '".$count."', '".$hide_spell."')");
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
'name' => $name,
|
||||
'words' => $words,
|
||||
'type' => 1,
|
||||
'mana' => $spell->getMana(),
|
||||
'level' => $spell->getLevel(),
|
||||
'maglevel' => $spell->getMagicLevel(),
|
||||
'soul' => $spell->getSoul(),
|
||||
'premium' => $spell->isPremium() ? 1 : 0,
|
||||
'vocations' => json_encode($spell->getVocations()),
|
||||
'conjure_count' => 0,
|
||||
'hidden' => $spell->isEnabled() ? 0 : 1
|
||||
));
|
||||
|
||||
if($show) {
|
||||
success("Added: ".$name."<br/>");
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
if($show) {
|
||||
warning('Error while adding spell (' . $name . '): ' . $error->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add runes
|
||||
$runeslist = self::$spellsList->getRunesList();
|
||||
if($show) {
|
||||
echo "<h3>Runes:</h3>";
|
||||
}
|
||||
|
||||
foreach($runeslist as $spellname) {
|
||||
$spell = self::$spellsList->getRune($spellname);
|
||||
|
||||
$name = $spell->getName() . ' (rune)';
|
||||
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'spells', array(
|
||||
'name' => $name,
|
||||
'words' => $spell->getWords(),
|
||||
'type' => 3,
|
||||
'mana' => $spell->getMana(),
|
||||
'level' => $spell->getLevel(),
|
||||
'maglevel' => $spell->getMagicLevel(),
|
||||
'soul' => $spell->getSoul(),
|
||||
'premium' => $spell->isPremium() ? 1 : 0,
|
||||
'vocations' => json_encode($spell->getVocations()),
|
||||
'conjure_count' => 0,
|
||||
'item_id' => $spell->getID(),
|
||||
'hidden' => $spell->isEnabled() ? 0 : 1
|
||||
));
|
||||
|
||||
if($show) {
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
@@ -151,4 +153,12 @@ class Spells {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getSpellsList() {
|
||||
return self::$spellsList;
|
||||
}
|
||||
|
||||
public static function getLastError() {
|
||||
return self::$lastError;
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
123
system/libs/usage_statistics.php
Normal file
123
system/libs/usage_statistics.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* Usage Statistics
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Usage_Statistics {
|
||||
public static function report() {
|
||||
$url = 'http://my-acc.org/report_usage.php';
|
||||
//$url = BASE_URL . 'report_usage.php';
|
||||
|
||||
$data = json_encode(self::getStats());
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => 'Content-type: application/json',
|
||||
'method' => 'POST',
|
||||
'content' => $data
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$result = file_get_contents($url, false, $context);
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
//var_dump($result);
|
||||
}
|
||||
|
||||
public static function getStats() {
|
||||
global $config, $db;
|
||||
|
||||
$ret = array();
|
||||
|
||||
$ret['unique_id'] = hash('sha1', $config['server_path']);
|
||||
$ret['server_os'] = php_uname('s') . ' ' . php_uname('r');
|
||||
|
||||
$ret['myaac_version'] = MYAAC_VERSION;
|
||||
$ret['myaac_db_version'] = DATABASE_VERSION;
|
||||
|
||||
$query = $db->query('SELECT `value` FROM `server_config` WHERE `config` = ' . $db->quote('database_version'));
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$ret['otserv_db_version'] = $query['value'];
|
||||
}
|
||||
|
||||
$ret['client_version'] = $config['client'];
|
||||
|
||||
$ret['php_version'] = phpversion();
|
||||
|
||||
$query = $db->query('SELECT VERSION() as `version`;');
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$ret['mysql_version'] = $query['version'];
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT SUM(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 ), 0)) AS "size"
|
||||
FROM INFORMATION_SCHEMA.TABLES
|
||||
WHERE TABLE_SCHEMA = "forgottenserver";');
|
||||
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$ret['database_size'] = $query['size'];
|
||||
}
|
||||
|
||||
$ret['views_counter'] = getDatabaseConfig('views_counter');
|
||||
|
||||
$query = $db->query('SELECT COUNT(`id`) as `size` FROM `accounts`;');
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$ret['accounts_size'] = $query['size'];
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT COUNT(`id`) as `size` FROM `players`;');
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$ret['players_size'] = $query['size'];
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT COUNT(`id`) as `size` FROM `' . TABLE_PREFIX . 'monsters`;');
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$ret['monsters_size'] = $query['size'];
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT COUNT(`id`) as `size` FROM `' . TABLE_PREFIX . 'spells`;');
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$ret['spells_size'] = $query['size'];
|
||||
}
|
||||
|
||||
$ret['locales'] = get_locales();
|
||||
$ret['plugins'] = array();
|
||||
foreach(get_plugins() as $plugin) {
|
||||
$string = file_get_contents(BASE . 'plugins/' . $plugin . '.json');
|
||||
$plugin_info = json_decode($string, true);
|
||||
if($plugin_info != false) {
|
||||
if(isset($plugin_info['version'])) {
|
||||
$ret['plugins'][$plugin] = $plugin_info['version'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$ret['templates'] = get_templates();
|
||||
|
||||
$ret['date_timezone'] = $config['date_timezone'];
|
||||
$ret['backward_support'] = $config['backward_support'];
|
||||
|
||||
$cache_engine = strtolower($config['cache_engine']);
|
||||
if($cache_engine == 'auto') {
|
||||
$cache_engine = Cache::detect();
|
||||
}
|
||||
|
||||
$ret['cache_engine'] = $cache_engine;
|
||||
return $ret;
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
82
system/libs/weapons.php
Normal file
82
system/libs/weapons.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Weapons class
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Weapons {
|
||||
private static $error = '';
|
||||
|
||||
public static function loadFromXML($show = false)
|
||||
{
|
||||
global $config, $db;
|
||||
|
||||
try {
|
||||
$db->query("DELETE FROM `myaac_weapons`;");
|
||||
} catch (PDOException $error) {
|
||||
}
|
||||
|
||||
$file_path = $config['data_path'] . 'weapons/weapons.xml';
|
||||
if (!file_exists($file_path)) {
|
||||
self::$error = 'Cannot load file ' . $file_path;
|
||||
return false;
|
||||
}
|
||||
|
||||
$xml = new DOMDocument;
|
||||
$xml->load($file_path);
|
||||
|
||||
foreach ($xml->getElementsByTagName('wand') as $weapon) {
|
||||
self::parseNode($weapon, $show);
|
||||
}
|
||||
foreach ($xml->getElementsByTagName('melee') as $weapon) {
|
||||
self::parseNode($weapon, $show);
|
||||
}
|
||||
foreach ($xml->getElementsByTagName('distance') as $weapon) {
|
||||
self::parseNode($weapon, $show);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function parseNode($node, $show = false) {
|
||||
global $config, $db;
|
||||
|
||||
$id = (int)$node->getAttribute('id');
|
||||
$vocations_ids = array_flip($config['vocations']);
|
||||
$level = (int)$node->getAttribute('level');
|
||||
$maglevel = (int)$node->getAttribute('maglevel');
|
||||
|
||||
$vocations = array();
|
||||
foreach($node->getElementsByTagName('vocation') as $vocation) {
|
||||
$show = $vocation->getAttribute('showInDescription');
|
||||
if(!empty($vocation->getAttribute('id')))
|
||||
$voc_id = $vocation->getAttribute('id');
|
||||
else {
|
||||
$voc_id = $vocations_ids[$vocation->getAttribute('name')];
|
||||
}
|
||||
|
||||
$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($show) {
|
||||
warning('Duplicated weapon with id: ' . $id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$db->insert(TABLE_PREFIX . 'weapons', array('id' => $id, 'level' => $level, 'maglevel' => $maglevel, 'vocations' => json_encode($vocations)));
|
||||
}
|
||||
}
|
||||
|
||||
public static function getError() {
|
||||
return self::$error;
|
||||
}
|
||||
}
|
@@ -69,7 +69,8 @@ $locale['step_database_adding_field'] = 'Adding field';
|
||||
$locale['step_database_modifying_field'] = 'Modifying field';
|
||||
$locale['step_database_changing_field'] = 'Changing $FIELD$ to $FIELD_NEW$...';
|
||||
$locale['step_database_imported_players'] = 'Imported player samples...';
|
||||
$locale['step_database_loaded_creatures'] = 'Loaded creatures...';
|
||||
$locale['step_database_loaded_monsters'] = 'Loaded monsters...';
|
||||
$locale['step_database_error_monsters'] = 'There were some problems loading your monsters.xml file. Please check $LOG$ for more info.';
|
||||
$locale['step_database_loaded_spells'] = 'Loaded spells...';
|
||||
$locale['step_database_created_account'] = 'Created admin account...';
|
||||
$locale['step_database_created_news'] = 'Created newses...';
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -15,9 +15,9 @@ $logged_flags = 0;
|
||||
$action = isset($_REQUEST['action']) ? strtolower($_REQUEST['action']) : '';
|
||||
if($action == 'logout' && !isset($_REQUEST['account_login']))
|
||||
{
|
||||
unset($_SESSION['account']);
|
||||
unset($_SESSION['password']);
|
||||
unset($_SESSION['remember_me']);
|
||||
unsetSession('account');
|
||||
unsetSession('password');
|
||||
unsetSession('remember_me');
|
||||
|
||||
if(isset($_REQUEST['redirect']))
|
||||
{
|
||||
@@ -68,19 +68,19 @@ else
|
||||
&& (!isset($t) || $t['attempts'] < 5)
|
||||
)
|
||||
{
|
||||
$_SESSION['account'] = $account_logged->getId();
|
||||
$_SESSION['password'] = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $login_password);
|
||||
setSession('account', $account_logged->getId());
|
||||
setSession('password', encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $login_password));
|
||||
if(isset($_POST['remember_me']))
|
||||
$_SESSION['remember_me'] = true;
|
||||
setSession('remember_me', true);
|
||||
|
||||
$logged = true;
|
||||
$logged_flags = $account_logged->getWebFlags();
|
||||
|
||||
if(isset($_POST['admin']) && !admin()) {
|
||||
$errors[] = 'This account has no admin privileges.';
|
||||
unset($_SESSION['account']);
|
||||
unset($_SESSION['password']);
|
||||
unset($_SESSION['remember_me']);
|
||||
unsetSession('account');
|
||||
unsetSession('password');
|
||||
unsetSession('remember_me');
|
||||
$logged = false;
|
||||
}
|
||||
else {
|
||||
@@ -119,19 +119,20 @@ else
|
||||
}
|
||||
|
||||
// stay-logged with sessions
|
||||
if(isset($_SESSION['account']))
|
||||
$current_session = getSession('account');
|
||||
if($current_session !== false)
|
||||
{
|
||||
$account_logged = new OTS_Account();
|
||||
$account_logged->load($_SESSION['account']);
|
||||
if($account_logged->isLoaded() && $account_logged->getPassword() == $_SESSION['password']
|
||||
$account_logged->load($current_session);
|
||||
if($account_logged->isLoaded() && $account_logged->getPassword() == getSession('password')
|
||||
//&& (!isset($_SESSION['admin']) || admin())
|
||||
&& (isset($_SESSION['remember_me']) || $_SESSION['last_visit'] > time() - 15 * 60)) { // login for 15 minutes if "remember me" is not used
|
||||
&& (getSession('remember_me') !== false || getSession('last_visit') > time() - 15 * 60)) { // login for 15 minutes if "remember me" is not used
|
||||
$logged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$logged = false;
|
||||
unset($_SESSION['account']);
|
||||
unsetSession('account');
|
||||
unset($account_logged);
|
||||
}
|
||||
}
|
||||
@@ -143,8 +144,9 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION['last_visit'] = time();
|
||||
if(defined('PAGE'))
|
||||
$_SESSION['last_page'] = PAGE;
|
||||
$_SESSION['last_uri'] = $_SERVER['REQUEST_URI'];
|
||||
setSession('last_visit', time());
|
||||
if(defined('PAGE')) {
|
||||
setSession('last_page', PAGE);
|
||||
}
|
||||
setSession('last_uri', $_SERVER['REQUEST_URI']);
|
||||
?>
|
||||
|
49
system/migrations/12.php
Normal file
49
system/migrations/12.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
// add new item_id field for runes
|
||||
if(!fieldExist('item_id', TABLE_PREFIX . 'spells'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` ADD `item_id` INT(11) NOT NULL DEFAULT 0 AFTER `conjure_count`;");
|
||||
|
||||
// change unique index from spell to name
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` DROP INDEX `spell`;");
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` ADD UNIQUE INDEX (`name`);");
|
||||
|
||||
// change comment of spells.type
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` MODIFY `type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - instant, 2 - conjure, 3 - rune';");
|
||||
|
||||
// new items table
|
||||
if(!tableExist(TABLE_PREFIX . 'items'))
|
||||
$db->query("
|
||||
CREATE TABLE `" . TABLE_PREFIX . "items`
|
||||
(
|
||||
`id` INT(11) NOT NULL,
|
||||
`article` VARCHAR(5) NOT NULL DEFAULT '',
|
||||
`name` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
`plural` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
`attributes` VARCHAR(500) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;");
|
||||
|
||||
// new weapons table
|
||||
if(!tableExist(TABLE_PREFIX . 'weapons'))
|
||||
$db->query("
|
||||
CREATE TABLE `" . TABLE_PREFIX . "weapons`
|
||||
(
|
||||
`id` INT(11) NOT NULL,
|
||||
`level` INT(11) NOT NULL DEFAULT 0,
|
||||
`maglevel` INT(11) NOT NULL DEFAULT 0,
|
||||
`vocations` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;");
|
||||
|
||||
// modify vocations to support json data
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` MODIFY `vocations` VARCHAR(100) NOT NULL DEFAULT '';");
|
||||
$query = $db->query('SELECT `id`, `vocations` FROM `' . TABLE_PREFIX . 'spells`');
|
||||
foreach($query->fetchAll() as $spell) {
|
||||
$tmp = explode(',', $spell['vocations']);
|
||||
foreach($tmp as &$v) {
|
||||
$v = (int)$v;
|
||||
}
|
||||
$db->update(TABLE_PREFIX . 'spells', array('vocations' => json_encode($tmp)), array('id' => $spell['id']));
|
||||
}
|
||||
?>
|
4
system/migrations/13.php
Normal file
4
system/migrations/13.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
if(fieldExist('spell', TABLE_PREFIX . 'spells'))
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` DROP COLUMN `spell`;");
|
||||
?>
|
18
system/migrations/14.php
Normal file
18
system/migrations/14.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
// change monsters.file_path field to loot
|
||||
if(fieldExist('file_path', TABLE_PREFIX . 'monsters')) {
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` CHANGE `file_path` `loot` VARCHAR(5000);");
|
||||
}
|
||||
|
||||
// update loot to empty string
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "monsters` SET `loot` = '';");
|
||||
|
||||
// drop monsters.gfx_name field
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` DROP COLUMN `gfx_name`;");
|
||||
|
||||
// rename hide_creature to hidden
|
||||
if(fieldExist('hide_creature', TABLE_PREFIX . 'monsters')) {
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "monsters` CHANGE `hide_creature` `hidden` TINYINT(1) NOT NULL DEFAULT 0;");
|
||||
}
|
||||
?>
|
11
system/migrations/15.php
Normal file
11
system/migrations/15.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// add new forum.guild and forum.access fields
|
||||
if(!fieldExist('guild', TABLE_PREFIX . 'forum_boards')) {
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "forum_boards` ADD `guild` TINYINT(1) NOT NULL DEFAULT 0 AFTER `closed`;");
|
||||
}
|
||||
|
||||
if(!fieldExist('access', TABLE_PREFIX . 'forum_boards')) {
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "forum_boards` ADD `access` TINYINT(1) NOT NULL DEFAULT 0 AFTER `guild`;");
|
||||
}
|
||||
?>
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
60
system/pages/account/change_comment.php
Normal file
60
system/pages/account/change_comment.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Change comment
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$player_name = isset($_REQUEST['name']) ? stripslashes($_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>.');
|
||||
echo $twig->render('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.";
|
||||
}
|
||||
} else {
|
||||
$errors[] = 'Error. Name contain illegal characters.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Please enter character name.';
|
||||
}
|
||||
|
||||
if($show_form) {
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
if(isset($player)) {
|
||||
echo $twig->render('account.change_comment.html.twig', array(
|
||||
'player' => $player
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
163
system/pages/account/change_email.php
Normal file
163
system/pages/account/change_email.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
/**
|
||||
* Change Email
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$email_new_time = $account_logged->getCustomField("email_new_time");
|
||||
|
||||
if($email_new_time > 10) {
|
||||
$email_new = $account_logged->getCustomField("email_new");
|
||||
}
|
||||
|
||||
if($email_new_time < 10) {
|
||||
if(isset($_POST['changeemailsave']) && $_POST['changeemailsave'] == 1) {
|
||||
$email_new = $_POST['new_email'];
|
||||
$post_password = $_POST['password'];
|
||||
|
||||
if(!Validator::email($email_new)) {
|
||||
$errors[] = Validator::getLastError();
|
||||
}
|
||||
|
||||
if(empty($post_password)) {
|
||||
$errors[] = 'Please enter password to your account.';
|
||||
}
|
||||
else {
|
||||
$post_password = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $post_password);
|
||||
if($post_password != $account_logged->getPassword()) {
|
||||
$errors[] = 'Wrong password to account.';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$email_new_time = time() + $config['account_mail_change'] * 24 * 3600;
|
||||
$account_logged->setCustomField("email_new", $email_new);
|
||||
$account_logged->setCustomField("email_new_time", $email_new_time);
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'New Email Address Requested',
|
||||
'description' => 'You have requested to change your email address to <b>' . $email_new . '</b>. The actual change will take place after <b>' . date("j F Y, G:i:s", $email_new_time) . '</b>, during which you can cancel the request at any time.'
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
//show errors
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
//show form
|
||||
echo $twig->render('account.change_mail.html.twig', array(
|
||||
'new_email' => isset($_POST['new_email']) ? $_POST['new_email'] : null
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $twig->render('account.change_mail.html.twig', array(
|
||||
'new_email' => isset($_POST['new_email']) ? $_POST['new_email'] : null
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if($email_new_time < time()) {
|
||||
if($_POST['changeemailsave'] == 1) {
|
||||
$account_logged->setCustomField("email_new", "");
|
||||
$account_logged->setCustomField("email_new_time", 0);
|
||||
$account_logged->setEmail($email_new);
|
||||
$account_logged->save();
|
||||
$account_logged->logAction('Account email changed to <b>' . $email_new . '</b>');
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Email Address Change Accepted',
|
||||
'description' => 'You have accepted <b>' . $account_logged->getEmail() . '</b> as your new email adress.'
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$custom_buttons = '
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td align=left>
|
||||
<form action="' . getLink('account/email') . '" method="post"><input type="hidden" name="changeemailsave" value=1 >
|
||||
<INPUT TYPE=image NAME="I Agree" SRC="' . $template_path . '/images/global/buttons/sbutton_iagree.gif" BORDER=0 WIDTH=120 HEIGHT=17>
|
||||
</form>
|
||||
</td>
|
||||
<td align=left>
|
||||
<form action="' . getLink('account/email') . '" method="post">
|
||||
<input type="hidden" name="emailchangecancel" value=1 >
|
||||
' . $twig->render('buttons.cancel.html.twig') . '
|
||||
</form>
|
||||
</td>
|
||||
<td align=right>
|
||||
<form action="?subtopic=accountmanagement" method="post" >
|
||||
' . $twig->render('buttons.back.html.twig') . '
|
||||
</form>
|
||||
</td>
|
||||
<td width="30"> </td>
|
||||
</tr>
|
||||
</table>';
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Email Address Change Accepted',
|
||||
'description' => 'Do you accept <b>'.$email_new.'</b> as your new email adress?',
|
||||
'custom_buttons' => $custom_buttons
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$custom_buttons = '
|
||||
<table style="width:100%;" >
|
||||
<tr align="center">
|
||||
<td>
|
||||
<table border="0" cellspacing="0" cellpadding="0" >
|
||||
<form action="{{ ' .getLink('account/email') . ' }}" method="post" >
|
||||
<tr>
|
||||
<td style="border:0px;" >
|
||||
<input type="hidden" name="emailchangecancel" value="1" >
|
||||
' . $twig->render('buttons.cancel.html.twig') . '
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table border="0" cellspacing="0" cellpadding="0" >
|
||||
<form action="' . getLink('account/manage') . '" method="post" >
|
||||
<tr>
|
||||
<td style="border:0px;" >
|
||||
' . $twig->render('buttons.back.html.twig') . '
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Change of Email Address',
|
||||
'description' => 'A request has been submitted to change the email address of this account to <b>'.$email_new.'</b>.<br/>The actual change will take place on <b>'.date("j F Y, G:i:s", $email_new_time).'</b>.<br>If you do not want to change your email address, please click on "Cancel".',
|
||||
'custom_buttons' => $custom_buttons
|
||||
));
|
||||
}
|
||||
}
|
||||
if(isset($_POST['emailchangecancel']) && $_POST['emailchangecancel'] == 1) {
|
||||
$account_logged->setCustomField("email_new", "");
|
||||
$account_logged->setCustomField("email_new_time", 0);
|
||||
|
||||
$custom_buttons = '<center><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=accountmanagement" method="post" ><tr><td style="border:0px;" >' . $twig->render('buttons.back.html.twig') . '</td></tr></form></table></center>';
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Email Address Change Cancelled',
|
||||
'description' => 'Your request to change the email address of your account has been cancelled. The email address will not be changed.',
|
||||
'custom_buttons' => $custom_buttons
|
||||
));
|
||||
}
|
||||
?>
|
62
system/pages/account/change_info.php
Normal file
62
system/pages/account/change_info.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Change info
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$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;
|
||||
$new_country = isset($_POST['info_country']) ? htmlspecialchars(stripslashes($_POST['info_country'])) : NULL;
|
||||
if(isset($_POST['changeinfosave']) && $_POST['changeinfosave'] == 1) {
|
||||
if(!isset($config['countries'][$new_country]))
|
||||
$errors[] = 'Country is not correct.';
|
||||
|
||||
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_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>.');
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Public Information Changed',
|
||||
'description' => 'Your public information has been changed.'
|
||||
));
|
||||
$show_form = false;
|
||||
}
|
||||
else {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
}
|
||||
|
||||
//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");
|
||||
|
||||
$countries = array();
|
||||
foreach (array('pl', 'se', 'br', 'us', 'gb',) as $country)
|
||||
$countries[$country] = $config['countries'][$country];
|
||||
|
||||
$countries['--'] = '----------';
|
||||
|
||||
foreach ($config['countries'] as $code => $country)
|
||||
$countries[$code] = $country;
|
||||
|
||||
echo $twig->render('account.change_info.html.twig', array(
|
||||
'countries' => $countries,
|
||||
'account_rlname' => $account_rlname,
|
||||
'account_location' => $account_location,
|
||||
'account_country' => $account_country
|
||||
));
|
||||
}
|
||||
?>
|
93
system/pages/account/change_name.php
Normal file
93
system/pages/account/change_name.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Change characters name
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
echo '<script type="text/javascript" src="tools/check_name.js"></script>';
|
||||
|
||||
$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']))
|
||||
echo 'Changing character name for premium points is disabled on this server.';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
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(empty($errors) && empty($name))
|
||||
$errors[] = 'Please enter a new name for your character!';
|
||||
else if(strlen($name) > 25)
|
||||
$errors[] = 'Name is too long. Max. lenght <b>25</b> letters.';
|
||||
else if(strlen($name) < 3)
|
||||
$errors[] = 'Name is too short. Min. lenght <b>3</b> letters.';
|
||||
else {
|
||||
$exist = new OTS_Player();
|
||||
$exist->find($name);
|
||||
if($exist->isLoaded()) {
|
||||
$errors[] = 'Character with this name already exist.';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
if(!admin() && !Validator::newCharacterName($name))
|
||||
$errors[] = Validator::getLastError();
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$player = new OTS_Player();
|
||||
$player->load($player_id);
|
||||
if($player->isLoaded()) {
|
||||
$player_account = $player->getAccount();
|
||||
if($account_logged->getId() == $player_account->getId()) {
|
||||
if($player->isOnline()) {
|
||||
$errors[] = 'This character is online.';
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$show_form = false;
|
||||
$old_name = $player->getName();
|
||||
$player->setName($name);
|
||||
$player->save();
|
||||
$account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
|
||||
$account_logged->logAction('Changed name from <b>' . $old_name . '</b> to <b>' . $player->getName() . '</b>.');
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Character Name Changed',
|
||||
'description' => 'The character <b>'.$old_name.'</b> name has been changed to <b>' . $player->getName() . '</b>.'
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character <b>' . $player_name . '</b> is not on your account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = "Character with this name doesn't exist.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($show_form) {
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
echo $twig->render('account.change_name.html.twig', array(
|
||||
'points' => $points,
|
||||
'errors' => $errors
|
||||
//'account_players' => $account_logged->getPlayersList()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
84
system/pages/account/change_password.php
Normal file
84
system/pages/account/change_password.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Change password
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$new_password = isset($_POST['newpassword']) ? $_POST['newpassword'] : NULL;
|
||||
$new_password2 = isset($_POST['newpassword2']) ? $_POST['newpassword2'] : NULL;
|
||||
$old_password = isset($_POST['oldpassword']) ? $_POST['oldpassword'] : NULL;
|
||||
if(empty($new_password) && empty($new_password2) && empty($old_password)) {
|
||||
echo $twig->render('account.change_password.html.twig');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(empty($new_password) || empty($new_password2) || empty($old_password)){
|
||||
$errors[] = "Please fill in form.";
|
||||
}
|
||||
$password_strlen = strlen($new_password);
|
||||
if($new_password != $new_password2) {
|
||||
$errors[] = "The new passwords do not match!";
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
if(!Validator::password($new_password)) {
|
||||
$errors[] = Validator::getLastError();
|
||||
}
|
||||
|
||||
$old_password = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $old_password);
|
||||
if($old_password != $account_logged->getPassword()) {
|
||||
$errors[] = "Current password is incorrect!";
|
||||
}
|
||||
}
|
||||
if(!empty($errors)){
|
||||
//show errors
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
//show form
|
||||
echo $twig->render('account.change_password.html.twig');
|
||||
}
|
||||
else
|
||||
{
|
||||
$org_pass = $new_password;
|
||||
|
||||
if($config_salt_enabled)
|
||||
{
|
||||
$salt = generateRandomString(10, false, true, true);
|
||||
$new_password = $salt . $new_password;
|
||||
$account_logged->setCustomField('salt', $salt);
|
||||
}
|
||||
|
||||
$new_password = encrypt($new_password);
|
||||
$account_logged->setPassword($new_password);
|
||||
$account_logged->save();
|
||||
$account_logged->logAction('Account password changed.');
|
||||
|
||||
$message = '';
|
||||
if($config['mail_enabled'] && $config['send_mail_when_change_password'])
|
||||
{
|
||||
$mailBody = $twig->render('mail.password_changed.html.twig', array(
|
||||
'new_password' => $org_pass
|
||||
));
|
||||
|
||||
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 occorred while sending email with password:<br/>' . $mailer->ErrorInfo . '</p>';
|
||||
}
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Password Changed',
|
||||
'description' => 'Your password has been changed.' . $message
|
||||
));
|
||||
setSession('password', $new_password);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
89
system/pages/account/change_sex.php
Normal file
89
system/pages/account/change_sex.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Change sex
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$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']))
|
||||
echo 'You cant change your character sex';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
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(empty($errors) && !isset($config['genders'][$new_sex])) {
|
||||
$errors[] = 'This sex is invalid.';
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$player = new OTS_Player();
|
||||
$player->load($player_id);
|
||||
|
||||
if($player->isLoaded()) {
|
||||
$player_account = $player->getAccount();
|
||||
|
||||
if($account_logged->getId() == $player_account->getId()) {
|
||||
if($player->isOnline()) {
|
||||
$errors[] = 'This character is online.';
|
||||
}
|
||||
|
||||
if(empty($errors) && $player->getSex() == $new_sex)
|
||||
$errors[] = 'Sex cannot be same';
|
||||
|
||||
if(empty($errors)) {
|
||||
$sex_changed = true;
|
||||
$old_sex = $player->getSex();
|
||||
$player->setSex($new_sex);
|
||||
|
||||
$old_sex_str = 'Unknown';
|
||||
if(isset($config['genders'][$old_sex]))
|
||||
$old_sex_str = $config['genders'][$old_sex];
|
||||
|
||||
$new_sex_str = 'Unknown';
|
||||
if(isset($config['genders'][$new_sex]))
|
||||
$new_sex_str = $config['genders'][$new_sex];
|
||||
|
||||
$player->save();
|
||||
$account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
|
||||
$account_logged->logAction('Changed sex on character <b>' . $player->getName() . '</b> from <b>' . $old_sex_str . '</b> to <b>' . $new_sex_str . '</b>.');
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Character Sex Changed',
|
||||
'description' => 'The character <b>' . $player->getName() . '</b> sex has been changed to <b>' . $new_sex_str . '</b>.'
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character <b>'.$player_name.'</b> is not on your account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = "Character with this name doesn't exist.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$sex_changed) {
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
echo $twig->render('account.change_sex.html.twig', array(
|
||||
'players' => $account_logged->getPlayersList(),
|
||||
'player_sex' => isset($player) ? $player->getSex() : -1,
|
||||
'points' => $points
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
208
system/pages/account/create_character.php
Normal file
208
system/pages/account/create_character.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/**
|
||||
* Create character
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
echo '<script type="text/javascript" src="tools/check_name.js"></script>';
|
||||
$newchar_name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : NULL;
|
||||
$newchar_sex = isset($_POST['sex']) ? $_POST['sex'] : NULL;
|
||||
$newchar_vocation = isset($_POST['vocation']) ? $_POST['vocation'] : NULL;
|
||||
$newchar_town = isset($_POST['town']) ? $_POST['town'] : NULL;
|
||||
|
||||
$newchar_created = false;
|
||||
$save = isset($_POST['save']) && $_POST['save'] == 1;
|
||||
if($save) {
|
||||
if(empty($newchar_name))
|
||||
$errors['name'] = 'Please enter a name for your character!';
|
||||
else if(strlen($newchar_name) > 25)
|
||||
$errors['name'] = 'Name is too long. Max. lenght <b>25</b> letters.';
|
||||
else if(strlen($newchar_name) < 3)
|
||||
$errors['name'] = 'Name is too short. Min. lenght <b>3</b> letters.';
|
||||
else {
|
||||
if(!admin() && !Validator::newCharacterName($newchar_name)) {
|
||||
$errors['name'] = Validator::getLastError();
|
||||
}
|
||||
|
||||
$exist = new OTS_Player();
|
||||
$exist->find($newchar_name);
|
||||
if($exist->isLoaded()) {
|
||||
$errors['name'] = 'Character with this name already exist.';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($newchar_sex) && $newchar_sex != "0")
|
||||
$errors[] = 'Please select the sex for your character!';
|
||||
|
||||
if(count($config['character_samples']) > 1)
|
||||
{
|
||||
if(!isset($newchar_vocation))
|
||||
$errors[] = 'Please select a vocation for your character.';
|
||||
}
|
||||
else
|
||||
$newchar_vocation = $config['character_samples'][0];
|
||||
|
||||
if(count($config['character_towns']) > 1) {
|
||||
if(!isset($newchar_town))
|
||||
$errors[] = 'Please select a town for your character.';
|
||||
}
|
||||
else {
|
||||
$newchar_town = $config['character_towns'][0];
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
if(!isset($config['genders'][$newchar_sex]))
|
||||
$errors[] = 'Sex is invalid.';
|
||||
if(!in_array($newchar_town, $config['character_towns']))
|
||||
$errors[] = 'Please select valid town.';
|
||||
if(count($config['character_samples']) > 1)
|
||||
{
|
||||
$newchar_vocation_check = false;
|
||||
foreach($config['character_samples'] as $char_vocation_key => $sample_char)
|
||||
if($newchar_vocation == $char_vocation_key)
|
||||
$newchar_vocation_check = true;
|
||||
if(!$newchar_vocation_check)
|
||||
$errors[] = 'Unknown vocation. Please fill in form again.';
|
||||
}
|
||||
else
|
||||
$newchar_vocation = 0;
|
||||
}
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$number_of_players_on_account = $account_logged->getPlayersList()->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>!';
|
||||
}
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$char_to_copy_name = $config['character_samples'][$newchar_vocation];
|
||||
$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/config.php and set valid characters to copy names. Character to copy: <b>'.$char_to_copy_name.'</b> doesn\'t exist.';
|
||||
}
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
if($newchar_sex == "0")
|
||||
$char_to_copy->setLookType(136);
|
||||
$player = $ots->createObject('Player');
|
||||
$player->setName($newchar_name);
|
||||
$player->setAccount($account_logged);
|
||||
//$player->setGroupId($char_to_copy->getGroup()->getId());
|
||||
$player->setGroupId(1);
|
||||
$player->setSex($newchar_sex);
|
||||
$player->setVocation($char_to_copy->getVocation());
|
||||
if(fieldExist('promotion', 'players'))
|
||||
$player->setPromotion($char_to_copy->getPromotion());
|
||||
|
||||
if(fieldExist('direction', 'players'))
|
||||
$player->setDirection($char_to_copy->getDirection());
|
||||
|
||||
$player->setConditions($char_to_copy->getConditions());
|
||||
$rank = $char_to_copy->getRank();
|
||||
if($rank->isLoaded()) {
|
||||
$player->setRank($char_to_copy->getRank());
|
||||
}
|
||||
|
||||
if(fieldExist('lookaddons', 'players'))
|
||||
$player->setLookAddons($char_to_copy->getLookAddons());
|
||||
|
||||
$player->setTownId($newchar_town);
|
||||
$player->setExperience($char_to_copy->getExperience());
|
||||
$player->setLevel($char_to_copy->getLevel());
|
||||
$player->setMagLevel($char_to_copy->getMagLevel());
|
||||
$player->setHealth($char_to_copy->getHealth());
|
||||
$player->setHealthMax($char_to_copy->getHealthMax());
|
||||
$player->setMana($char_to_copy->getMana());
|
||||
$player->setManaMax($char_to_copy->getManaMax());
|
||||
$player->setManaSpent($char_to_copy->getManaSpent());
|
||||
$player->setSoul($char_to_copy->getSoul());
|
||||
|
||||
for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++)
|
||||
$player->setSkill($skill, 10);
|
||||
|
||||
$player->setLookBody($char_to_copy->getLookBody());
|
||||
$player->setLookFeet($char_to_copy->getLookFeet());
|
||||
$player->setLookHead($char_to_copy->getLookHead());
|
||||
$player->setLookLegs($char_to_copy->getLookLegs());
|
||||
$player->setLookType($char_to_copy->getLookType());
|
||||
$player->setCap($char_to_copy->getCap());
|
||||
$player->setBalance(0);
|
||||
$player->setPosX(0);
|
||||
$player->setPosY(0);
|
||||
$player->setPosZ(0);
|
||||
$player->setStamina($config['otserv_version'] == TFS_03 ? 151200000 : 2520);
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
$player->setLossExperience($char_to_copy->getLossExperience());
|
||||
$player->setLossMana($char_to_copy->getLossMana());
|
||||
$player->setLossSkills($char_to_copy->getLossSkills());
|
||||
}
|
||||
if(fieldExist('loss_items', 'players')) {
|
||||
$player->setLossItems($char_to_copy->getLossItems());
|
||||
$player->setLossContainers($char_to_copy->getLossContainers());
|
||||
}
|
||||
|
||||
$player->save();
|
||||
$player->setCustomField("created", time());
|
||||
|
||||
$newchar_created = true;
|
||||
$account_logged->logAction('Created character <b>' . $player->getName() . '</b>.');
|
||||
unset($player);
|
||||
|
||||
$player = new OTS_Player();
|
||||
$player->find($newchar_name);
|
||||
|
||||
if($player->isLoaded()) {
|
||||
if(tableExist('player_skills')) {
|
||||
for($i=0; $i<7; $i++) {
|
||||
$skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $i);
|
||||
if($skillExists->rowCount() <= 0) {
|
||||
$db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$i.', 10, 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)
|
||||
$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']."', '".$save_item['attributes']."');");
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Character Created',
|
||||
'description' => 'The character <b>' . $newchar_name . '</b> has been created.<br/>
|
||||
Please select the outfit when you log in for the first time.<br/><br/>
|
||||
<b>See you on ' . $config['lua']['serverName'] . '!</b>'
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
error("Error. Can't create character. Probably problem with database. Please try again later or contact with admin.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count($errors) > 0) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
if(!$newchar_created) {
|
||||
echo $twig->render('account.create_character.html.twig', array(
|
||||
'name' => $newchar_name,
|
||||
'sex' => $newchar_sex,
|
||||
'vocation' => $newchar_vocation,
|
||||
'town' => $newchar_town,
|
||||
'save' => $save,
|
||||
'errors' => $errors
|
||||
));
|
||||
}
|
||||
?>
|
70
system/pages/account/delete_character.php
Normal file
70
system/pages/account/delete_character.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Delete character
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$player_name = isset($_POST['delete_name']) ? stripslashes($_POST['delete_name']) : NULL;
|
||||
$password_verify = isset($_POST['delete_password']) ? $_POST['delete_password'] : NULL;
|
||||
$password_verify = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $password_verify);
|
||||
if(isset($_POST['deletecharactersave']) && $_POST['deletecharactersave'] == 1) {
|
||||
if(!empty($player_name) && !empty($password_verify)) {
|
||||
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($password_verify == $account_logged->getPassword()) {
|
||||
if(!$player->isOnline())
|
||||
{
|
||||
//dont show table "delete character" again
|
||||
$show_form = false;
|
||||
//delete player
|
||||
if(fieldExist('deletion', 'players'))
|
||||
$player->setCustomField('deletion', 1);
|
||||
else
|
||||
$player->setCustomField('deleted', 1);
|
||||
$account_logged->logAction('Deleted character <b>' . $player->getName() . '</b>.');
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Character Deleted',
|
||||
'description' => 'The character <b>' . $player_name . '</b> has been deleted.'
|
||||
));
|
||||
}
|
||||
else
|
||||
$errors[] = 'This character is online.';
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Wrong password to account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character <b>'.$player_name.'</b> is not on your account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character with this name doesn\'t exist.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Name contain illegal characters.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character name or/and password is empty. Please fill in form.';
|
||||
}
|
||||
}
|
||||
if($show_form) {
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
echo $twig->render('account.delete_character.html.twig');
|
||||
}
|
||||
?>
|
59
system/pages/account/register.php
Normal file
59
system/pages/account/register.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Register Account
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$_POST['reg_password'] = isset($_POST['reg_password']) ? $_POST['reg_password'] : '';
|
||||
$reg_password = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $_POST['reg_password']);
|
||||
$old_key = $account_logged->getCustomField("key");
|
||||
|
||||
if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == "1") {
|
||||
if($reg_password == $account_logged->getPassword()) {
|
||||
if(empty($old_key)) {
|
||||
$show_form = false;
|
||||
$new_rec_key = generateRandomString(10, false, true, true);
|
||||
|
||||
$account_logged->setCustomField("key", $new_rec_key);
|
||||
$account_logged->logAction('Generated recovery key.');
|
||||
|
||||
if($config['mail_enabled'] && $config['send_mail_when_generate_reckey'])
|
||||
{
|
||||
$mailBody = $twig->render('mail.account.register.html.twig', array(
|
||||
'recovery_key' => $new_rec_key
|
||||
));
|
||||
if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - Recovery Key", $mailBody))
|
||||
$message = '<br /><small>Your recovery key were send on email address <b>'.$account_logged->getEMail().'</b>.</small>';
|
||||
else
|
||||
$message = '<br /><p class="error">An error occorred while sending email with recovery key! You will not receive e-mail with this key. Error:<br/>' . $mailer->ErrorInfo . '</p>';
|
||||
}
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Account Registered',
|
||||
'description' => 'Thank you for registering your account! You can now recover your account if you have lost access to the assigned email address by using the following<br/><br/><font size="5"> <b>Recovery Key: '.$new_rec_key.'</b></font><br/><br/><br/><b>Important:</b><ul><li>Write down this recovery key carefully.</li><li>Store it at a safe place!</li>' . $message . '</ul>'
|
||||
));
|
||||
}
|
||||
else
|
||||
$errors[] = 'Your account is already registered.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'Wrong password to account.';
|
||||
}
|
||||
|
||||
if($show_form) {
|
||||
if(!empty($errors)) {
|
||||
//show errors
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
//show form
|
||||
echo $twig->render('account.generate_recovery_key.html.twig');
|
||||
}
|
||||
|
||||
?>
|
72
system/pages/account/register_new.php
Normal file
72
system/pages/account/register_new.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Register Account New
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(isset($_POST['reg_password']))
|
||||
$reg_password = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $_POST['reg_password']);
|
||||
|
||||
$reckey = $account_logged->getCustomField('key');
|
||||
if((!$config['generate_new_reckey'] || !$config['mail_enabled']) || empty($reckey))
|
||||
echo 'You cant get new rec key';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == '1')
|
||||
{
|
||||
if($reg_password == $account_logged->getPassword())
|
||||
{
|
||||
if($points >= $config['generate_new_reckey_price'])
|
||||
{
|
||||
$show_form = false;
|
||||
$new_rec_key = generateRandomString(10, false, true, true);
|
||||
|
||||
$mailBody = $twig->render('mail.account.register.html.twig', array(
|
||||
'recovery_key' => $new_rec_key
|
||||
));
|
||||
|
||||
if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - new recovery key", $mailBody))
|
||||
{
|
||||
$account_logged->setCustomField("key", $new_rec_key);
|
||||
$account_logged->setCustomField("premium_points", $account_logged->getCustomField("premium_points") - $config['generate_new_reckey_price']);
|
||||
$account_logged->logAction('Generated new recovery key for ' . $config['generate_new_reckey_price'] . ' premium points.');
|
||||
$message = '<br />Your recovery key were send on email address <b>'.$account_logged->getEMail().'</b> for '.$config['generate_new_reckey_price'].' premium points.';
|
||||
}
|
||||
else
|
||||
$message = '<br /><p class="error">An error occorred while sending email ( <b>'.$account_logged->getEMail().'</b> ) with recovery key! Recovery key not changed. Try again. Error:<br/>' . $mailer->ErrorInfo . '</p>';
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Account Registered',
|
||||
'description' => '<ul>' . $message . '</ul>'
|
||||
));
|
||||
}
|
||||
else
|
||||
$errors[] = 'You need '.$config['generate_new_reckey_price'].' premium points to generate new recovery key. You have <b>'.$points.'<b> premium points.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'Wrong password to account.';
|
||||
}
|
||||
|
||||
//show errors if not empty
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
if($show_form)
|
||||
{
|
||||
//show form
|
||||
echo $twig->render('account.generate_new_recovery_key.html.twig', array(
|
||||
'points' => $points
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -124,862 +124,7 @@ $errors = array();
|
||||
'players' => $account_players
|
||||
));
|
||||
}
|
||||
//########### CHANGE PASSWORD ##########
|
||||
if($action == "changepassword") {
|
||||
$new_password = isset($_POST['newpassword']) ? $_POST['newpassword'] : NULL;
|
||||
$new_password2 = isset($_POST['newpassword2']) ? $_POST['newpassword2'] : NULL;
|
||||
$old_password = isset($_POST['oldpassword']) ? $_POST['oldpassword'] : NULL;
|
||||
if(empty($new_password) && empty($new_password2) && empty($old_password)) {
|
||||
echo $twig->render('account.change_password.html.twig');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(empty($new_password) || empty($new_password2) || empty($old_password)){
|
||||
$errors[] = "Please fill in form.";
|
||||
}
|
||||
$password_strlen = strlen($new_password);
|
||||
if($new_password != $new_password2) {
|
||||
$errors[] = "The new passwords do not match!";
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
if(!Validator::password($new_password)) {
|
||||
$errors[] = Validator::getLastError();
|
||||
}
|
||||
|
||||
$old_password = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $old_password);
|
||||
if($old_password != $account_logged->getPassword()) {
|
||||
$errors[] = "Current password is incorrect!";
|
||||
}
|
||||
}
|
||||
if(!empty($errors)){
|
||||
//show errors
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
//show form
|
||||
echo $twig->render('account.change_password.html.twig');
|
||||
}
|
||||
else
|
||||
{
|
||||
$org_pass = $new_password;
|
||||
|
||||
if($config_salt_enabled)
|
||||
{
|
||||
$salt = generateRandomString(10, false, true, true);
|
||||
$new_password = $salt . $new_password;
|
||||
$account_logged->setCustomField('salt', $salt);
|
||||
}
|
||||
|
||||
$new_password = encrypt($new_password);
|
||||
$account_logged->setPassword($new_password);
|
||||
$account_logged->save();
|
||||
$account_logged->logAction('Account password changed.');
|
||||
|
||||
$message = '';
|
||||
if($config['mail_enabled'] && $config['send_mail_when_change_password'])
|
||||
{
|
||||
$mailBody = $twig->render('mail.password_changed.html.twig', array(
|
||||
'new_password' => $org_pass
|
||||
));
|
||||
|
||||
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 occorred while sending email with password:<br/>' . $mailer->ErrorInfo . '</p>';
|
||||
}
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Password Changed',
|
||||
'description' => 'Your password has been changed.' . $message
|
||||
));
|
||||
$_SESSION['password'] = $new_password;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//############# CHANGE E-MAIL ###################
|
||||
if($action == "changeemail") {
|
||||
$email_new_time = $account_logged->getCustomField("email_new_time");
|
||||
|
||||
if($email_new_time > 10) {
|
||||
$email_new = $account_logged->getCustomField("email_new");
|
||||
}
|
||||
|
||||
if($email_new_time < 10) {
|
||||
if(isset($_POST['changeemailsave']) && $_POST['changeemailsave'] == 1) {
|
||||
$email_new = $_POST['new_email'];
|
||||
$post_password = $_POST['password'];
|
||||
|
||||
if(!Validator::email($email_new)) {
|
||||
$errors[] = Validator::getLastError();
|
||||
}
|
||||
|
||||
if(empty($post_password)) {
|
||||
$errors[] = 'Please enter password to your account.';
|
||||
}
|
||||
else {
|
||||
$post_password = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $post_password);
|
||||
if($post_password != $account_logged->getPassword()) {
|
||||
$errors[] = 'Wrong password to account.';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$email_new_time = time() + $config['account_mail_change'] * 24 * 3600;
|
||||
$account_logged->setCustomField("email_new", $email_new);
|
||||
$account_logged->setCustomField("email_new_time", $email_new_time);
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'New Email Address Requested',
|
||||
'description' => 'You have requested to change your email address to <b>' . $email_new . '</b>. The actual change will take place after <b>' . date("j F Y, G:i:s", $email_new_time) . '</b>, during which you can cancel the request at any time.'
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
//show errors
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
//show form
|
||||
echo $twig->render('account.change_mail.html.twig', array(
|
||||
'new_email' => isset($_POST['new_email']) ? $_POST['new_email'] : null
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $twig->render('account.change_mail.html.twig', array(
|
||||
'new_email' => isset($_POST['new_email']) ? $_POST['new_email'] : null
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if($email_new_time < time()) {
|
||||
if($_POST['changeemailsave'] == 1) {
|
||||
$account_logged->setCustomField("email_new", "");
|
||||
$account_logged->setCustomField("email_new_time", 0);
|
||||
$account_logged->setEmail($email_new);
|
||||
$account_logged->save();
|
||||
$account_logged->logAction('Account email changed to <b>' . $email_new . '</b>');
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Email Address Change Accepted',
|
||||
'description' => 'You have accepted <b>' . $account_logged->getEmail() . '</b> as your new email adress.'
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$custom_buttons = '
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td width="30"> </td>
|
||||
<td align=left>
|
||||
<form action="?subtopic=accountmanagement&action=changeemail" method="post"><input type="hidden" name="changeemailsave" value=1 >
|
||||
<INPUT TYPE=image NAME="I Agree" SRC="' . $template_path . '/images/buttons/sbutton_iagree.gif" BORDER=0 WIDTH=120 HEIGHT=17>
|
||||
</form>
|
||||
</td>
|
||||
<td align=left>
|
||||
<form action="?subtopic=accountmanagement&action=changeemail" method="post">
|
||||
<input type="hidden" name="emailchangecancel" value=1 >
|
||||
<input type=image name="Cancel" src="' . $template_path . '/images/buttons/sbutton_cancel.gif" BORDER=0 WIDTH=120 HEIGHT=17>
|
||||
</form>
|
||||
</td>
|
||||
<td align=right>
|
||||
<form action="?subtopic=accountmanagement" method="post" >
|
||||
<div class="BigButton" style="background-image:url(' . $template_path . '/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url(' . $template_path . '/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="' . $template_path . '/images/buttons/_sbutton_back.gif" ></div>
|
||||
</div>
|
||||
</form>
|
||||
</td>
|
||||
<td width="30"> </td>
|
||||
</tr>
|
||||
</table>';
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Email Address Change Accepted',
|
||||
'description' => 'Do you accept <b>'.$email_new.'</b> as your new email adress?',
|
||||
'custom_buttons' => $custom_buttons
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$custom_buttons = '
|
||||
<table style="width:100%;" >
|
||||
<tr align="center">
|
||||
<td>
|
||||
<table border="0" cellspacing="0" cellpadding="0" >
|
||||
<form action="?subtopic=accountmanagement&action=changeemail" method="post" >
|
||||
<tr>
|
||||
<td style="border:0px;" >
|
||||
<input type="hidden" name="emailchangecancel" value="1" >
|
||||
<div class="BigButton" style="background-image:url(' . $template_path . '/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url(' . $template_path . '/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Cancel" alt="Cancel" src="'.$template_path.'/images/buttons/_sbutton_cancel.gif" ></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table border="0" cellspacing="0" cellpadding="0" >
|
||||
<form action="?subtopic=accountmanagement" method="post" >
|
||||
<tr>
|
||||
<td style="border:0px;" >
|
||||
<div class="BigButton" style="background-image:url(' . $template_path . '/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url(' . $template_path . '/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="' . $template_path . '/images/buttons/_sbutton_back.gif" ></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>';
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Change of Email Address',
|
||||
'description' => 'A request has been submitted to change the email address of this account to <b>'.$email_new.'</b>.<br/>The actual change will take place on <b>'.date("j F Y, G:i:s", $email_new_time).'</b>.<br>If you do not want to change your email address, please click on "Cancel".',
|
||||
'custom_buttons' => $custom_buttons
|
||||
));
|
||||
}
|
||||
}
|
||||
if(isset($_POST['emailchangecancel']) && $_POST['emailchangecancel'] == 1) {
|
||||
$account_logged->setCustomField("email_new", "");
|
||||
$account_logged->setCustomField("email_new_time", 0);
|
||||
|
||||
$custom_buttons = '<center><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=accountmanagement" method="post" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$template_path.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$template_path.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$template_path.'/images/buttons/_sbutton_back.gif" ></div></div></td></tr></form></table></center>';
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Email Address Change Cancelled',
|
||||
'description' => 'Your request to change the email address of your account has been cancelled. The email address will not be changed.',
|
||||
'custom_buttons' => $custom_buttons
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
//########### CHANGE PUBLIC INFORMATION (about account owner) ######################
|
||||
if($action == "changeinfo") {
|
||||
$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;
|
||||
$new_country = isset($_POST['info_country']) ? htmlspecialchars(stripslashes($_POST['info_country'])) : NULL;
|
||||
if(isset($_POST['changeinfosave']) && $_POST['changeinfosave'] == 1) {
|
||||
if(!isset($config['countries'][$new_country]))
|
||||
$errors[] = 'Country is not correct.';
|
||||
|
||||
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_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>.');
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Public Information Changed',
|
||||
'description' => 'Your public information has been changed.'
|
||||
));
|
||||
$show_form = false;
|
||||
}
|
||||
else {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
}
|
||||
|
||||
//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");
|
||||
|
||||
$countries = array();
|
||||
foreach (array('pl', 'se', 'br', 'us', 'gb',) as $country)
|
||||
$countries[$country] = $config['countries'][$country];
|
||||
|
||||
$countries['--'] = '----------';
|
||||
|
||||
foreach ($config['countries'] as $code => $country)
|
||||
$countries[$code] = $country;
|
||||
|
||||
echo $twig->render('account.change_info.html.twig', array(
|
||||
'countries' => $countries,
|
||||
'account_rlname' => $account_rlname,
|
||||
'account_location' => $account_location,
|
||||
'account_country' => $account_country
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
//############## GENERATE RECOVERY KEY ###########
|
||||
if($action == "registeraccount")
|
||||
{
|
||||
$_POST['reg_password'] = isset($_POST['reg_password']) ? $_POST['reg_password'] : '';
|
||||
$reg_password = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $_POST['reg_password']);
|
||||
$old_key = $account_logged->getCustomField("key");
|
||||
|
||||
if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == "1") {
|
||||
if($reg_password == $account_logged->getPassword()) {
|
||||
if(empty($old_key)) {
|
||||
$show_form = false;
|
||||
$new_rec_key = generateRandomString(10, false, true, true);
|
||||
|
||||
$account_logged->setCustomField("key", $new_rec_key);
|
||||
$account_logged->logAction('Generated recovery key.');
|
||||
|
||||
if($config['mail_enabled'] && $config['send_mail_when_generate_reckey'])
|
||||
{
|
||||
$mailBody = $twig->render('mail.account.register.html.twig', array(
|
||||
'recovery_key' => $new_rec_key
|
||||
));
|
||||
if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - Recovery Key", $mailBody))
|
||||
$message = '<br /><small>Your recovery key were send on email address <b>'.$account_logged->getEMail().'</b>.</small>';
|
||||
else
|
||||
$message = '<br /><p class="error">An error occorred while sending email with recovery key! You will not receive e-mail with this key. Error:<br/>' . $mailer->ErrorInfo . '</p>';
|
||||
}
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Account Registered',
|
||||
'description' => 'Thank you for registering your account! You can now recover your account if you have lost access to the assigned email address by using the following<br/><br/><font size="5"> <b>Recovery Key: '.$new_rec_key.'</b></font><br/><br/><br/><b>Important:</b><ul><li>Write down this recovery key carefully.</li><li>Store it at a safe place!</li>' . $message . '</ul>'
|
||||
));
|
||||
}
|
||||
else
|
||||
$errors[] = 'Your account is already registered.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'Wrong password to account.';
|
||||
}
|
||||
|
||||
if($show_form) {
|
||||
if(!empty($errors)) {
|
||||
//show errors
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
//show form
|
||||
echo $twig->render('account.generate_recovery_key.html.twig');
|
||||
}
|
||||
}
|
||||
|
||||
//############## GENERATE NEW RECOVERY KEY ###########
|
||||
if($action == "registernew")
|
||||
{
|
||||
if(isset($_POST['reg_password']))
|
||||
$reg_password = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $_POST['reg_password']);
|
||||
|
||||
$reckey = $account_logged->getCustomField('key');
|
||||
if((!$config['generate_new_reckey'] || !$config['mail_enabled']) || empty($reckey))
|
||||
echo 'You cant get new rec key';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == '1')
|
||||
{
|
||||
if($reg_password == $account_logged->getPassword())
|
||||
{
|
||||
if($points >= $config['generate_new_reckey_price'])
|
||||
{
|
||||
$show_form = false;
|
||||
$new_rec_key = generateRandomString(10, false, true, true);
|
||||
|
||||
$mailBody = $twig->render('mail.account.register.html.twig', array(
|
||||
'recovery_key' => $new_rec_key
|
||||
));
|
||||
|
||||
if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - new recovery key", $mailBody))
|
||||
{
|
||||
$account_logged->setCustomField("key", $new_rec_key);
|
||||
$account_logged->setCustomField("premium_points", $account_logged->getCustomField("premium_points") - $config['generate_new_reckey_price']);
|
||||
$account_logged->logAction('Generated new recovery key for ' . $config['generate_new_reckey_price'] . ' premium points.');
|
||||
$message = '<br />Your recovery key were send on email address <b>'.$account_logged->getEMail().'</b> for '.$config['generate_new_reckey_price'].' premium points.';
|
||||
}
|
||||
else
|
||||
$message = '<br /><p class="error">An error occorred while sending email ( <b>'.$account_logged->getEMail().'</b> ) with recovery key! Recovery key not changed. Try again. Error:<br/>' . $mailer->ErrorInfo . '</p>';
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Account Registered',
|
||||
'description' => '<ul>' . $message . '</ul>'
|
||||
));
|
||||
}
|
||||
else
|
||||
$errors[] = 'You need '.$config['generate_new_reckey_price'].' premium points to generate new recovery key. You have <b>'.$points.'<b> premium points.';
|
||||
}
|
||||
else
|
||||
$errors[] = 'Wrong password to account.';
|
||||
}
|
||||
|
||||
//show errors if not empty
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
if($show_form)
|
||||
{
|
||||
//show form
|
||||
echo $twig->render('account.generate_new_recovery_key.html.twig', array(
|
||||
'points' => $points
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//###### CHANGE CHARACTER COMMENT ######
|
||||
if($action == "changecomment") {
|
||||
$player_name = isset($_REQUEST['name']) ? stripslashes($_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>.');
|
||||
echo $twig->render('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.";
|
||||
}
|
||||
} else {
|
||||
$errors[] = 'Error. Name contain illegal characters.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Please enter character name.';
|
||||
}
|
||||
|
||||
if($show_form) {
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
if(isset($player)) {
|
||||
echo $twig->render('account.change_comment.html.twig', array(
|
||||
'player' => $player
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($action == "changename") {
|
||||
echo '<script type="text/javascript" src="tools/check_name.js"></script>';
|
||||
|
||||
$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']))
|
||||
echo 'Changing character name for premium points is disabled on this server.';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
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(empty($errors) && empty($name))
|
||||
$errors[] = 'Please enter a new name for your character!';
|
||||
else if(strlen($name) > 25)
|
||||
$errors[] = 'Name is too long. Max. lenght <b>25</b> letters.';
|
||||
else if(strlen($name) < 3)
|
||||
$errors[] = 'Name is too short. Min. lenght <b>3</b> letters.';
|
||||
else {
|
||||
$exist = new OTS_Player();
|
||||
$exist->find($name);
|
||||
if($exist->isLoaded()) {
|
||||
$errors[] = 'Character with this name already exist.';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
if(!admin() && !Validator::newCharacterName($name))
|
||||
$errors[] = Validator::getLastError();
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$player = new OTS_Player();
|
||||
$player->load($player_id);
|
||||
if($player->isLoaded()) {
|
||||
$player_account = $player->getAccount();
|
||||
if($account_logged->getId() == $player_account->getId()) {
|
||||
if($player->isOnline()) {
|
||||
$errors[] = 'This character is online.';
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$show_form = false;
|
||||
$old_name = $player->getName();
|
||||
$player->setName($name);
|
||||
$player->save();
|
||||
$account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
|
||||
$account_logged->logAction('Changed name from <b>' . $old_name . '</b> to <b>' . $player->getName() . '</b>.');
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Character Name Changed',
|
||||
'description' => 'The character <b>'.$old_name.'</b> name has been changed to <b>' . $player->getName() . '</b>.'
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character <b>' . $player_name . '</b> is not on your account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = "Character with this name doesn't exist.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($show_form) {
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
echo $twig->render('account.change_name.html.twig', array(
|
||||
'points' => $points,
|
||||
'errors' => $errors
|
||||
//'account_players' => $account_logged->getPlayersList()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($action == "changesex") {
|
||||
$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']))
|
||||
echo 'You cant change your character sex';
|
||||
else
|
||||
{
|
||||
$points = $account_logged->getCustomField('premium_points');
|
||||
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(empty($errors) && !isset($config['genders'][$new_sex])) {
|
||||
$errors[] = 'This sex is invalid.';
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$player = new OTS_Player();
|
||||
$player->load($player_id);
|
||||
|
||||
if($player->isLoaded()) {
|
||||
$player_account = $player->getAccount();
|
||||
|
||||
if($account_logged->getId() == $player_account->getId()) {
|
||||
if($player->isOnline()) {
|
||||
$errors[] = 'This character is online.';
|
||||
}
|
||||
|
||||
if(empty($errors) && $player->getSex() == $new_sex)
|
||||
$errors[] = 'Sex cannot be same';
|
||||
|
||||
if(empty($errors)) {
|
||||
$sex_changed = true;
|
||||
$old_sex = $player->getSex();
|
||||
$player->setSex($new_sex);
|
||||
|
||||
$old_sex_str = 'Unknown';
|
||||
if(isset($config['genders'][$old_sex]))
|
||||
$old_sex_str = $config['genders'][$old_sex];
|
||||
|
||||
$new_sex_str = 'Unknown';
|
||||
if(isset($config['genders'][$new_sex]))
|
||||
$new_sex_str = $config['genders'][$new_sex];
|
||||
|
||||
$player->save();
|
||||
$account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']);
|
||||
$account_logged->logAction('Changed sex on character <b>' . $player->getName() . '</b> from <b>' . $old_sex_str . '</b> to <b>' . $new_sex_str . '</b>.');
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Character Sex Changed',
|
||||
'description' => 'The character <b>' . $player->getName() . '</b> sex has been changed to <b>' . $new_sex_str . '</b>.'
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character <b>'.$player_name.'</b> is not on your account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = "Character with this name doesn't exist.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$sex_changed) {
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
echo $twig->render('account.change_sex.html.twig', array(
|
||||
'players' => $account_logged->getPlayersList(),
|
||||
'player_sex' => isset($player) ? $player->getSex() : -1,
|
||||
'points' => $points
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
//### DELETE character from account ###
|
||||
if($action == "deletecharacter") {
|
||||
$player_name = isset($_POST['delete_name']) ? stripslashes($_POST['delete_name']) : NULL;
|
||||
$password_verify = isset($_POST['delete_password']) ? $_POST['delete_password'] : NULL;
|
||||
$password_verify = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $password_verify);
|
||||
if(isset($_POST['deletecharactersave']) && $_POST['deletecharactersave'] == 1) {
|
||||
if(!empty($player_name) && !empty($password_verify)) {
|
||||
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($password_verify == $account_logged->getPassword()) {
|
||||
if(!$player->isOnline())
|
||||
{
|
||||
//dont show table "delete character" again
|
||||
$show_form = false;
|
||||
//delete player
|
||||
if(fieldExist('deletion', 'players'))
|
||||
$player->setCustomField('deletion', 1);
|
||||
else
|
||||
$player->setCustomField('deleted', 1);
|
||||
$account_logged->logAction('Deleted character <b>' . $player->getName() . '</b>.');
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Character Deleted',
|
||||
'description' => 'The character <b>' . $player_name . '</b> has been deleted.'
|
||||
));
|
||||
}
|
||||
else
|
||||
$errors[] = 'This character is online.';
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Wrong password to account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character <b>'.$player_name.'</b> is not on your account.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character with this name doesn\'t exist.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Name contain illegal characters.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'Character name or/and password is empty. Please fill in form.';
|
||||
}
|
||||
}
|
||||
if($show_form) {
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
echo $twig->render('account.delete_character.html.twig');
|
||||
}
|
||||
}
|
||||
|
||||
//## CREATE CHARACTER on account ###
|
||||
if($action == "createcharacter") {
|
||||
echo '<script type="text/javascript" src="tools/check_name.js"></script>';
|
||||
$newchar_name = isset($_POST['name']) ? stripslashes(ucwords(strtolower($_POST['name']))) : NULL;
|
||||
$newchar_sex = isset($_POST['sex']) ? $_POST['sex'] : NULL;
|
||||
$newchar_vocation = isset($_POST['vocation']) ? $_POST['vocation'] : NULL;
|
||||
$newchar_town = isset($_POST['town']) ? $_POST['town'] : NULL;
|
||||
|
||||
$newchar_created = false;
|
||||
$save = isset($_POST['save']) && $_POST['save'] == 1;
|
||||
if($save) {
|
||||
if(empty($newchar_name))
|
||||
$errors['name'] = 'Please enter a name for your character!';
|
||||
else if(strlen($newchar_name) > 25)
|
||||
$errors['name'] = 'Name is too long. Max. lenght <b>25</b> letters.';
|
||||
else if(strlen($newchar_name) < 3)
|
||||
$errors['name'] = 'Name is too short. Min. lenght <b>3</b> letters.';
|
||||
else {
|
||||
if(!admin() && !Validator::newCharacterName($newchar_name)) {
|
||||
$errors['name'] = Validator::getLastError();
|
||||
}
|
||||
|
||||
$exist = new OTS_Player();
|
||||
$exist->find($newchar_name);
|
||||
if($exist->isLoaded()) {
|
||||
$errors['name'] = 'Character with this name already exist.';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($newchar_sex) && $newchar_sex != "0")
|
||||
$errors[] = 'Please select the sex for your character!';
|
||||
|
||||
if(count($config['character_samples']) > 1)
|
||||
{
|
||||
if(!isset($newchar_vocation))
|
||||
$errors[] = 'Please select a vocation for your character.';
|
||||
}
|
||||
else
|
||||
$newchar_vocation = $config['character_samples'][0];
|
||||
|
||||
if(count($config['character_towns']) > 1) {
|
||||
if(!isset($newchar_town))
|
||||
$errors[] = 'Please select a town for your character.';
|
||||
}
|
||||
else {
|
||||
$newchar_town = $config['character_towns'][0];
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
if(!isset($config['genders'][$newchar_sex]))
|
||||
$errors[] = 'Sex is invalid.';
|
||||
if(!in_array($newchar_town, $config['character_towns']))
|
||||
$errors[] = 'Please select valid town.';
|
||||
if(count($config['character_samples']) > 1)
|
||||
{
|
||||
$newchar_vocation_check = false;
|
||||
foreach($config['character_samples'] as $char_vocation_key => $sample_char)
|
||||
if($newchar_vocation == $char_vocation_key)
|
||||
$newchar_vocation_check = true;
|
||||
if(!$newchar_vocation_check)
|
||||
$errors[] = 'Unknown vocation. Please fill in form again.';
|
||||
}
|
||||
else
|
||||
$newchar_vocation = 0;
|
||||
}
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$number_of_players_on_account = $account_logged->getPlayersList()->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>!';
|
||||
}
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$char_to_copy_name = $config['character_samples'][$newchar_vocation];
|
||||
$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/config.php and set valid characters to copy names. Character to copy: <b>'.$char_to_copy_name.'</b> doesn\'t exist.';
|
||||
}
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
if($newchar_sex == "0")
|
||||
$char_to_copy->setLookType(136);
|
||||
$player = $ots->createObject('Player');
|
||||
$player->setName($newchar_name);
|
||||
$player->setAccount($account_logged);
|
||||
//$player->setGroupId($char_to_copy->getGroup()->getId());
|
||||
$player->setGroupId(1);
|
||||
$player->setSex($newchar_sex);
|
||||
$player->setVocation($char_to_copy->getVocation());
|
||||
if(fieldExist('promotion', 'players'))
|
||||
$player->setPromotion($char_to_copy->getPromotion());
|
||||
|
||||
if(fieldExist('direction', 'players'))
|
||||
$player->setDirection($char_to_copy->getDirection());
|
||||
|
||||
$player->setConditions($char_to_copy->getConditions());
|
||||
$rank = $char_to_copy->getRank();
|
||||
if($rank->isLoaded()) {
|
||||
$player->setRank($char_to_copy->getRank());
|
||||
}
|
||||
|
||||
if(fieldExist('lookaddons', 'players'))
|
||||
$player->setLookAddons($char_to_copy->getLookAddons());
|
||||
|
||||
$player->setTownId($newchar_town);
|
||||
$player->setExperience($char_to_copy->getExperience());
|
||||
$player->setLevel($char_to_copy->getLevel());
|
||||
$player->setMagLevel($char_to_copy->getMagLevel());
|
||||
$player->setHealth($char_to_copy->getHealth());
|
||||
$player->setHealthMax($char_to_copy->getHealthMax());
|
||||
$player->setMana($char_to_copy->getMana());
|
||||
$player->setManaMax($char_to_copy->getManaMax());
|
||||
$player->setManaSpent($char_to_copy->getManaSpent());
|
||||
$player->setSoul($char_to_copy->getSoul());
|
||||
|
||||
for($skill = POT::SKILL_FIRST; $skill <= POT::SKILL_LAST; $skill++)
|
||||
$player->setSkill($skill, 10);
|
||||
|
||||
$player->setLookBody($char_to_copy->getLookBody());
|
||||
$player->setLookFeet($char_to_copy->getLookFeet());
|
||||
$player->setLookHead($char_to_copy->getLookHead());
|
||||
$player->setLookLegs($char_to_copy->getLookLegs());
|
||||
$player->setLookType($char_to_copy->getLookType());
|
||||
$player->setCap($char_to_copy->getCap());
|
||||
$player->setBalance(0);
|
||||
$player->setPosX(0);
|
||||
$player->setPosY(0);
|
||||
$player->setPosZ(0);
|
||||
$player->setStamina($config['otserv_version'] == TFS_03 ? 151200000 : 2520);
|
||||
if(fieldExist('loss_experience', 'players')) {
|
||||
$player->setLossExperience($char_to_copy->getLossExperience());
|
||||
$player->setLossMana($char_to_copy->getLossMana());
|
||||
$player->setLossSkills($char_to_copy->getLossSkills());
|
||||
}
|
||||
if(fieldExist('loss_items', 'players')) {
|
||||
$player->setLossItems($char_to_copy->getLossItems());
|
||||
$player->setLossContainers($char_to_copy->getLossContainers());
|
||||
}
|
||||
|
||||
$player->save();
|
||||
$player->setCustomField("created", time());
|
||||
|
||||
$newchar_created = true;
|
||||
$account_logged->logAction('Created character <b>' . $player->getName() . '</b>.');
|
||||
unset($player);
|
||||
|
||||
$player = new OTS_Player();
|
||||
$player->find($newchar_name);
|
||||
|
||||
if($player->isLoaded()) {
|
||||
if(tableExist('player_skills')) {
|
||||
for($i=0; $i<7; $i++) {
|
||||
$skillExists = $db->query('SELECT `skillid` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' AND `skillid` = ' . $i);
|
||||
if($skillExists->rowCount() <= 0) {
|
||||
$db->query('INSERT INTO `player_skills` (`player_id`, `skillid`, `value`, `count`) VALUES ('.$player->getId().', '.$i.', 10, 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)
|
||||
$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']."', '".$save_item['attributes']."');");
|
||||
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Character Created',
|
||||
'description' => 'The character <b>' . $newchar_name . '</b> has been created.<br/>
|
||||
Please select the outfit when you log in for the first time.<br/><br/>
|
||||
<b>See you on ' . $config['lua']['serverName'] . '!</b>'
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
error("Error. Can't create character. Probably problem with database. Please try again later or contact with admin.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(count($errors) > 0) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
if(!$newchar_created) {
|
||||
echo $twig->render('account.create_character.html.twig', array(
|
||||
'name' => $newchar_name,
|
||||
'sex' => $newchar_sex,
|
||||
'vocation' => $newchar_vocation,
|
||||
'town' => $newchar_town,
|
||||
'save' => $save,
|
||||
'errors' => $errors
|
||||
));
|
||||
}
|
||||
else if(file_exists(PAGES . 'account/' . $action . '.php')) {
|
||||
require(PAGES . 'account/' . $action . '.php');
|
||||
}
|
||||
?>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
31
system/pages/admin/items.php
Normal file
31
system/pages/admin/items.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Load items.xml
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Load items.xml';
|
||||
|
||||
require(LIBS . 'items.php');
|
||||
require(LIBS . 'weapons.php');
|
||||
|
||||
echo $twig->render('admin.items.html.twig');
|
||||
|
||||
$reload = isset($_REQUEST['reload']) && (int)$_REQUEST['reload'] == 1;
|
||||
if($reload) {
|
||||
if(Items::loadFromXML(true))
|
||||
success('Successfully loaded items.');
|
||||
else
|
||||
error(Items::getError());
|
||||
|
||||
if(Weapons::loadFromXML(true))
|
||||
success('Successfully loaded weapons.');
|
||||
else
|
||||
error(Weapons::getError());
|
||||
|
||||
}
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,13 +5,14 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Plugin manager';
|
||||
|
||||
require(SYSTEM . 'hooks.php');
|
||||
require(LIBS . 'plugins.php');
|
||||
|
||||
function deleteDirectory($dir) {
|
||||
if(!file_exists($dir)) {
|
||||
@@ -45,28 +46,33 @@ if(isset($_REQUEST['uninstall'])){
|
||||
error('Plugin ' . $uninstall . ' does not exist.');
|
||||
}
|
||||
else {
|
||||
$string = file_get_contents($filename);
|
||||
$plugin_info = json_decode($string, true);
|
||||
if($plugin_info == false) {
|
||||
warning('Cannot load plugin info ' . $uninstall . '.json');
|
||||
if(!isset($plugin_info['uninstall'])) {
|
||||
error("Plugin doesn't have uninstall options defined. Skipping...");
|
||||
}
|
||||
else {
|
||||
$success = true;
|
||||
foreach($plugin_info['uninstall'] as $file) {
|
||||
$file = BASE . $file;
|
||||
if(!deleteDirectory($file)) {
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
if($success) {
|
||||
if($cache->enabled()) {
|
||||
$cache->delete('templates');
|
||||
}
|
||||
success('Successfully uninstalled plugin ' . $uninstall);
|
||||
$string = file_get_contents($filename);
|
||||
$plugin_info = json_decode($string, true);
|
||||
if($plugin_info == false) {
|
||||
error('Cannot load plugin info ' . $uninstall . '.json');
|
||||
}
|
||||
else {
|
||||
error('Error while uninstalling plugin ' . $uninstall . ': ' . error_get_last());
|
||||
$success = true;
|
||||
foreach($plugin_info['uninstall'] as $file) {
|
||||
$file = BASE . $file;
|
||||
if(!deleteDirectory($file)) {
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
if($success) {
|
||||
if($cache->enabled()) {
|
||||
$cache->delete('templates');
|
||||
}
|
||||
success('Successfully uninstalled plugin ' . $uninstall);
|
||||
}
|
||||
else {
|
||||
error('Error while uninstalling plugin ' . $uninstall . ': ' . error_get_last());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,98 +121,17 @@ else if(isset($_FILES["plugin"]["name"]))
|
||||
$targetzip = BASE . 'plugins/' . $tmp_filename . '.zip';
|
||||
|
||||
if(move_uploaded_file($tmp_name, $targetzip)) { // move uploaded file
|
||||
$zip = new ZipArchive();
|
||||
if ($zip->open($targetzip)) {
|
||||
for ($i = 0; $i < $zip->numFiles; $i++) {
|
||||
$tmp = $zip->getNameIndex($i);
|
||||
if(pathinfo($tmp, PATHINFO_DIRNAME) == 'plugins' && pathinfo($tmp, PATHINFO_EXTENSION) == 'json')
|
||||
$json_file = $tmp;
|
||||
if(Plugins::install($targetzip)) {
|
||||
foreach(Plugins::getWarnings() as $warning) {
|
||||
warning($warning);
|
||||
}
|
||||
|
||||
if(!isset($json_file)) {
|
||||
error('Cannot find plugin info .json file. Installation is discontinued.');
|
||||
}
|
||||
else if($zip->extractTo(BASE)) { // place in the directory with same name
|
||||
$file_name = BASE . $json_file;
|
||||
if(!file_exists($file_name))
|
||||
warning("Cannot load " . $file_name . ". File doesn't exist.");
|
||||
else {
|
||||
$string = file_get_contents($file_name);
|
||||
$plugin = json_decode($string, true);
|
||||
if ($plugin == null) {
|
||||
warning('Cannot load ' . $file_name . '. File might be not a valid json code.');
|
||||
}
|
||||
else {
|
||||
$continue = true;
|
||||
|
||||
if(isset($plugin['require'])) {
|
||||
$require = $plugin['require'];
|
||||
if(isset($require['myaac'])) {
|
||||
$require_myaac = $require['myaac'];
|
||||
if(version_compare(MYAAC_VERSION, $require_myaac, '<')) {
|
||||
warning("This plugin requires MyAAC version " . $require_myaac . ", you're using version " . MYAAC_VERSION . " - please update.");
|
||||
$continue = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($require['php'])) {
|
||||
$require_php = $require['php'];
|
||||
if(version_compare(phpversion(), $require_php, '<')) {
|
||||
warning("This plugin requires PHP version " . $require_php . ", you're using version " . phpversion() . " - please update.");
|
||||
$continue = false;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($require['database'])) {
|
||||
$require_database = $require['database'];
|
||||
if($require_database < DATABASE_VERSION) {
|
||||
warning("This plugin requires database version " . $require_database . ", you're using version " . DATABASE_VERSION . " - please update.");
|
||||
$continue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($continue) {
|
||||
if (isset($plugin['install'])) {
|
||||
if (file_exists(BASE . $plugin['install']))
|
||||
require(BASE . $plugin['install']);
|
||||
else
|
||||
warning('Cannot load install script. Your plugin might be not working correctly.');
|
||||
}
|
||||
|
||||
if (isset($plugin['hooks'])) {
|
||||
foreach ($plugin['hooks'] as $_name => $info) {
|
||||
if (isset($hook_types[$info['type']])) {
|
||||
$query = $db->query('SELECT `id` FROM `' . TABLE_PREFIX . 'hooks` WHERE `name` = ' . $db->quote($_name) . ';');
|
||||
if ($query->rowCount() == 1) { // found something
|
||||
$query = $query->fetch();
|
||||
$db->query('UPDATE `' . TABLE_PREFIX . 'hooks` SET `type` = ' . $hook_types[$info['type']] . ', `file` = ' . $db->quote($info['file']) . ' WHERE `id` = ' . (int)$query['id'] . ';');
|
||||
} else {
|
||||
$db->query('INSERT INTO `' . TABLE_PREFIX . 'hooks` (`id`, `name`, `type`, `file`) VALUES (NULL, ' . $db->quote($_name) . ', ' . $hook_types[$info['type']] . ', ' . $db->quote($info['file']) . ');');
|
||||
}
|
||||
} else
|
||||
warning('Unknown event type: ' . $info['type']);
|
||||
}
|
||||
}
|
||||
|
||||
if($cache->enabled()) {
|
||||
$cache->delete('templates');
|
||||
}
|
||||
success('<strong>' . $plugin['name'] . '</strong> plugin has been successfully installed.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error('There was a problem with extracting zip archive.');
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
unlink($targetzip); // delete the Zipped file
|
||||
}
|
||||
else {
|
||||
error('There was a problem with opening zip archive.');
|
||||
$info = Plugins::getPluginInfo();
|
||||
success((isset($info['name']) ? '<strong>' . $info['name'] . '</strong> p' : 'P') . 'lugin has been successfully installed.');
|
||||
}
|
||||
else
|
||||
error(Plugins::getError());
|
||||
|
||||
unlink($targetzip); // delete the Zipped file
|
||||
}
|
||||
else
|
||||
error('There was a problem with the upload. Please try again.');
|
||||
@@ -231,11 +156,11 @@ foreach(get_plugins() as $plugin)
|
||||
}
|
||||
else {
|
||||
$plugins[] = array(
|
||||
'name' => $plugin_info['name'],
|
||||
'description' => $plugin_info['description'],
|
||||
'version' => $plugin_info['version'],
|
||||
'author' => $plugin_info['author'],
|
||||
'contact' => $plugin_info['contact'],
|
||||
'name' => isset($plugin_info['name']) ? $plugin_info['name'] : '',
|
||||
'description' => isset($plugin_info['description']) ? $plugin_info['description'] : '',
|
||||
'version' => isset($plugin_info['version']) ? $plugin_info['version'] : '',
|
||||
'author' => isset($plugin_info['author']) ? $plugin_info['author'] : '',
|
||||
'contact' => isset($plugin_info['contact']) ? $plugin_info['contact'] : '',
|
||||
'file' => $plugin,
|
||||
'uninstall' => isset($plugin_info['uninstall'])
|
||||
);
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -351,16 +351,16 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil
|
||||
// check if account has been banned
|
||||
$bannedUntil = '';
|
||||
$banned = array();
|
||||
if (tableExist('account_bans'))
|
||||
$banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = ' . $account->getId() . ' and `expires_at` > ' . time());
|
||||
if(tableExist('account_bans'))
|
||||
$banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = ' . $account->getId() . ' and (`expires_at` > ' . time() . ' OR `expires_at` = -1);');
|
||||
else if (tableExist('bans')) {
|
||||
if (fieldExist('expires', 'bans'))
|
||||
$banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = ' . $account->getId() . ' or `value` = ' . $player->getId() . ') and `active` = 1 and `type` != 2 and `type` != 4 and `expires` > ' . time());
|
||||
$banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = ' . $account->getId() . ' or `value` = ' . $player->getId() . ') and `active` = 1 and `type` != 2 and `type` != 4 and (`expires` > ' . time() . ' OR `expires` = -1);');
|
||||
else
|
||||
$banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = ' . $account->getId() . ' or `player` = ' . $player->getId() . ') and `type` != 2 and `type` != 4 and `time` > ' . time());
|
||||
$banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = ' . $account->getId() . ' or `player` = ' . $player->getId() . ') and `type` != 2 and `type` != 4 and (`time` > ' . time() . ' OR `time` = -1);');
|
||||
}
|
||||
foreach ($banned as $ban) {
|
||||
$bannedUntil = ' <font color="red">[Banished ' . ($ban['expires'] == "-1" ? 'forever' : 'until ' . date("d F Y, h:s", $ban['expires'])) . ']</font>';
|
||||
foreach($banned as $ban) {
|
||||
$bannedUntil = $ban['expires'];
|
||||
}
|
||||
|
||||
$account_players = $account->getPlayersList();
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,66 +6,33 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = "Creatures";
|
||||
|
||||
$rarity = array(
|
||||
'Not Rare' => 7,
|
||||
'Semi Rare' => 2,
|
||||
'Rare' => 0.5,
|
||||
'Very Rare' => 0
|
||||
);
|
||||
|
||||
function addLoot($loot, $level=1)
|
||||
{
|
||||
foreach($loot as $test) {
|
||||
$chance = $test['chance'];
|
||||
if(!$chance)
|
||||
$chance = $test['chance1'];
|
||||
|
||||
printLoot($level, $test['id'], $test['countmax'], $chance);
|
||||
foreach($test as $k => $v)
|
||||
addLoot($v->item, $level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
function printLoot($level, $itemid, $count, $chance)
|
||||
{
|
||||
global $itemList, $rarity, $i;
|
||||
|
||||
$chance /= 1000;
|
||||
if(isset($_GET['lootrate'])) {
|
||||
global $lootRate;
|
||||
$chance *= $lootRate;
|
||||
}
|
||||
|
||||
foreach($rarity as $lootRarity => $percent) {
|
||||
if($chance >= $percent) {
|
||||
if(isset($itemid))
|
||||
echo str_repeat("... ", $level) . '<u>' . ($count ? $count : 1) . '</u> <span style="color: #7878FF; font-weight: bold;">' . $itemList[(int)$itemid] . '</span> ' . $itemid . ' <span style="color: #C45; font-weight: bold;">' . $lootRarity . '</span> (<span style="color: #FF9A9A;">' . $chance . '%</span>)<br />';
|
||||
|
||||
if($i % 6 == 0)
|
||||
{
|
||||
if($i != 0)
|
||||
echo '</td></tr>';
|
||||
echo '<tr bgcolor="'.getStyle(0).'"><td width="100">';
|
||||
}
|
||||
echo getItemImage($itemid);
|
||||
$i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript" src="tools/tipped.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="tools/tipped.css"/>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
Tipped.create('.tooltip');
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
$canEdit = hasFlag(FLAG_CONTENT_MONSTERS) || admin();
|
||||
if(isset($_POST['reload_monsters']) && $canEdit)
|
||||
{
|
||||
require LIBS . 'creatures.php';
|
||||
Creatures::loadFromXML(true);
|
||||
if(Creatures::loadFromXML(true)) {
|
||||
if (Creatures::getMonstersList()->hasErrors())
|
||||
error('There were some problems loading your monsters.xml file. Please check system/logs/error.log for more info.');
|
||||
}
|
||||
else {
|
||||
error(Creatures::getLastError());
|
||||
}
|
||||
}
|
||||
|
||||
if($canEdit)
|
||||
@@ -109,7 +76,7 @@ if(empty($_REQUEST['creature']))
|
||||
$whereandorder = ' ORDER BY name';
|
||||
}
|
||||
//send query to database
|
||||
$monsters = $db->query('SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'monsters').' WHERE hide_creature != 1'.$whereandorder);
|
||||
$monsters = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1'.$whereandorder);
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['vdarkborder'].'>';
|
||||
if($order == 'name' && !isset($_REQUEST['desc'])) {
|
||||
echo '<TD class="white" width="200"><B><a href="?subtopic=creatures&order=name&desc=1"><font class="white">Name DESC</a></B></TD>';
|
||||
@@ -168,7 +135,7 @@ if(empty($_REQUEST['creature']))
|
||||
|
||||
|
||||
$monster_name = stripslashes(trim(ucwords($_REQUEST['creature'])));
|
||||
$monster = $db->query('SELECT * FROM '.$db->tableName(TABLE_PREFIX . 'monsters').' WHERE '.$db->fieldName('hide_creature').' != 1 AND '.$db->fieldName('name').' = '.$db->quote($monster_name).';')->fetch();
|
||||
$monster = $db->query('SELECT * FROM `' . TABLE_PREFIX . 'monsters` WHERE `hidden` != 1 AND `name` = '.$db->quote($monster_name).';')->fetch();
|
||||
if(isset($monster['name']))
|
||||
{
|
||||
$title = $monster['name'] . " - Creatures";
|
||||
@@ -204,6 +171,7 @@ if(isset($monster['name']))
|
||||
echo '</TABLE></td><td align=left>
|
||||
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=40%>
|
||||
<tr><td align=left>';
|
||||
$monster['gfx_name'] = trim(mb_strtolower($monster['name'])).".gif";
|
||||
if(!file_exists('images/monsters/'.$monster['gfx_name'])) {
|
||||
$gfx_name = str_replace(" ", "", $monster['gfx_name']);
|
||||
if(file_exists('images/monsters/' . $gfx_name))
|
||||
@@ -217,33 +185,59 @@ if(isset($monster['name']))
|
||||
echo '</td></tr>
|
||||
</TABLE></td></tr><tr><td>
|
||||
<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
|
||||
if(!empty($monster['immunities']))
|
||||
$immunities = json_decode($monster['immunities'], true);
|
||||
if(count($immunities) > 0)
|
||||
{
|
||||
$number_of_rows++;
|
||||
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Immunities: </b></td><td width="100%">'.$monster['immunities'].'</td></tr>';
|
||||
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Immunities: </b></td><td width="100%">'.implode(', ', $immunities).'</td></tr>';
|
||||
}
|
||||
if(!empty($monster['voices']))
|
||||
|
||||
$voices = json_decode($monster['voices'], true);
|
||||
if(count($voices) > 0)
|
||||
{
|
||||
foreach($voices as &$voice) {
|
||||
$voice = '"' . $voice . '"';
|
||||
}
|
||||
|
||||
$number_of_rows++;
|
||||
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Voices: </b></td><td width="100%">'.$monster['voices'].'</td></tr>';
|
||||
echo '<tr BGCOLOR="'.getStyle($number_of_rows).'"><td width="100"><b>Voices: </b></td><td width="100%">'.implode(', ', $voices).'</td></tr>';
|
||||
}
|
||||
echo '</TABLE></td></tr>';
|
||||
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>';
|
||||
$loot = simplexml_load_file($config['data_path'] . 'monster/' . $monster['file_path']);
|
||||
|
||||
$loot = json_decode($monster['loot'], true);
|
||||
if($loot)
|
||||
{
|
||||
if($item = $loot->loot->item)
|
||||
addLoot($item);
|
||||
{
|
||||
echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr><td style="display: block;">';
|
||||
function sort_by_chance($a, $b)
|
||||
{
|
||||
if($a['chance'] == $b['chance']) {
|
||||
return 0;
|
||||
}
|
||||
return ($a['chance'] > $b['chance']) ? -1 : 1;
|
||||
}
|
||||
|
||||
usort($loot, 'sort_by_chance');
|
||||
|
||||
$i = 0;
|
||||
foreach($loot as $item) {
|
||||
$name = getItemNameById($item['id']);
|
||||
$tooltip = $name . '<br/>Chance: ' . round($item['chance'] / 1000, 2) . '%<br/>Max count: ' . $item['count'];
|
||||
|
||||
echo '<img src="' . $config['item_images_url'] . $item['id'] . '.gif" class="tooltip" title="' . $tooltip . '" width="32" height="32" border="0" alt=" ' .$name . '" />';
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo '</td></tr></TABLE>';
|
||||
}
|
||||
|
||||
echo '</TABLE></td></tr>';
|
||||
echo '</td></tr>';
|
||||
echo '</TABLE>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Monster with name <b>'.$monster_name.'</b> doesn\'t exist.';
|
||||
echo "Monster with name <b>" . $monster_name . "</b> doesn't exist.";
|
||||
}
|
||||
|
||||
//back button
|
||||
echo '<br/></br><center><form action="?subtopic=creatures" METHOD=post><div class="BigButton" style="background-image:url('.$template_path.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$template_path.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$template_path.'/images/buttons/_sbutton_back.gif" ></div></div></form></center>';
|
||||
echo $twig->render('creatures.back_button.html.twig');
|
||||
?>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
$title = 'Downloads';
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -24,107 +24,25 @@ if(strtolower($config['forum']) != 'site')
|
||||
return;
|
||||
}
|
||||
|
||||
function parseSmiles($text)
|
||||
{
|
||||
$smileys = array(
|
||||
';D' => 1,
|
||||
':D' => 1,
|
||||
':cool:' => 2,
|
||||
';cool;' => 2,
|
||||
':ekk:' => 3,
|
||||
';ekk;' => 3,
|
||||
';o' => 4,
|
||||
';O' => 4,
|
||||
':o' => 4,
|
||||
':O' => 4,
|
||||
':(' => 5,
|
||||
';(' => 5,
|
||||
':mad:' => 6,
|
||||
';mad;' => 6,
|
||||
';rolleyes;' => 7,
|
||||
':rolleyes:' => 7,
|
||||
':)' => 8,
|
||||
';d' => 9,
|
||||
':d' => 9,
|
||||
';)' => 10
|
||||
);
|
||||
|
||||
foreach($smileys as $search => $replace)
|
||||
$text = str_replace($search, '<img src="images/forum/smile/'.$replace.'.gif" alt="'. $search .'" title="' . $search . '" />', $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
function parseBBCode($text, $smiles)
|
||||
{
|
||||
$rows = 0;
|
||||
while(stripos($text, '[code]') !== false && stripos($text, '[/code]') !== false )
|
||||
{
|
||||
$code = substr($text, stripos($text, '[code]')+6, stripos($text, '[/code]') - stripos($text, '[code]') - 6);
|
||||
if(!is_int($rows / 2)) { $bgcolor = 'ABED25'; } else { $bgcolor = '23ED25'; } $rows++;
|
||||
$text = str_ireplace('[code]'.$code.'[/code]', '<i>Code:</i><br /><table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #CCCCCC; border-width: 2px"><tr><td>'.$code.'</td></tr></table>', $text);
|
||||
}
|
||||
$rows = 0;
|
||||
while(stripos($text, '[quote]') !== false && stripos($text, '[/quote]') !== false )
|
||||
{
|
||||
$quote = substr($text, stripos($text, '[quote]')+7, stripos($text, '[/quote]') - stripos($text, '[quote]') - 7);
|
||||
if(!is_int($rows / 2)) { $bgcolor = 'AAAAAA'; } else { $bgcolor = 'CCCCCC'; } $rows++;
|
||||
$text = str_ireplace('[quote]'.$quote.'[/quote]', '<table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #007900; border-width: 2px"><tr><td>'.$quote.'</td></tr></table>', $text);
|
||||
}
|
||||
$rows = 0;
|
||||
while(stripos($text, '[url]') !== false && stripos($text, '[/url]') !== false )
|
||||
{
|
||||
$url = substr($text, stripos($text, '[url]')+5, stripos($text, '[/url]') - stripos($text, '[url]') - 5);
|
||||
$text = str_ireplace('[url]'.$url.'[/url]', '<a href="'.$url.'" target="_blank">'.$url.'</a>', $text);
|
||||
}
|
||||
|
||||
$xhtml = false;
|
||||
$tags = array(
|
||||
'#\[b\](.*?)\[/b\]#si' => ($xhtml ? '<strong>\\1</strong>' : '<b>\\1</b>'),
|
||||
'#\[i\](.*?)\[/i\]#si' => ($xhtml ? '<em>\\1</em>' : '<i>\\1</i>'),
|
||||
'#\[u\](.*?)\[/u\]#si' => ($xhtml ? '<span style="text-decoration: underline;">\\1</span>' : '<u>\\1</u>'),
|
||||
'#\[s\](.*?)\[/s\]#si' => ($xhtml ? '<strike>\\1</strike>' : '<s>\\1</s>'),
|
||||
|
||||
'#\[guild\](.*?)\[/guild\]#si' => urldecode(generateLink(getGuildLink('$1', false), '$1', true)),
|
||||
'#\[house\](.*?)\[/house\]#si' => urldecode(generateLink(getHouseLink('$1', false), '$1', true)),
|
||||
'#\[player\](.*?)\[/player\]#si' => urldecode(generateLink(getPlayerLink('$1', false), '$1', true)),
|
||||
// TODO: [poll] tag
|
||||
|
||||
'#\[color=(.*?)\](.*?)\[/color\]#si' => ($xhtml ? '<span style="color: \\1;">\\2</span>' : '<font color="\\1">\\2</font>'),
|
||||
'#\[img\](.*?)\[/img\]#si' => ($xhtml ? '<img src="\\1" border="0" alt="" />' : '<img src="\\1" border="0" alt="">'),
|
||||
'#\[url=(.*?)\](.*?)\[/url\]#si' => '<a href="\\1" title="\\2">\\2</a>',
|
||||
// '#\[email\](.*?)\[/email\]#si' => '<a href="mailto:\\1" title="Email \\1">\\1</a>',
|
||||
'#\[code\](.*?)\[/code\]#si' => '<code>\\1</code>',
|
||||
// '#\[align=(.*?)\](.*?)\[/align\]#si' => ($xhtml ? '<div style="text-align: \\1;">\\2</div>' : '<div align="\\1">\\2</div>'),
|
||||
// '#\[br\]#si' => ($xhtml ? '<br style="clear: both;" />' : '<br>'),
|
||||
);
|
||||
|
||||
foreach($tags as $search => $replace)
|
||||
$text = preg_replace($search, $replace, $text);
|
||||
|
||||
return ($smiles == 0 ? parseSmiles($text) : $text);
|
||||
}
|
||||
|
||||
function showPost($topic, $text, $smiles)
|
||||
{
|
||||
$text = nl2br($text);
|
||||
$post = '';
|
||||
if(!empty($topic))
|
||||
$post .= '<b>'.($smiles == 0 ? parseSmiles($topic) : $topic).'</b><hr />';
|
||||
$post .= parseBBCode($text, $smiles);
|
||||
return $post;
|
||||
}
|
||||
if(!$logged)
|
||||
echo 'You are not logged in. <a href="?subtopic=accountmanagement&redirect=' . BASE_URL . urlencode('?subtopic=forum') . '">Log in</a> to post on the forum.<br /><br />';
|
||||
|
||||
$canEdit = hasFlag(FLAG_CONTENT_FORUM) || superAdmin();
|
||||
if($canEdit)
|
||||
{
|
||||
$groups = new OTS_Groups_List();
|
||||
|
||||
if(!empty($action))
|
||||
{
|
||||
if($action == 'delete_board' || $action == 'edit_board' || $action == 'hide_board' || $action == 'moveup_board' || $action == 'movedown_board')
|
||||
$id = $_REQUEST['id'];
|
||||
|
||||
if(isset($_REQUEST['access']))
|
||||
$access = $_REQUEST['access'];
|
||||
|
||||
if(isset($_REQUEST['guild']))
|
||||
$guild = $_REQUEST['guild'];
|
||||
|
||||
if(isset($_REQUEST['name']))
|
||||
$name = $_REQUEST['name'];
|
||||
|
||||
@@ -134,7 +52,7 @@ if($canEdit)
|
||||
$errors = array();
|
||||
|
||||
if($action == 'add_board') {
|
||||
if(Forum::add_board($name, $description, $errors))
|
||||
if(Forum::add_board($name, $description, $access, $guild, $errors))
|
||||
$action = $name = $description = '';
|
||||
}
|
||||
else if($action == 'delete_board') {
|
||||
@@ -146,11 +64,14 @@ if($canEdit)
|
||||
if(isset($id) && !isset($name)) {
|
||||
$board = Forum::get_board($id);
|
||||
$name = $board['name'];
|
||||
$access = $board['access'];
|
||||
$guild = $board['guild'];
|
||||
$description = $board['description'];
|
||||
}
|
||||
else {
|
||||
Forum::update_board($id, $name, $description);
|
||||
Forum::update_board($id, $name, $access, $guild, $description);
|
||||
$action = $name = $description = '';
|
||||
$access = $guild = 0;
|
||||
}
|
||||
}
|
||||
else if($action == 'hide_board') {
|
||||
@@ -173,12 +94,17 @@ if($canEdit)
|
||||
}
|
||||
|
||||
if(empty($action) || $action == 'edit_board') {
|
||||
$guilds = $db->query('SELECT `id`, `name` FROM `guilds`')->fetchAll();
|
||||
echo $twig->render('forum.add_board.html.twig', array(
|
||||
'link' => getLink('forum', ($action == 'edit_board' ? 'edit_board' : 'add_board')),
|
||||
'action' => $action,
|
||||
'id' => isset($id) ? $id : null,
|
||||
'name' => isset($name) ? $name : null,
|
||||
'description' => isset($description) ? $description : null
|
||||
'description' => isset($description) ? $description : null,
|
||||
'access' => isset($access) ? $access : 0,
|
||||
'guild' => isset($guild) ? $guild : null,
|
||||
'groups' => $groups,
|
||||
'guilds' => $guilds
|
||||
));
|
||||
|
||||
if($action == 'edit_board')
|
||||
@@ -193,7 +119,9 @@ foreach(getForumBoards() as $section)
|
||||
'id' => $section['id'],
|
||||
'name' => $section['name'],
|
||||
'description' => $section['description'],
|
||||
'closed' => $section['closed'] == '1'
|
||||
'closed' => $section['closed'] == '1',
|
||||
'guild' => $section['guild'],
|
||||
'access' => $section['access']
|
||||
);
|
||||
|
||||
if($canEdit) {
|
||||
@@ -214,21 +142,24 @@ if(empty($action))
|
||||
$counters[$data['section']] = array('threads' => $data['threads'], 'posts' => $data['replies'] + $data['threads']);
|
||||
foreach($sections as $id => $section)
|
||||
{
|
||||
$last_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`section` = ".(int) $id." AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 1")->fetch();
|
||||
$boards[] = array(
|
||||
'id' => $id,
|
||||
'link' => getForumBoardLink($id),
|
||||
'name' => $section['name'],
|
||||
'description' => $section['description'],
|
||||
'hidden' => $section['hidden'],
|
||||
'posts' => isset($counters[$id]['posts']) ? $counters[$id]['posts'] : 0,
|
||||
'threads' => isset($counters[$id]['threads']) ? $counters[$id]['threads'] : 0,
|
||||
'last_post' => array(
|
||||
'name' => isset($last_post['name']) ? $last_post['name'] : null,
|
||||
'date' => isset($last_post['post_date']) ? $last_post['post_date'] : null,
|
||||
'player_link' => isset($last_post['name']) ? getPlayerLink($last_post['name']) : null,
|
||||
)
|
||||
);
|
||||
$show = true;
|
||||
if(Forum::hasAccess($id)) {
|
||||
$last_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`section` = ".(int) $id." AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 1")->fetch();
|
||||
$boards[] = array(
|
||||
'id' => $id,
|
||||
'link' => getForumBoardLink($id),
|
||||
'name' => $section['name'],
|
||||
'description' => $section['description'],
|
||||
'hidden' => $section['hidden'],
|
||||
'posts' => isset($counters[$id]['posts']) ? $counters[$id]['posts'] : 0,
|
||||
'threads' => isset($counters[$id]['threads']) ? $counters[$id]['threads'] : 0,
|
||||
'last_post' => array(
|
||||
'name' => isset($last_post['name']) ? $last_post['name'] : null,
|
||||
'date' => isset($last_post['post_date']) ? $last_post['post_date'] : null,
|
||||
'player_link' => isset($last_post['name']) ? getPlayerLink($last_post['name']) : null,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
echo $twig->render('forum.boards.html.twig', array(
|
||||
@@ -240,144 +171,10 @@ if(empty($action))
|
||||
return;
|
||||
}
|
||||
|
||||
$links_to_pages = '';
|
||||
if($action == 'show_board')
|
||||
|
||||
if($action == 'show_board' || $action == 'show_thread')
|
||||
{
|
||||
$section_id = (int) $_REQUEST['id'];
|
||||
$_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
|
||||
$threads_count = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS threads_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`section` = ".(int) $section_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = `" . TABLE_PREFIX . "forum`.`id`")->fetch();
|
||||
for($i = 0; $i < $threads_count['threads_count'] / $config['forum_threads_per_page']; $i++)
|
||||
{
|
||||
if($i != $_page)
|
||||
$links_to_pages .= '<a href="' . getForumBoardLink($section_id, $i) . '">'.($i + 1).'</a> ';
|
||||
else
|
||||
$links_to_pages .= '<b>'.($i + 1).' </b>';
|
||||
}
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <b>'.$sections[$section_id]['name'].'</b>';
|
||||
if(!$sections[$section_id]['closed'] || Forum::isModerator())
|
||||
{
|
||||
echo '<br /><br />
|
||||
<a href="?subtopic=forum&action=new_thread§ion_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
}
|
||||
|
||||
echo '<br /><br />Page: '.$links_to_pages.'<br />';
|
||||
$last_threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`last_post`, `" . TABLE_PREFIX . "forum`.`replies`, `" . TABLE_PREFIX . "forum`.`views`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`section` = ".(int) $section_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = `" . TABLE_PREFIX . "forum`.`id` ORDER BY `" . TABLE_PREFIX . "forum`.`last_post` DESC LIMIT ".$config['forum_threads_per_page']." OFFSET ".($_page * $config['forum_threads_per_page']))->fetchAll();
|
||||
if(isset($last_threads[0]))
|
||||
{
|
||||
echo '<table width="100%"><tr bgcolor="'.$config['vdarkborder'].'" align="center"><td><font color="white" size="1"><b>Thread</b></font></td><td><font color="white" size="1"><b>Thread Starter</b></font></td><td><font color="white" size="1"><b>Replies</b></font></td><td><font color="white" size="1"><b>Views</b></font></td><td><font color="white" size="1"><b>Last Post</b></font></td></tr>';
|
||||
|
||||
$player = new OTS_Player();
|
||||
foreach($last_threads as $thread)
|
||||
{
|
||||
echo '<tr bgcolor="' . getStyle($number_of_rows++) . '"><td>';
|
||||
if(Forum::isModerator())
|
||||
{
|
||||
echo '<a href="?subtopic=forum&action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>';
|
||||
echo '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><font color="red">[REMOVE]</font></a> ';
|
||||
}
|
||||
|
||||
$player->load($thread['player_id']);
|
||||
if(!$player->isLoaded()) {
|
||||
error('Forum error: Player not loaded.');
|
||||
die();
|
||||
}
|
||||
|
||||
$player_account = $player->getAccount();
|
||||
$canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
|
||||
|
||||
echo '<a href="' . getForumThreadLink($thread['id']) . '">'.($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])) . '</a><br /><small>'.($canEditForum ? substr(strip_tags($thread['post_text']), 0, 50) : htmlspecialchars(substr($thread['post_text'], 0, 50))).'...</small></td><td>' . getPlayerLink($thread['name']) . '</td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';
|
||||
if($thread['last_post'] > 0)
|
||||
{
|
||||
$last_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id']." AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 1")->fetch();
|
||||
if(isset($last_post['name']))
|
||||
echo date('d.m.y H:i:s', $last_post['post_date']).'<br />by ' . getPlayerLink($last_post['name']);
|
||||
else
|
||||
echo 'No posts.';
|
||||
}
|
||||
else
|
||||
echo date('d.m.y H:i:s', $thread['post_date']).'<br />by ' . getPlayerLink($thread['name']);
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
if(!$sections[$section_id]['closed'] || Forum::isModerator())
|
||||
echo '<br /><a href="?subtopic=forum&action=new_thread§ion_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
}
|
||||
else
|
||||
echo '<h3>No threads in this board.</h3>';
|
||||
return;
|
||||
}
|
||||
if($action == 'show_thread')
|
||||
{
|
||||
$thread_id = (int) $_REQUEST['id'];
|
||||
$_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
|
||||
$thread_name = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_topic` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`id` = `" . TABLE_PREFIX . "forum`.`first_post` AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` LIMIT 1")->fetch();
|
||||
if(!empty($thread_name['name']))
|
||||
{
|
||||
$posts_count = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id)->fetch();
|
||||
for($i = 0; $i < $posts_count['posts_count'] / $config['forum_threads_per_page']; $i++)
|
||||
{
|
||||
if($i != $_page)
|
||||
$links_to_pages .= '<a href="' . getForumThreadLink($thread_id, $i) . '">'.($i + 1).'</a> ';
|
||||
else
|
||||
$links_to_pages .= '<b>'.($i + 1).' </b>';
|
||||
}
|
||||
$threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `players`.`account_id`, `players`.`vocation`" . (fieldExist('promotion', 'players') ? ", `players`.`promotion`" : "") . ", `players`.`level`, `" . TABLE_PREFIX . "forum`.`id`,`" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`section`,`" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`last_edit_aid`, `" . TABLE_PREFIX . "forum`.`edit_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` LIMIT ".$config['forum_posts_per_page']." OFFSET ".($_page * $config['forum_posts_per_page']))->fetchAll();
|
||||
if(isset($threads[0]['name']))
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($threads[0]['section']) . '">'.$sections[$threads[0]['section']]['name'].'</a> >> <b>'.$thread_name['post_topic'].'</b>';
|
||||
echo '<br /><br /><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"><img src="images/forum/post.gif" border="0" /></a><br /><br />Page: '.$links_to_pages.'<br /><table width="100%"><tr bgcolor="'.$config['lightborder'].'" width="100%"><td colspan="2"><font size="4"><b>'.htmlspecialchars($thread_name['post_topic']).'</b></font><font size="1"><br />by ' . getPlayerLink($thread_name['name']) . '</font></td></tr><tr bgcolor="'.$config['vdarkborder'].'"><td width="200"><font color="white" size="1"><b>Author</b></font></td><td> </td></tr>';
|
||||
$player = $ots->createObject('Player');
|
||||
foreach($threads as $thread)
|
||||
{
|
||||
$player->load($thread['player_id']);
|
||||
if(!$player->isLoaded()) {
|
||||
error('Forum error: Player not loaded.');
|
||||
die();
|
||||
}
|
||||
|
||||
echo '<tr bgcolor="' . getStyle($number_of_rows++) . '"><td valign="top">' . getPlayerLink($thread['name']) . '<br /><br /><font size="1">Profession: '.$config['vocations'][$player->getVocation()].'<br />Level: '.$thread['level'].'<br />';
|
||||
|
||||
$rank = $player->getRank();
|
||||
if($rank->isLoaded())
|
||||
{
|
||||
$guild = $rank->getGuild();
|
||||
if($guild->isLoaded())
|
||||
echo $rank->getName().' of <a href="'.getGuildLink($guild->getName(), false).'">'.$guild->getName().'</a><br />';
|
||||
}
|
||||
$player_account = $player->getAccount();
|
||||
$canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
|
||||
|
||||
$posts = $db->query("SELECT COUNT(`id`) AS 'posts' FROM `" . TABLE_PREFIX . "forum` WHERE `author_aid`=".(int) $thread['account_id'])->fetch();
|
||||
echo '<br />Posts: '.(int) $posts['posts'].'<br /></font></td><td valign="top">'.showPost(($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($canEditForum ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile']).'</td></tr>
|
||||
<tr bgcolor="'.getStyle($number_of_rows++).'"><td><font size="1">'.date('d.m.y H:i:s', $thread['post_date']);
|
||||
if($thread['edit_date'] > 0)
|
||||
{
|
||||
if($thread['last_edit_aid'] != $thread['author_aid'])
|
||||
echo '<br />Edited by moderator';
|
||||
else
|
||||
echo '<br />Edited by '.$thread['name'];
|
||||
echo '<br />on '.date('d.m.y H:i:s', $thread['edit_date']);
|
||||
}
|
||||
echo '</font></td><td>';
|
||||
if(Forum::isModerator())
|
||||
if($thread['first_post'] != $thread['id'])
|
||||
echo '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove post of '.$thread['name'].'?\')"><font color="red">REMOVE POST</font></a>';
|
||||
else
|
||||
{
|
||||
echo '<a href="?subtopic=forum&action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>';
|
||||
echo '<br/><a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><font color="red">REMOVE THREAD</font></a>';
|
||||
}
|
||||
if($logged && ($thread['account_id'] == $account_logged->getId() || Forum::isModerator()))
|
||||
echo '<br/><a href="?subtopic=forum&action=edit_post&id='.$thread['id'].'">EDIT POST</a>';
|
||||
if($logged)
|
||||
echo '<br/><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"e='.$thread['id'].'">Quote</a>';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</table><br /><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"><img src="images/forum/post.gif" border="0" /></a>';
|
||||
}
|
||||
else
|
||||
echo 'Thread with this ID does not exits.';
|
||||
|
||||
require(PAGES . 'forum/' . $action . '.php');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -387,387 +184,8 @@ if(!$logged)
|
||||
return;
|
||||
}
|
||||
|
||||
if($action == 'remove_post')
|
||||
{
|
||||
if(Forum::isModerator())
|
||||
{
|
||||
$id = (int) $_REQUEST['id'];
|
||||
$post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
|
||||
if($post['id'] == $id)
|
||||
{
|
||||
if($post['id'] == $post['first_post'])
|
||||
{
|
||||
$db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `first_post` = ".$post['id']);
|
||||
header('Location: ' . getForumBoardLink($post['section']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`id` < ".$id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $post['first_post'])->fetch();
|
||||
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
|
||||
$db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post['id']);
|
||||
header('Location: ' . getForumThreadLink($post['first_post'], (int) $_page));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'Post with ID ' . $id . ' does not exist.';
|
||||
}
|
||||
else
|
||||
echo 'You are not logged in or you are not moderator.';
|
||||
}
|
||||
if($action == 'new_post')
|
||||
{
|
||||
if(Forum::canPost($account_logged))
|
||||
{
|
||||
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
|
||||
$thread_id = (int) $_REQUEST['thread_id'];
|
||||
$thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." LIMIT 1")->fetch();
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread_id) . '">'.$thread['post_topic'].'</a> >> <b>Post new reply</b><br /><h3>'.$thread['post_topic'].'</h3>';
|
||||
if(isset($thread['id']))
|
||||
{
|
||||
$quote = isset($_REQUEST['quote']) ? (int) $_REQUEST['quote'] : NULL;
|
||||
$text = isset($_REQUEST['text']) ? stripslashes(trim($_REQUEST['text'])) : NULL;
|
||||
$char_id = (int) (isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
|
||||
$post_topic = isset($_REQUEST['topic']) ? stripslashes(trim($_REQUEST['topic'])) : '';
|
||||
$smile = (int) (isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
|
||||
$saved = false;
|
||||
if(isset($_REQUEST['quote']))
|
||||
{
|
||||
$quoted_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`id` = ".(int) $quote)->fetchAll();
|
||||
if(isset($quoted_post[0]['name']))
|
||||
$text = '[i]Originally posted by '.$quoted_post[0]['name'].' on '.date('d.m.y H:i:s', $quoted_post[0]['post_date']).':[/i][quote]'.$quoted_post[0]['post_text'].'[/quote]';
|
||||
}
|
||||
elseif(isset($_REQUEST['save']))
|
||||
{
|
||||
$lenght = 0;
|
||||
for($i = 0; $i < strlen($text); $i++)
|
||||
{
|
||||
if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
if($lenght < 1 || strlen($text) > 15000)
|
||||
$errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
|
||||
if($char_id == 0)
|
||||
$errors[] = 'Please select a character.';
|
||||
$player_on_account = false;
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
foreach($players_from_account as $player)
|
||||
if($char_id == $player['id'])
|
||||
$player_on_account = true;
|
||||
if(!$player_on_account)
|
||||
$errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
|
||||
}
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
$last_post = 0;
|
||||
$query = $db->query('SELECT post_date FROM ' . TABLE_PREFIX . 'forum ORDER BY post_date DESC LIMIT 1');
|
||||
if($query->rowCount() > 0)
|
||||
{
|
||||
$query = $query->fetch();
|
||||
$last_post = $query['post_date'];
|
||||
}
|
||||
if($last_post+$config['forum_post_interval']-time() > 0 && !Forum::isModerator())
|
||||
$errors[] = 'You can post one time per '.$config['forum_post_interval'].' seconds. Next post after '.($last_post+$config['forum_post_interval']-time()).' second(s).';
|
||||
}
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
$saved = true;
|
||||
$db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`id` ,`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES (NULL, '".$thread['id']."', '0', '".$thread['section']."', '0', '0', '".$account_logged->getId()."', '".(int) $char_id."', ".$db->quote($text).", ".$db->quote($post_topic).", '".(int) $smile."', '".time()."', '0', '0', '".$_SERVER['REMOTE_ADDR']."')");
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `replies`=`replies`+1, `last_post`=".time()." WHERE `id` = ".(int) $thread_id);
|
||||
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".time()." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id'])->fetch();
|
||||
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
|
||||
header('Location: ' . getForumThreadLink($thread_id, $_page));
|
||||
echo '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id, $_page) . '">GO BACK TO LAST THREAD</a>';
|
||||
}
|
||||
}
|
||||
if(!$saved)
|
||||
{
|
||||
if(!empty($errors))
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
echo '<form action="?" method="POST">
|
||||
<input type="hidden" name="action" value="new_post" />
|
||||
<input type="hidden" name="thread_id" value="'.$thread_id.'" />
|
||||
<input type="hidden" name="subtopic" value="forum" />
|
||||
<input type="hidden" name="save" value="save" />
|
||||
<table width="100%">
|
||||
<tr bgcolor="'.$config['vdarkborder'].'">
|
||||
<td colspan="2"><font color="white"><b>Post New Reply</b></font></td>
|
||||
</tr>
|
||||
<tr bgcolor="'.$config['darkborder'].'">
|
||||
<td width="180"><b>Character:</b></td>
|
||||
<td>
|
||||
<select name="char_id">
|
||||
<option value="0">(Choose character)</option>';
|
||||
foreach($players_from_account as $player)
|
||||
{
|
||||
echo '<option value="'.$player['id'].'"';
|
||||
if($player['id'] == $char_id)
|
||||
echo ' selected="selected"';
|
||||
echo '>'.$player['name'].'</option>';
|
||||
}
|
||||
echo '</select></td></tr><tr bgcolor="'.$config['lightborder'].'"><td><b>Topic:</b></td><td><input type="text" name="topic" value="'.htmlspecialchars($post_topic).'" size="40" maxlength="60" /> (Optional)</td></tr>
|
||||
<tr bgcolor="'.$config['darkborder'].'"><td valign="top"><b>Message:</b><font size="1"><br />You can use:<br />[player]Nick[/player]<br />[url]http://address.com/[/url]<br />[img]http://images.com/images3.gif[/img]<br />[code]Code[/code]<br />[b]<b>Text</b>[/b]<br />[i]<i>Text</i>[/i]<br />[u]<u>Text</u>[/u]<br />and smileys:<br />;) , :) , :D , :( , :rolleyes:<br />:cool: , :eek: , :o , :p</font></td><td><textarea rows="10" cols="60" name="text">'.htmlspecialchars($text).'</textarea><br />(Max. 15,000 letters)</td></tr>
|
||||
<tr bgcolor="'.$config['lightborder'].'"><td valign="top">Options:</td><td><label><input type="checkbox" name="smile" value="1"';
|
||||
if($smile == 1)
|
||||
echo ' checked="checked"';
|
||||
echo '/>Disable Smileys in This Post </label></td></tr></table><center><input type="submit" value="Post Reply" /></center></form>';
|
||||
$threads = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_smile` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` DESC LIMIT 10")->fetchAll();
|
||||
echo '<table width="100%"><tr bgcolor="'.$config['vdarkborder'].'"><td colspan="2"><font color="white"><b>Last 5 posts from thread: '.$thread['post_topic'].'</b></font></td></tr>';
|
||||
foreach($threads as $thread)
|
||||
{
|
||||
echo '<tr bgcolor="' . getStyle($number_of_rows++) . '"><td>'.$thread['name'].'</td><td>'.showPost($thread['post_topic'], $thread['post_text'], $thread['post_smile']).'</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'Thread with ID '.$thread_id.' doesn\'t exist.';
|
||||
}
|
||||
else
|
||||
echo "Your account is banned, deleted or you don't have any player with level " . $config['forum_level_required'] . " on your account. You can't post.";
|
||||
}
|
||||
|
||||
if($action == 'edit_post')
|
||||
{
|
||||
if(Forum::canPost($account_logged))
|
||||
{
|
||||
$post_id = (int) $_REQUEST['id'];
|
||||
$thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $post_id." LIMIT 1")->fetch();
|
||||
if(isset($thread['id']))
|
||||
{
|
||||
$first_post = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread['first_post']." LIMIT 1")->fetch();
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread['first_post']) . '">'.$first_post['post_topic'].'</a> >> <b>Edit post</b>';
|
||||
if($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())
|
||||
{
|
||||
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
|
||||
$saved = false;
|
||||
if(isset($_REQUEST['save']))
|
||||
{
|
||||
$text = stripslashes(trim($_REQUEST['text']));
|
||||
$char_id = (int) $_REQUEST['char_id'];
|
||||
$post_topic = stripslashes(trim($_REQUEST['topic']));
|
||||
$smile = (int) $_REQUEST['smile'];
|
||||
$lenght = 0;
|
||||
for($i = 0; $i <= strlen($post_topic); $i++)
|
||||
{
|
||||
if(ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
if(($lenght < 1 || strlen($post_topic) > 60) && $thread['id'] == $thread['first_post'])
|
||||
$errors[] = 'Too short or too long topic (short: '.$lenght.' long: '.strlen($post_topic).' letters). Minimum 1 letter, maximum 60 letters.';
|
||||
$lenght = 0;
|
||||
for($i = 0; $i <= strlen($text); $i++)
|
||||
{
|
||||
if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
if($lenght < 1 || strlen($text) > 15000)
|
||||
$errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
|
||||
if($char_id == 0)
|
||||
$errors[] = 'Please select a character.';
|
||||
if(empty($post_topic) && $thread['id'] == $thread['first_post'])
|
||||
$errors[] = 'Thread topic can\'t be empty.';
|
||||
$player_on_account == false;
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
foreach($players_from_account as $player)
|
||||
if($char_id == $player['id'])
|
||||
$player_on_account = true;
|
||||
if(!$player_on_account)
|
||||
$errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
|
||||
}
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
$saved = true;
|
||||
if($account_logged->getId() != $thread['author_aid'])
|
||||
$char_id = $thread['author_guid'];
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $char_id.", `post_text` = ".$db->quote($text).", `post_topic` = ".$db->quote($post_topic).", `post_smile` = ".(int) $smile.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']);
|
||||
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".$thread['post_date']." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['first_post'])->fetch();
|
||||
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
|
||||
header('Location: ' . getForumThreadLink($thread['first_post'], $_page));
|
||||
echo '<br />Thank you for editing post.<br /><a href="' . getForumThreadLink($thread['first_post'], $_page) . '">GO BACK TO LAST THREAD</a>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = $thread['post_text'];
|
||||
$char_id = (int) $thread['author_guid'];
|
||||
$post_topic = $thread['post_topic'];
|
||||
$smile = (int) $thread['post_smile'];
|
||||
}
|
||||
if(!$saved)
|
||||
{
|
||||
if(!empty($errors))
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
echo '<br /><form action="?" method="POST"><input type="hidden" name="action" value="edit_post" /><input type="hidden" name="id" value="'.$post_id.'" /><input type="hidden" name="subtopic" value="forum" /><input type="hidden" name="save" value="save" /><table width="100%"><tr bgcolor="'.$config['vdarkborder'].'"><td colspan="2"><font color="white"><b>Edit Post</b></font></td></tr><tr bgcolor="'.$config['darkborder'].'"><td width="180"><b>Character:</b></td><td><select name="char_id"><option value="0">(Choose character)</option>';
|
||||
foreach($players_from_account as $player)
|
||||
{
|
||||
echo '<option value="'.$player['id'].'"';
|
||||
if($player['id'] == $char_id)
|
||||
echo ' selected="selected"';
|
||||
echo '>'.$player['name'].'</option>';
|
||||
}
|
||||
echo '</select></td></tr><tr bgcolor="'.$config['lightborder'].'"><td><b>Topic:</b></td><td><input type="text" value="'.htmlspecialchars($post_topic).'" name="topic" size="40" maxlength="60" /> (Optional)</td></tr>
|
||||
<tr bgcolor="'.$config['darkborder'].'"><td valign="top"><b>Message:</b><font size="1"><br />You can use:<br />[player]Nick[/player]<br />[url]http://address.com/[/url]<br />[img]http://images.com/images3.gif[/img]<br />[code]Code[/code]<br />[b]<b>Text</b>[/b]<br />[i]<i>Text</i>[/i]<br />[u]<u>Text</u>[/u]<br />and smileys:<br />;) , :) , :D , :( , :rolleyes:<br />:cool: , :eek: , :o , :p</font></td><td><textarea rows="10" cols="60" name="text">'.htmlspecialchars($text).'</textarea><br />(Max. 15,000 letters)</td></tr>
|
||||
<tr bgcolor="'.$config['lightborder'].'"><td valign="top">Options:</td><td><label><input type="checkbox" name="smile" value="1"';
|
||||
if($smile == 1)
|
||||
echo ' checked="checked"';
|
||||
echo '/>Disable Smileys in This Post </label></td></tr></table><center><input type="submit" value="Save Post" /></center></form>';
|
||||
}
|
||||
}
|
||||
else
|
||||
echo '<br />You are not an author of this post.';
|
||||
}
|
||||
else
|
||||
echo '<br />Post with ID '.$post_id.' doesn\'t exist.';
|
||||
}
|
||||
else
|
||||
echo '<br />Your account is banned, deleted or you don\'t have any player with level '.$config['forum_level_required'].' on your account. You can\'t post.';
|
||||
}
|
||||
|
||||
if($action == 'new_thread')
|
||||
{
|
||||
if(Forum::canPost($account_logged))
|
||||
{
|
||||
$players_from_account = $db->query('SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = '.(int) $account_logged->getId())->fetchAll();
|
||||
$section_id = isset($_REQUEST['section_id']) ? $_REQUEST['section_id'] : null;
|
||||
if($section_id !== null) {
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($section_id) . '">' . $sections[$section_id]['name'] . '</a> >> <b>Post new thread</b><br />';
|
||||
if (isset($sections[$section_id]['name'])) {
|
||||
if ($sections[$section_id]['closed'] && !Forum::isModerator())
|
||||
$errors[] = 'You cannot create topic on this board.';
|
||||
|
||||
$quote = (int)(isset($_REQUEST['quote']) ? $_REQUEST['quote'] : 0);
|
||||
$text = isset($_REQUEST['text']) ? stripslashes($_REQUEST['text']) : '';
|
||||
$char_id = (int)(isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
|
||||
$post_topic = isset($_REQUEST['topic']) ? stripslashes($_REQUEST['topic']) : '';
|
||||
$smile = (int)(isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
|
||||
$saved = false;
|
||||
if (isset($_REQUEST['save'])) {
|
||||
$errors = array();
|
||||
|
||||
$lenght = 0;
|
||||
for ($i = 0; $i < strlen($post_topic); $i++) {
|
||||
if (ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
if ($lenght < 1 || strlen($post_topic) > 60)
|
||||
$errors[] = 'Too short or too long topic (short: ' . $lenght . ' long: ' . strlen($post_topic) . ' letters). Minimum 1 letter, maximum 60 letters.';
|
||||
$lenght = 0;
|
||||
for ($i = 0; $i < strlen($text); $i++) {
|
||||
if (ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
if ($lenght < 1 || strlen($text) > 15000)
|
||||
$errors[] = 'Too short or too long post (short: ' . $lenght . ' long: ' . strlen($text) . ' letters). Minimum 1 letter, maximum 15000 letters.';
|
||||
|
||||
if ($char_id == 0)
|
||||
$errors[] = 'Please select a character.';
|
||||
$player_on_account = false;
|
||||
|
||||
if (count($errors) == 0) {
|
||||
foreach ($players_from_account as $player)
|
||||
if ($char_id == $player['id'])
|
||||
$player_on_account = true;
|
||||
if (!$player_on_account)
|
||||
$errors[] = 'Player with selected ID ' . $char_id . ' doesn\'t exist or isn\'t on your account';
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
$last_post = 0;
|
||||
$query = $db->query('SELECT `post_date` FROM `' . TABLE_PREFIX . 'forum` ORDER BY `post_date` DESC LIMIT 1');
|
||||
if ($query->rowCount() > 0) {
|
||||
$query = $query->fetch();
|
||||
$last_post = $query['post_date'];
|
||||
}
|
||||
if ($last_post + $config['forum_post_interval'] - time() > 0 && !Forum::isModerator())
|
||||
$errors[] = 'You can post one time per ' . $config['forum_post_interval'] . ' seconds. Next post after ' . ($last_post + $config['forum_post_interval'] - time()) . ' second(s).';
|
||||
}
|
||||
if (count($errors) == 0) {
|
||||
$saved = true;
|
||||
$db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
|
||||
$thread_id = $db->lastInsertId();
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=" . (int)$thread_id . " WHERE `id` = " . (int)$thread_id);
|
||||
header('Location: ' . getForumThreadLink($thread_id));
|
||||
echo '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id) . '">GO BACK TO LAST THREAD</a>';
|
||||
}
|
||||
}
|
||||
if (!$saved) {
|
||||
if (!empty($errors))
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
echo $twig->render('forum.new_thread.html.twig', array(
|
||||
'section_id' => $section_id,
|
||||
'players' => $players_from_account,
|
||||
'post_player_id' => $char_id,
|
||||
'post_thread' => $post_topic,
|
||||
'text' => $text,
|
||||
'smiles_enabled' => $smile > 0
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'Board with ID ' . $board_id . ' doesn\'t exist.';
|
||||
}
|
||||
else
|
||||
echo 'Please enter section_id.';
|
||||
}
|
||||
else
|
||||
echo 'Your account is banned, deleted or you don\'t have any player with level '.$config['forum_level_required'].' on your account. You can\'t post.';
|
||||
}
|
||||
|
||||
//Board Change Function. Scripted by Cybermaster and Absolute Mango
|
||||
if($action == 'move_thread')
|
||||
{
|
||||
if(Forum::isModerator())
|
||||
{
|
||||
$id = (int) $_REQUEST['id'];
|
||||
$post = $db->query("SELECT `id`, `section`, `first_post`, `post_topic`, `author_guid` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
|
||||
$name= $db->query("SELECT `name` FROM `players` WHERE `id` = ".$post['author_guid']." ")->fetch();
|
||||
if($post['id'] == $id)
|
||||
{
|
||||
if($post['id'] == $post['first_post'])
|
||||
{
|
||||
echo $twig->render('forum.move_thread.html.twig', array(
|
||||
'thread' => $post['post_topic'],
|
||||
'author' => $name[0],
|
||||
'board' => $sections[$post['section']]['name'],
|
||||
'post_id' => $post['id'],
|
||||
'sections' => $sections,
|
||||
'section_link' => getForumBoardLink($post['section']),
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'Post with ID '.$id.' does not exist.';
|
||||
}
|
||||
else
|
||||
echo 'You are not logged in or you are not moderator.';
|
||||
}
|
||||
|
||||
if($action == 'moved_thread')
|
||||
{
|
||||
if(Forum::isModerator())
|
||||
{
|
||||
$id = (int) $_REQUEST['id'];
|
||||
$board = (int) $_REQUEST['section'];
|
||||
$post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
|
||||
if($post['id'] == $id)
|
||||
{
|
||||
if($post['id'] == $post['first_post'])
|
||||
{
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `section` = ".$board." WHERE `id` = ".$post['id']."") or die(mysql_error());
|
||||
$nPost = $db->query( 'SELECT `section` FROM `' . TABLE_PREFIX . 'forum` WHERE `id` = \''.$id.'\' LIMIT 1;' )->fetch();
|
||||
header('Location: ' . getForumBoardLink($nPost['section']));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'Post with ID ' . $id . ' does not exist.';
|
||||
}
|
||||
else
|
||||
echo 'You are not logged in or you are not moderator.';
|
||||
if(file_exists(PAGES . 'forum/' . $action . '.php')) {
|
||||
require(PAGES . 'forum/' . $action . '.php');
|
||||
}
|
||||
|
||||
class Forum
|
||||
@@ -793,7 +211,22 @@ class Forum
|
||||
return hasFlag(FLAG_CONTENT_FORUM) || admin();
|
||||
}
|
||||
|
||||
static public function add_board($name, $description, &$errors)
|
||||
static public function add_post($thread_id, $section, $author_aid, $author_guid, $post_text, $post_topic, $smile)
|
||||
{
|
||||
global $db;
|
||||
$db->insert(TABLE_PREFIX . 'forum', array(
|
||||
'first_post' => $thread_id,
|
||||
'section' => $section,
|
||||
'author_aid' => $author_aid,
|
||||
'author_guid' => $author_guid,
|
||||
'post_text' => $post_text,
|
||||
'post_topic' => $post_topic,
|
||||
'post_smile' => $smile,
|
||||
'post_date' => time(),
|
||||
'post_ip' => $_SERVER['REMOTE_ADDR']
|
||||
));
|
||||
}
|
||||
static public function add_board($name, $description, $access, $guild, &$errors)
|
||||
{
|
||||
global $db;
|
||||
if(isset($name[0]) && isset($description[0]))
|
||||
@@ -814,7 +247,7 @@ class Forum
|
||||
$query = $query->fetch();
|
||||
$ordering = $query['ordering'] + 1;
|
||||
}
|
||||
$db->insert(TABLE_PREFIX . 'forum_boards', array('name' => $name, 'description' => $description, 'ordering' => $ordering));
|
||||
$db->insert(TABLE_PREFIX . 'forum_boards', array('name' => $name, 'description' => $description, 'access' => $access, 'guild' => $guild, 'ordering' => $ordering));
|
||||
}
|
||||
else
|
||||
$errors[] = 'Forum board with this name already exists.';
|
||||
@@ -830,9 +263,9 @@ class Forum
|
||||
return $db->select(TABLE_PREFIX . 'forum_boards', array('id' => $id));
|
||||
}
|
||||
|
||||
static public function update_board($id, $name, $description) {
|
||||
static public function update_board($id, $name, $access, $guild, $description) {
|
||||
global $db;
|
||||
$db->update(TABLE_PREFIX . 'forum_boards', array('name' => $name, 'description' => $description), array('id' => $id));
|
||||
$db->update(TABLE_PREFIX . 'forum_boards', array('name' => $name, 'description' => $description, 'access' => $access, 'guild' => $guild), array('id' => $id));
|
||||
}
|
||||
|
||||
static public function delete_board($id, &$errors)
|
||||
@@ -886,4 +319,132 @@ class Forum
|
||||
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
public static function parseSmiles($text)
|
||||
{
|
||||
$smileys = array(
|
||||
';D' => 1,
|
||||
':D' => 1,
|
||||
':cool:' => 2,
|
||||
';cool;' => 2,
|
||||
':ekk:' => 3,
|
||||
';ekk;' => 3,
|
||||
';o' => 4,
|
||||
';O' => 4,
|
||||
':o' => 4,
|
||||
':O' => 4,
|
||||
':(' => 5,
|
||||
';(' => 5,
|
||||
':mad:' => 6,
|
||||
';mad;' => 6,
|
||||
';rolleyes;' => 7,
|
||||
':rolleyes:' => 7,
|
||||
':)' => 8,
|
||||
';d' => 9,
|
||||
':d' => 9,
|
||||
';)' => 10
|
||||
);
|
||||
|
||||
foreach($smileys as $search => $replace)
|
||||
$text = str_replace($search, '<img src="images/forum/smile/'.$replace.'.gif" alt="'. $search .'" title="' . $search . '" />', $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
public static function parseBBCode($text, $smiles)
|
||||
{
|
||||
$rows = 0;
|
||||
while(stripos($text, '[code]') !== false && stripos($text, '[/code]') !== false )
|
||||
{
|
||||
$code = substr($text, stripos($text, '[code]')+6, stripos($text, '[/code]') - stripos($text, '[code]') - 6);
|
||||
if(!is_int($rows / 2)) { $bgcolor = 'ABED25'; } else { $bgcolor = '23ED25'; } $rows++;
|
||||
$text = str_ireplace('[code]'.$code.'[/code]', '<i>Code:</i><br /><table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #CCCCCC; border-width: 2px"><tr><td>'.$code.'</td></tr></table>', $text);
|
||||
}
|
||||
$rows = 0;
|
||||
while(stripos($text, '[quote]') !== false && stripos($text, '[/quote]') !== false )
|
||||
{
|
||||
$quote = substr($text, stripos($text, '[quote]')+7, stripos($text, '[/quote]') - stripos($text, '[quote]') - 7);
|
||||
if(!is_int($rows / 2)) { $bgcolor = 'AAAAAA'; } else { $bgcolor = 'CCCCCC'; } $rows++;
|
||||
$text = str_ireplace('[quote]'.$quote.'[/quote]', '<table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #007900; border-width: 2px"><tr><td>'.$quote.'</td></tr></table>', $text);
|
||||
}
|
||||
$rows = 0;
|
||||
while(stripos($text, '[url]') !== false && stripos($text, '[/url]') !== false )
|
||||
{
|
||||
$url = substr($text, stripos($text, '[url]')+5, stripos($text, '[/url]') - stripos($text, '[url]') - 5);
|
||||
$text = str_ireplace('[url]'.$url.'[/url]', '<a href="'.$url.'" target="_blank">'.$url.'</a>', $text);
|
||||
}
|
||||
|
||||
$xhtml = false;
|
||||
$tags = array(
|
||||
'#\[b\](.*?)\[/b\]#si' => ($xhtml ? '<strong>\\1</strong>' : '<b>\\1</b>'),
|
||||
'#\[i\](.*?)\[/i\]#si' => ($xhtml ? '<em>\\1</em>' : '<i>\\1</i>'),
|
||||
'#\[u\](.*?)\[/u\]#si' => ($xhtml ? '<span style="text-decoration: underline;">\\1</span>' : '<u>\\1</u>'),
|
||||
'#\[s\](.*?)\[/s\]#si' => ($xhtml ? '<strike>\\1</strike>' : '<s>\\1</s>'),
|
||||
|
||||
'#\[guild\](.*?)\[/guild\]#si' => urldecode(generateLink(getGuildLink('$1', false), '$1', true)),
|
||||
'#\[house\](.*?)\[/house\]#si' => urldecode(generateLink(getHouseLink('$1', false), '$1', true)),
|
||||
'#\[player\](.*?)\[/player\]#si' => urldecode(generateLink(getPlayerLink('$1', false), '$1', true)),
|
||||
// TODO: [poll] tag
|
||||
|
||||
'#\[color=(.*?)\](.*?)\[/color\]#si' => ($xhtml ? '<span style="color: \\1;">\\2</span>' : '<font color="\\1">\\2</font>'),
|
||||
'#\[img\](.*?)\[/img\]#si' => ($xhtml ? '<img src="\\1" border="0" alt="" />' : '<img src="\\1" border="0" alt="">'),
|
||||
'#\[url=(.*?)\](.*?)\[/url\]#si' => '<a href="\\1" title="\\2">\\2</a>',
|
||||
// '#\[email\](.*?)\[/email\]#si' => '<a href="mailto:\\1" title="Email \\1">\\1</a>',
|
||||
'#\[code\](.*?)\[/code\]#si' => '<code>\\1</code>',
|
||||
// '#\[align=(.*?)\](.*?)\[/align\]#si' => ($xhtml ? '<div style="text-align: \\1;">\\2</div>' : '<div align="\\1">\\2</div>'),
|
||||
// '#\[br\]#si' => ($xhtml ? '<br style="clear: both;" />' : '<br>'),
|
||||
);
|
||||
|
||||
foreach($tags as $search => $replace)
|
||||
$text = preg_replace($search, $replace, $text);
|
||||
|
||||
return ($smiles == 0 ? Forum::parseSmiles($text) : $text);
|
||||
}
|
||||
|
||||
public static function showPost($topic, $text, $smiles)
|
||||
{
|
||||
$text = nl2br($text);
|
||||
$post = '';
|
||||
if(!empty($topic))
|
||||
$post .= '<b>'.($smiles == 0 ? self::parseSmiles($topic) : $topic).'</b><hr />';
|
||||
$post .= self::parseBBCode($text, $smiles);
|
||||
return $post;
|
||||
}
|
||||
|
||||
public static function hasAccess($board_id) {
|
||||
global $sections, $logged, $account_logged, $logged_access;
|
||||
if(!isset($sections[$board_id]))
|
||||
return false;
|
||||
|
||||
$hasAccess = true;
|
||||
$section = $sections[$board_id];
|
||||
if($section['guild'] > 0) {
|
||||
if($logged) {
|
||||
$guild = new OTS_Guild();
|
||||
$guild->load($section['guild']);
|
||||
$status = false;
|
||||
if($guild->isLoaded()) {
|
||||
$account_players = $account_logged->getPlayers();
|
||||
foreach ($account_players as $player) {
|
||||
if($guild->hasMember($player)) {
|
||||
$status = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$status) $hasAccess = false;
|
||||
}
|
||||
else {
|
||||
$hasAccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
if($section['access'] > 0) {
|
||||
if($logged_access < $section['access']) {
|
||||
$hasAccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $hasAccess;
|
||||
}
|
||||
}
|
||||
|
113
system/pages/forum/edit_post.php
Normal file
113
system/pages/forum/edit_post.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Edit forum post
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(Forum::canPost($account_logged))
|
||||
{
|
||||
$post_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : false;
|
||||
if(!$post_id) {
|
||||
echo 'Please enter post id.';
|
||||
return;
|
||||
}
|
||||
|
||||
$thread = $db->query("SELECT `author_guid`, `author_aid`, `first_post`, `post_topic`, `post_date`, `post_text`, `post_smile`, `id`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post_id." LIMIT 1")->fetch();
|
||||
if(isset($thread['id']))
|
||||
{
|
||||
$first_post = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread['first_post']." LIMIT 1")->fetch();
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread['first_post']) . '">'.$first_post['post_topic'].'</a> >> <b>Edit post</b>';
|
||||
if(Forum::hasAccess($thread['section'] && ($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())))
|
||||
{
|
||||
$char_id = $post_topic = $text = $smile = null;
|
||||
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
|
||||
$saved = false;
|
||||
if(isset($_REQUEST['save']))
|
||||
{
|
||||
$text = stripslashes(trim($_REQUEST['text']));
|
||||
$char_id = (int) $_REQUEST['char_id'];
|
||||
$post_topic = stripslashes(trim($_REQUEST['topic']));
|
||||
$smile = (int) $_REQUEST['smile'];
|
||||
$lenght = 0;
|
||||
for($i = 0; $i <= strlen($post_topic); $i++)
|
||||
{
|
||||
if(ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
if(($lenght < 1 || strlen($post_topic) > 60) && $thread['id'] == $thread['first_post'])
|
||||
$errors[] = 'Too short or too long topic (short: '.$lenght.' long: '.strlen($post_topic).' letters). Minimum 1 letter, maximum 60 letters.';
|
||||
$lenght = 0;
|
||||
for($i = 0; $i <= strlen($text); $i++)
|
||||
{
|
||||
if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
|
||||
if($lenght < 1 || strlen($text) > 15000)
|
||||
$errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
|
||||
if($char_id == 0)
|
||||
$errors[] = 'Please select a character.';
|
||||
if(empty($post_topic) && $thread['id'] == $thread['first_post'])
|
||||
$errors[] = 'Thread topic can\'t be empty.';
|
||||
|
||||
$player_on_account == false;
|
||||
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
foreach($players_from_account as $player)
|
||||
if($char_id == $player['id'])
|
||||
$player_on_account = true;
|
||||
if(!$player_on_account)
|
||||
$errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
|
||||
}
|
||||
|
||||
if(count($errors) == 0) {
|
||||
$saved = true;
|
||||
if($account_logged->getId() != $thread['author_aid'])
|
||||
$char_id = $thread['author_guid'];
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $char_id.", `post_text` = ".$db->quote($text).", `post_topic` = ".$db->quote($post_topic).", `post_smile` = ".(int) $smile.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']);
|
||||
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".$thread['post_date']." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['first_post'])->fetch();
|
||||
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
|
||||
header('Location: ' . getForumThreadLink($thread['first_post'], $_page));
|
||||
echo '<br />Thank you for editing post.<br /><a href="' . getForumThreadLink($thread['first_post'], $_page) . '">GO BACK TO LAST THREAD</a>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$text = $thread['post_text'];
|
||||
$char_id = (int) $thread['author_guid'];
|
||||
$post_topic = $thread['post_topic'];
|
||||
$smile = (int) $thread['post_smile'];
|
||||
}
|
||||
|
||||
if(!$saved)
|
||||
{
|
||||
if(!empty($errors))
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
echo $twig->render('forum.edit_post.html.twig', array(
|
||||
'post_id' => $post_id,
|
||||
'players' => $players_from_account,
|
||||
'player_id' => $char_id,
|
||||
'topic' => htmlspecialchars($post_topic),
|
||||
'text' => htmlspecialchars($text),
|
||||
'smile' => $smile
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo '<br/>You are not an author of this post.';
|
||||
}
|
||||
else
|
||||
echo "<br/>Post with ID " . $post_id . " doesn't exist.";
|
||||
}
|
||||
else
|
||||
echo "<br/>Your account is banned, deleted or you don't have any player with level " . $config['forum_level_required'] . " on your account. You can't post.";
|
||||
|
||||
?>
|
65
system/pages/forum/move_thread.php
Normal file
65
system/pages/forum/move_thread.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Move forum thread (for moderator)
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(!Forum::isModerator()) {
|
||||
echo 'You are not logged in or you are not moderator.';
|
||||
}
|
||||
|
||||
$save = isset($_REQUEST['save']) ? (int)$_REQUEST['save'] == 1 : false;
|
||||
if($save) {
|
||||
$post_id = (int)$_REQUEST['id'];
|
||||
$board = (int)$_REQUEST['section'];
|
||||
if(!Forum::hasAccess($board)) {
|
||||
echo "You don't have access to this board.";
|
||||
return;
|
||||
}
|
||||
|
||||
$post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = " . $post_id . " LIMIT 1")->fetch();
|
||||
if ($post['id'] == $post_id) {
|
||||
if ($post['id'] == $post['first_post']) {
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `section` = " . $board . " WHERE `id` = " . $post['id'] . "");
|
||||
$nPost = $db->query('SELECT `section` FROM `' . TABLE_PREFIX . 'forum` WHERE `id` = \'' . $post_id . '\' LIMIT 1;')->fetch();
|
||||
header('Location: ' . getForumBoardLink($nPost['section']));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'Post with ID ' . $post_id . ' does not exist.';
|
||||
}
|
||||
else {
|
||||
$post_id = (int)$_REQUEST['id'];
|
||||
$post = $db->query("SELECT `id`, `section`, `first_post`, `post_topic`, `author_guid` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = " . $post_id . " LIMIT 1")->fetch();
|
||||
$name = $db->query("SELECT `name` FROM `players` WHERE `id` = " . $post['author_guid'] . " ")->fetch();
|
||||
|
||||
$sections_allowed = array();
|
||||
foreach($sections as $id => $section) {
|
||||
if(Forum::hasAccess($id)) {
|
||||
$sections_allowed[$id] = $section;
|
||||
}
|
||||
}
|
||||
|
||||
if ($post['id'] == $post_id) {
|
||||
if ($post['id'] == $post['first_post']) {
|
||||
echo $twig->render('forum.move_thread.html.twig', array(
|
||||
'thread' => $post['post_topic'],
|
||||
'author' => $name['name'],
|
||||
'board' => $sections[$post['section']]['name'],
|
||||
'post_id' => $post['id'],
|
||||
'sections' => $sections_allowed,
|
||||
'section_link' => getForumBoardLink($post['section']),
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'Post with ID ' . $post_id . ' does not exist.';
|
||||
}
|
||||
?>
|
114
system/pages/forum/new_post.php
Normal file
114
system/pages/forum/new_post.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* New forum post
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(Forum::canPost($account_logged))
|
||||
{
|
||||
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
|
||||
$thread_id = isset($_REQUEST['thread_id']) ? (int) $_REQUEST['thread_id'] : 0;
|
||||
if($thread_id == 0) {
|
||||
echo "Thread with this id doesn't exist.";
|
||||
return;
|
||||
}
|
||||
|
||||
$thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." LIMIT 1")->fetch();
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread_id) . '">'.$thread['post_topic'].'</a> >> <b>Post new reply</b><br /><h3>'.$thread['post_topic'].'</h3>';
|
||||
if(isset($thread['id']) && Forum::hasAccess($thread['section']))
|
||||
{
|
||||
$quote = isset($_REQUEST['quote']) ? (int) $_REQUEST['quote'] : NULL;
|
||||
$text = isset($_REQUEST['text']) ? stripslashes(trim($_REQUEST['text'])) : NULL;
|
||||
$char_id = (int) (isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
|
||||
$post_topic = isset($_REQUEST['topic']) ? stripslashes(trim($_REQUEST['topic'])) : '';
|
||||
$smile = (int) (isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
|
||||
$saved = false;
|
||||
if(isset($_REQUEST['quote']))
|
||||
{
|
||||
$quoted_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`id` = ".(int) $quote)->fetchAll();
|
||||
if(isset($quoted_post[0]['name']))
|
||||
$text = '[i]Originally posted by '.$quoted_post[0]['name'].' on '.date('d.m.y H:i:s', $quoted_post[0]['post_date']).':[/i][quote]'.$quoted_post[0]['post_text'].'[/quote]';
|
||||
}
|
||||
elseif(isset($_REQUEST['save']))
|
||||
{
|
||||
$lenght = 0;
|
||||
for($i = 0; $i < strlen($text); $i++)
|
||||
{
|
||||
if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
if($lenght < 1 || strlen($text) > 15000)
|
||||
$errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
|
||||
if($char_id == 0)
|
||||
$errors[] = 'Please select a character.';
|
||||
|
||||
$player_on_account = false;
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
foreach($players_from_account as $player)
|
||||
if($char_id == $player['id'])
|
||||
$player_on_account = true;
|
||||
if(!$player_on_account)
|
||||
$errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
|
||||
}
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
$last_post = 0;
|
||||
$query = $db->query('SELECT post_date FROM ' . TABLE_PREFIX . 'forum ORDER BY post_date DESC LIMIT 1');
|
||||
if($query->rowCount() > 0)
|
||||
{
|
||||
$query = $query->fetch();
|
||||
$last_post = $query['post_date'];
|
||||
}
|
||||
if($last_post+$config['forum_post_interval']-time() > 0 && !Forum::isModerator())
|
||||
$errors[] = 'You can post one time per '.$config['forum_post_interval'].' seconds. Next post after '.($last_post+$config['forum_post_interval']-time()).' second(s).';
|
||||
}
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
$saved = true;
|
||||
Forum::add_post($thread['id'], $thread['section'], $account_logged->getId(), (int) $char_id, $text, $post_topic, (int) $smile, time(), $_SERVER['REMOTE_ADDR']);
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `replies`=`replies`+1, `last_post`=".time()." WHERE `id` = ".(int) $thread_id);
|
||||
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".time()." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id'])->fetch();
|
||||
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
|
||||
header('Location: ' . getForumThreadLink($thread_id, $_page));
|
||||
echo '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id, $_page) . '">GO BACK TO LAST THREAD</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if(!$saved)
|
||||
{
|
||||
if(!empty($errors))
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
$threads = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_smile` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` DESC LIMIT 5")->fetchAll();
|
||||
|
||||
foreach($threads as &$thread) {
|
||||
$thread['post'] = Forum::showPost($thread['post_topic'], $thread['post_text'], $thread['post_smile']);
|
||||
}
|
||||
|
||||
echo $twig->render('forum.new_post.html.twig', array(
|
||||
'thread_id' => $thread_id,
|
||||
'post_player_id' => $char_id,
|
||||
'players' => $players_from_account,
|
||||
'post_topic' => $post_topic,
|
||||
'post_text' => $text,
|
||||
'post_smile' => $smile,
|
||||
'topic' => $thread['post_topic'],
|
||||
'threads' => $threads
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo "Thread with ID " . $thread_id . " doesn't exist.";
|
||||
}
|
||||
else
|
||||
echo "Your account is banned, deleted or you don't have any player with level " . $config['forum_level_required'] . " on your account. You can't post.";
|
||||
|
||||
?>
|
103
system/pages/forum/new_thread.php
Normal file
103
system/pages/forum/new_thread.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* New forum thread
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(Forum::canPost($account_logged))
|
||||
{
|
||||
$players_from_account = $db->query('SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = '.(int) $account_logged->getId())->fetchAll();
|
||||
$section_id = isset($_REQUEST['section_id']) ? $_REQUEST['section_id'] : null;
|
||||
if($section_id !== null) {
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($section_id) . '">' . $sections[$section_id]['name'] . '</a> >> <b>Post new thread</b><br />';
|
||||
if(isset($sections[$section_id]['name']) && Forum::hasAccess($section_id)) {
|
||||
if ($sections[$section_id]['closed'] && !Forum::isModerator())
|
||||
$errors[] = 'You cannot create topic on this board.';
|
||||
|
||||
$quote = (int)(isset($_REQUEST['quote']) ? $_REQUEST['quote'] : 0);
|
||||
$text = isset($_REQUEST['text']) ? stripslashes($_REQUEST['text']) : '';
|
||||
$char_id = (int)(isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
|
||||
$post_topic = isset($_REQUEST['topic']) ? stripslashes($_REQUEST['topic']) : '';
|
||||
$smile = (int)(isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
|
||||
$saved = false;
|
||||
if (isset($_REQUEST['save'])) {
|
||||
$errors = array();
|
||||
|
||||
$lenght = 0;
|
||||
for ($i = 0; $i < strlen($post_topic); $i++) {
|
||||
if (ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
if ($lenght < 1 || strlen($post_topic) > 60)
|
||||
$errors[] = 'Too short or too long topic (short: ' . $lenght . ' long: ' . strlen($post_topic) . ' letters). Minimum 1 letter, maximum 60 letters.';
|
||||
$lenght = 0;
|
||||
for ($i = 0; $i < strlen($text); $i++) {
|
||||
if (ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
if ($lenght < 1 || strlen($text) > 15000)
|
||||
$errors[] = 'Too short or too long post (short: ' . $lenght . ' long: ' . strlen($text) . ' letters). Minimum 1 letter, maximum 15000 letters.';
|
||||
|
||||
if ($char_id == 0)
|
||||
$errors[] = 'Please select a character.';
|
||||
$player_on_account = false;
|
||||
|
||||
if (count($errors) == 0) {
|
||||
foreach ($players_from_account as $player)
|
||||
if ($char_id == $player['id'])
|
||||
$player_on_account = true;
|
||||
if (!$player_on_account)
|
||||
$errors[] = 'Player with selected ID ' . $char_id . ' doesn\'t exist or isn\'t on your account';
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
$last_post = 0;
|
||||
$query = $db->query('SELECT `post_date` FROM `' . TABLE_PREFIX . 'forum` ORDER BY `post_date` DESC LIMIT 1');
|
||||
if ($query->rowCount() > 0) {
|
||||
$query = $query->fetch();
|
||||
$last_post = $query['post_date'];
|
||||
}
|
||||
if ($last_post + $config['forum_post_interval'] - time() > 0 && !Forum::isModerator())
|
||||
$errors[] = 'You can post one time per ' . $config['forum_post_interval'] . ' seconds. Next post after ' . ($last_post + $config['forum_post_interval'] - time()) . ' second(s).';
|
||||
}
|
||||
if (count($errors) == 0) {
|
||||
$saved = true;
|
||||
$db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
|
||||
$thread_id = $db->lastInsertId();
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=" . (int)$thread_id . " WHERE `id` = " . (int)$thread_id);
|
||||
header('Location: ' . getForumThreadLink($thread_id));
|
||||
echo '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id) . '">GO BACK TO LAST THREAD</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$saved) {
|
||||
if (!empty($errors))
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
echo $twig->render('forum.new_thread.html.twig', array(
|
||||
'section_id' => $section_id,
|
||||
'players' => $players_from_account,
|
||||
'post_player_id' => $char_id,
|
||||
'post_thread' => $post_topic,
|
||||
'text' => $text,
|
||||
'smiles_enabled' => $smile > 0
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'Board with ID ' . $board_id . ' doesn\'t exist.';
|
||||
}
|
||||
else
|
||||
echo 'Please enter section_id.';
|
||||
}
|
||||
else
|
||||
echo 'Your account is banned, deleted or you don\'t have any player with level '.$config['forum_level_required'].' on your account. You can\'t post.';
|
||||
|
||||
?>
|
37
system/pages/forum/remove_post.php
Normal file
37
system/pages/forum/remove_post.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Remove forum post
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(Forum::isModerator())
|
||||
{
|
||||
$id = (int) $_REQUEST['id'];
|
||||
$post = $db->query("SELECT `id`, `first_post`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$id." LIMIT 1")->fetch();
|
||||
if($post['id'] == $id && Forum::hasAccess($post['section']))
|
||||
{
|
||||
if($post['id'] == $post['first_post'])
|
||||
{
|
||||
$db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `first_post` = ".$post['id']);
|
||||
header('Location: ' . getForumBoardLink($post['section']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`id` < ".$id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $post['first_post'])->fetch();
|
||||
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
|
||||
$db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post['id']);
|
||||
header('Location: ' . getForumThreadLink($post['first_post'], (int) $_page));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'Post with ID ' . $id . ' does not exist.';
|
||||
}
|
||||
else
|
||||
echo 'You are not logged in or you are not moderator.';
|
88
system/pages/forum/show_board.php
Normal file
88
system/pages/forum/show_board.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Show forum board
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$links_to_pages = '';
|
||||
$section_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
|
||||
|
||||
if($section_id == null || !isset($sections[$section_id])) {
|
||||
echo "Board with this id does't exist.";
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Forum::hasAccess($section_id)) {
|
||||
echo "You don't have access to this board.";
|
||||
return;
|
||||
}
|
||||
|
||||
$_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
|
||||
$threads_count = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS threads_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`section` = ".(int) $section_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = `" . TABLE_PREFIX . "forum`.`id`")->fetch();
|
||||
for($i = 0; $i < $threads_count['threads_count'] / $config['forum_threads_per_page']; $i++)
|
||||
{
|
||||
if($i != $_page)
|
||||
$links_to_pages .= '<a href="' . getForumBoardLink($section_id, $i) . '">'.($i + 1).'</a> ';
|
||||
else
|
||||
$links_to_pages .= '<b>'.($i + 1).' </b>';
|
||||
}
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <b>'.$sections[$section_id]['name'].'</b>';
|
||||
if(!$sections[$section_id]['closed'] || Forum::isModerator())
|
||||
{
|
||||
echo '<br /><br />
|
||||
<a href="?subtopic=forum&action=new_thread§ion_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
}
|
||||
|
||||
echo '<br /><br />Page: '.$links_to_pages.'<br />';
|
||||
$last_threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`last_post`, `" . TABLE_PREFIX . "forum`.`replies`, `" . TABLE_PREFIX . "forum`.`views`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`section` = ".(int) $section_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = `" . TABLE_PREFIX . "forum`.`id` ORDER BY `" . TABLE_PREFIX . "forum`.`last_post` DESC LIMIT ".$config['forum_threads_per_page']." OFFSET ".($_page * $config['forum_threads_per_page']))->fetchAll();
|
||||
if(isset($last_threads[0]))
|
||||
{
|
||||
echo '<table width="100%"><tr bgcolor="'.$config['vdarkborder'].'" align="center"><td><font color="white" size="1"><b>Thread</b></font></td><td><font color="white" size="1"><b>Thread Starter</b></font></td><td><font color="white" size="1"><b>Replies</b></font></td><td><font color="white" size="1"><b>Views</b></font></td><td><font color="white" size="1"><b>Last Post</b></font></td></tr>';
|
||||
|
||||
$player = new OTS_Player();
|
||||
foreach($last_threads as $thread)
|
||||
{
|
||||
echo '<tr bgcolor="' . getStyle($number_of_rows++) . '"><td>';
|
||||
if(Forum::isModerator())
|
||||
{
|
||||
echo '<a href="?subtopic=forum&action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>';
|
||||
echo '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><font color="red">[REMOVE]</font></a> ';
|
||||
}
|
||||
|
||||
$player->load($thread['player_id']);
|
||||
if(!$player->isLoaded()) {
|
||||
error('Forum error: Player not loaded.');
|
||||
die();
|
||||
}
|
||||
|
||||
$player_account = $player->getAccount();
|
||||
$canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
|
||||
|
||||
echo '<a href="' . getForumThreadLink($thread['id']) . '">'.($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])) . '</a><br /><small>'.($canEditForum ? substr(strip_tags($thread['post_text']), 0, 50) : htmlspecialchars(substr($thread['post_text'], 0, 50))).'...</small></td><td>' . getPlayerLink($thread['name']) . '</td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';
|
||||
if($thread['last_post'] > 0)
|
||||
{
|
||||
$last_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id']." AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 1")->fetch();
|
||||
if(isset($last_post['name']))
|
||||
echo date('d.m.y H:i:s', $last_post['post_date']).'<br />by ' . getPlayerLink($last_post['name']);
|
||||
else
|
||||
echo 'No posts.';
|
||||
}
|
||||
else
|
||||
echo date('d.m.y H:i:s', $thread['post_date']).'<br />by ' . getPlayerLink($thread['name']);
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
if(!$sections[$section_id]['closed'] || Forum::isModerator())
|
||||
echo '<br /><a href="?subtopic=forum&action=new_thread§ion_id='.$section_id.'"><img src="images/forum/topic.gif" border="0" /></a>';
|
||||
}
|
||||
else
|
||||
echo '<h3>No threads in this board.</h3>';
|
||||
|
||||
?>
|
90
system/pages/forum/show_thread.php
Normal file
90
system/pages/forum/show_thread.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Show forum thread
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$links_to_pages = '';
|
||||
$thread_id = (int) $_REQUEST['id'];
|
||||
$_page = (int) (isset($_REQUEST['page']) ? $_REQUEST['page'] : 0);
|
||||
$thread_name = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`section` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`id` = `" . TABLE_PREFIX . "forum`.`first_post` AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` LIMIT 1")->fetch();
|
||||
|
||||
if(empty($thread_name['name'])) {
|
||||
echo 'Thread with this ID does not exits.';
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Forum::hasAccess($thread_name['section'])) {
|
||||
echo "You don't have access to view this thread.";
|
||||
return;
|
||||
}
|
||||
|
||||
$posts_count = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id)->fetch();
|
||||
for($i = 0; $i < $posts_count['posts_count'] / $config['forum_threads_per_page']; $i++)
|
||||
{
|
||||
if($i != $_page)
|
||||
$links_to_pages .= '<a href="' . getForumThreadLink($thread_id, $i) . '">'.($i + 1).'</a> ';
|
||||
else
|
||||
$links_to_pages .= '<b>'.($i + 1).' </b>';
|
||||
}
|
||||
$threads = $db->query("SELECT `players`.`id` as `player_id`, `players`.`name`, `players`.`account_id`, `players`.`vocation`" . (fieldExist('promotion', 'players') ? ", `players`.`promotion`" : "") . ", `players`.`level`, `" . TABLE_PREFIX . "forum`.`id`,`" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`section`,`" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`last_edit_aid`, `" . TABLE_PREFIX . "forum`.`edit_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." ORDER BY `" . TABLE_PREFIX . "forum`.`post_date` LIMIT ".$config['forum_posts_per_page']." OFFSET ".($_page * $config['forum_posts_per_page']))->fetchAll();
|
||||
if(isset($threads[0]['name']))
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($threads[0]['section']) . '">'.$sections[$threads[0]['section']]['name'].'</a> >> <b>'.$thread_name['post_topic'].'</b>';
|
||||
echo '<br /><br /><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"><img src="images/forum/post.gif" border="0" /></a><br /><br />Page: '.$links_to_pages.'<br /><table width="100%"><tr bgcolor="'.$config['lightborder'].'" width="100%"><td colspan="2"><font size="4"><b>'.htmlspecialchars($thread_name['post_topic']).'</b></font><font size="1"><br />by ' . getPlayerLink($thread_name['name']) . '</font></td></tr><tr bgcolor="'.$config['vdarkborder'].'"><td width="200"><font color="white" size="1"><b>Author</b></font></td><td> </td></tr>';
|
||||
$player = $ots->createObject('Player');
|
||||
foreach($threads as $thread)
|
||||
{
|
||||
$player->load($thread['player_id']);
|
||||
if(!$player->isLoaded()) {
|
||||
error('Forum error: Player not loaded.');
|
||||
die();
|
||||
}
|
||||
|
||||
echo '<tr bgcolor="' . getStyle($number_of_rows++) . '"><td valign="top">' . getPlayerLink($thread['name']) . '<br /><br /><font size="1">Profession: '.$config['vocations'][$player->getVocation()].'<br />Level: '.$thread['level'].'<br />';
|
||||
|
||||
$rank = $player->getRank();
|
||||
if($rank->isLoaded())
|
||||
{
|
||||
$guild = $rank->getGuild();
|
||||
if($guild->isLoaded())
|
||||
echo $rank->getName().' of <a href="'.getGuildLink($guild->getName(), false).'">'.$guild->getName().'</a><br />';
|
||||
}
|
||||
$player_account = $player->getAccount();
|
||||
$canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
|
||||
|
||||
$posts = $db->query("SELECT COUNT(`id`) AS 'posts' FROM `" . TABLE_PREFIX . "forum` WHERE `author_aid`=".(int) $thread['account_id'])->fetch();
|
||||
echo '<br />Posts: '.(int) $posts['posts'].'<br /></font></td><td valign="top">'.Forum::showPost(($canEditForum ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($canEditForum ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile']).'</td></tr>
|
||||
<tr bgcolor="'.getStyle($number_of_rows++).'"><td><font size="1">'.date('d.m.y H:i:s', $thread['post_date']);
|
||||
if($thread['edit_date'] > 0)
|
||||
{
|
||||
if($thread['last_edit_aid'] != $thread['author_aid'])
|
||||
echo '<br />Edited by moderator';
|
||||
else
|
||||
echo '<br />Edited by '.$thread['name'];
|
||||
echo '<br />on '.date('d.m.y H:i:s', $thread['edit_date']);
|
||||
}
|
||||
echo '</font></td><td>';
|
||||
if(Forum::isModerator())
|
||||
if($thread['first_post'] != $thread['id'])
|
||||
echo '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove post of '.$thread['name'].'?\')"><font color="red">REMOVE POST</font></a>';
|
||||
else
|
||||
{
|
||||
echo '<a href="?subtopic=forum&action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>';
|
||||
echo '<br/><a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><font color="red">REMOVE THREAD</font></a>';
|
||||
}
|
||||
if($logged && ($thread['account_id'] == $account_logged->getId() || Forum::isModerator()))
|
||||
echo '<br/><a href="?subtopic=forum&action=edit_post&id='.$thread['id'].'">EDIT POST</a>';
|
||||
if($logged)
|
||||
echo '<br/><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"e='.$thread['id'].'">Quote</a>';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
echo '</table><br /><a href="?subtopic=forum&action=new_post&thread_id='.$thread_id.'"><img src="images/forum/post.gif" border="0" /></a>';
|
||||
?>
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.0
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -56,14 +56,16 @@ if($canEdit) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
}
|
||||
|
||||
echo $twig->render('gallery.form.html.twig', array(
|
||||
'link' => getLink('gallery/' . ($action == 'edit' ? 'edit' : 'add')),
|
||||
'action' => $action,
|
||||
'id' => isset($id) ? $id : null,
|
||||
'comment' => isset($comment) ? $comment : null,
|
||||
'image' => isset($image) ? $image : null,
|
||||
'author' => isset($author) ? $author : null
|
||||
));
|
||||
if(!isset($_GET['image'])) {
|
||||
echo $twig->render('gallery.form.html.twig', array(
|
||||
'link' => getLink('gallery/' . ($action == 'edit' ? 'edit' : 'add')),
|
||||
'action' => $action,
|
||||
'id' => isset($id) ? $id : null,
|
||||
'comment' => isset($comment) ? $comment : null,
|
||||
'image' => isset($image) ? $image : null,
|
||||
'author' => isset($author) ? $author : null
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
echo 'You cannot edit/add gallery items as it seems your PHP installation doesnt have GD support enabled. Visit <a href="http://be2.php.net/manual/en/image.installation.php">PHP Manual</a> for more info.';
|
||||
|
File diff suppressed because it is too large
Load Diff
125
system/pages/guilds/accept_invite.php
Normal file
125
system/pages/guilds/accept_invite.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* Accept invite
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
//set rights in guild
|
||||
$guild_name = isset($_REQUEST['guild']) ? $_REQUEST['guild'] : NULL;
|
||||
$name = isset($_REQUEST['name']) ? stripslashes($_REQUEST['name']) : NULL;
|
||||
if(!$logged) {
|
||||
$errors[] = 'You are not logged in. You can\'t accept invitations.';
|
||||
}
|
||||
if(!Validator::guildName($guild_name)) {
|
||||
$errors[] = Validator::getLastError();
|
||||
}
|
||||
if(empty($errors)) {
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') {
|
||||
if(!Validator::characterName($name)) {
|
||||
$errors[] = 'Invalid name format.';
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$player = new OTS_Player();
|
||||
$player->find($name);
|
||||
if(!$player->isLoaded()) {
|
||||
$errors[] = 'Player with name <b>'.$name.'</b> doesn\'t exist.';
|
||||
}
|
||||
else
|
||||
{
|
||||
$rank_of_player = $player->getRank();
|
||||
if($rank_of_player->isLoaded()) {
|
||||
$errors[] = 'Character with name <b>'.$name.'</b> is already in guild. You must leave guild before you join other guild.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') {
|
||||
if(empty($errors)) {
|
||||
$is_invited = false;
|
||||
include(SYSTEM . 'libs/pot/InvitesDriver.php');
|
||||
new InvitesDriver($guild);
|
||||
$invited_list = $guild->listInvites();
|
||||
if(count($invited_list) > 0) {
|
||||
foreach($invited_list as $invited) {
|
||||
if($invited->getName() == $player->getName()) {
|
||||
$is_invited = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$is_invited) {
|
||||
$errors[] = 'Character '.$player->getName.' isn\'t invited to guild <b>'.$guild->getName().'</b>.';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(empty($errors)) {
|
||||
$acc_invited = false;
|
||||
$account_players = $account_logged->getPlayers();
|
||||
include(SYSTEM . 'libs/pot/InvitesDriver.php');
|
||||
new InvitesDriver($guild);
|
||||
$invited_list = $guild->listInvites();
|
||||
|
||||
if(count($invited_list) > 0) {
|
||||
foreach($invited_list as $invited) {
|
||||
foreach($account_players as $player_from_acc) {
|
||||
if($invited->getName() == $player_from_acc->getName()) {
|
||||
$acc_invited = true;
|
||||
$list_of_invited_players[] = $player_from_acc->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$acc_invited) {
|
||||
$errors[] = "Any character from your account isn't invited to <b>" . $guild->getName() . "</b>.";
|
||||
}
|
||||
}
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
echo $twig->render('guilds.back_button.html.twig', array(
|
||||
'action' => getLink('guilds') . '/' . $guild_name
|
||||
));
|
||||
}
|
||||
else {
|
||||
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') {
|
||||
$guild->acceptInvite($player);
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Accept invitation',
|
||||
'description' => 'Player with name <b>'.$player->getName().'</b> has been added to guild <b>'.$guild->getName() . '</b>.',
|
||||
'custom_buttons' => $twig->render('guilds.back_button.html.twig', array(
|
||||
'action' => getLink('guilds') . '/' . $guild_name
|
||||
))
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
sort($list_of_invited_players);
|
||||
|
||||
echo $twig->render('guilds.accept_invite.html.twig', array(
|
||||
'guild_name' => $guild_name,
|
||||
'invited_players' => $list_of_invited_players
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
77
system/pages/guilds/add_rank.php
Normal file
77
system/pages/guilds/add_rank.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Add rank
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$guild_name = $_REQUEST['guild'];
|
||||
$ranknew = $_REQUEST['rank_name'];
|
||||
if(!Validator::guildName($guild_name)) {
|
||||
$guild_errors[] = Validator::getLastError();
|
||||
}
|
||||
if(empty($guild_errors)) {
|
||||
if(!Validator::rankName($ranknew)) {
|
||||
$guild_errors[] = 'Invalid rank name format.';
|
||||
}
|
||||
if(!$logged) {
|
||||
$guild_errors[] = 'You are not logged.';
|
||||
}
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$guild_errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
}
|
||||
if(empty($guild_errors)) {
|
||||
$guild_leader_char = $guild->getOwner();
|
||||
$rank_list = $guild->getGuildRanksList();
|
||||
$rank_list->orderBy('level', POT::ORDER_DESC);
|
||||
$guild_leader = false;
|
||||
$account_players = $account_logged->getPlayers();
|
||||
foreach($account_players as $player) {
|
||||
if($guild_leader_char->getId() == $player->getId()) {
|
||||
$guild_vice = true;
|
||||
$guild_leader = true;
|
||||
$level_in_guild = 3;
|
||||
}
|
||||
}
|
||||
if($guild_leader) {
|
||||
$new_rank = new OTS_GuildRank();
|
||||
$new_rank->setGuild($guild);
|
||||
$new_rank->setLevel(1);
|
||||
$new_rank->setName($ranknew);
|
||||
$new_rank->save();
|
||||
header("Location: ?subtopic=guilds&guild=".$guild->getName()."&action=manager");
|
||||
echo 'New rank added. Redirecting...';
|
||||
}
|
||||
else {
|
||||
$guild_errors[] = 'You are not a leader of guild!';
|
||||
}
|
||||
}
|
||||
if(!empty($guild_errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $guild_errors));
|
||||
|
||||
echo $twig->render('guilds.back_button.html.twig', array(
|
||||
'new_line' => true,
|
||||
'action' => '?subtopic=guilds&guild='.$guild_name.'&action=show'
|
||||
));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!empty($guild_errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $guild_errors));
|
||||
|
||||
echo $twig->render('guilds.back_button.html.twig', array(
|
||||
'new_line' => true
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
76
system/pages/guilds/change_description.php
Normal file
76
system/pages/guilds/change_description.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Change guild description
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$guild_name = $_REQUEST['guild'];
|
||||
if(!Validator::guildName($guild_name)) {
|
||||
$errors[] = Validator::getLastError();
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$guild = $ots->createObject('Guild');
|
||||
$guild->find($guild_name);
|
||||
if(!$guild->isLoaded()) {
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
if($logged) {
|
||||
$guild_leader_char = $guild->getOwner();
|
||||
$rank_list = $guild->getGuildRanksList();
|
||||
$rank_list->orderBy('level', POT::ORDER_DESC);
|
||||
$guild_leader = false;
|
||||
$account_players = $account_logged->getPlayers();
|
||||
foreach($account_players as $player) {
|
||||
if($guild->getOwner()->getId() == $player->getId()) {
|
||||
$guild_vice = true;
|
||||
$guild_leader = true;
|
||||
$level_in_guild = 3;
|
||||
}
|
||||
}
|
||||
|
||||
$saved = false;
|
||||
if($guild_leader) {
|
||||
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') {
|
||||
$description = htmlspecialchars(stripslashes(substr(trim($_REQUEST['description']),0,$config['guild_description_chars_limit'])));
|
||||
$guild->setCustomField('description', $description);
|
||||
$saved = true;
|
||||
}
|
||||
|
||||
if($saved) {
|
||||
success('Changes has been saved');
|
||||
}
|
||||
|
||||
echo $twig->render('guilds.change_description.html.twig', array(
|
||||
'guild' => $guild,
|
||||
'rows' => bcsub($config['guild_description_lines_limit'],1)
|
||||
));
|
||||
}
|
||||
else {
|
||||
$errors[] = 'You are not a leader of guild!';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$errors[] = 'You are not logged. You can\'t manage guild.';
|
||||
}
|
||||
}
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
echo $twig->render('guilds.back_button.html.twig', array(
|
||||
'new_line' => true,
|
||||
'action' => '?subtopic=guilds'
|
||||
));
|
||||
}
|
||||
|
||||
?>
|
126
system/pages/guilds/change_logo.php
Normal file
126
system/pages/guilds/change_logo.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* Change guild logo
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.4
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$guild_name = $_REQUEST['guild'];
|
||||
if(!Validator::guildName($guild_name)) {
|
||||
$errors[] = Validator::getLastError();
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
$guild = new OTS_Guild();
|
||||
$guild->find($guild_name);
|
||||
|
||||
if(!$guild->isLoaded()) {
|
||||
$errors[] = 'Guild with name <b>'.$guild_name.'</b> doesn\'t exist.';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($errors)) {
|
||||
if($logged) {
|
||||
$guild_leader_char = $guild->getOwner();
|
||||
$guild_leader = false;
|
||||
$account_players = $account_logged->getPlayers();
|
||||
|
||||
foreach($account_players as $player) {
|
||||
if($guild_leader_char->getId() == $player->getId()) {
|
||||
$guild_vice = true;
|
||||
$guild_leader = true;
|
||||
$level_in_guild = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if($guild_leader)
|
||||
{
|
||||
$max_image_size_b = $config['guild_image_size_kb'] * 1024;
|
||||
$allowed_ext = array('image/gif', 'image/jpg', 'image/pjpeg', 'image/jpeg', 'image/bmp', 'image/png', 'image/x-png');
|
||||
$ext_name = array('image/gif' => 'gif', 'image/jpg' => 'jpg', 'image/jpeg' => 'jpg', 'image/pjpeg' => 'jpg', 'image/bmp' => 'bmp', 'image/png' => 'png', 'image/x-png' => 'png');
|
||||
$save_file_name = str_replace(' ', '_', strtolower($guild->getName()));
|
||||
$save_path = 'images/guilds/' . $save_file_name;
|
||||
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save')
|
||||
{
|
||||
$file = $_FILES['newlogo'];
|
||||
if(is_uploaded_file($file['tmp_name']))
|
||||
{
|
||||
if($file['size'] > $max_image_size_b) {
|
||||
$upload_errors[] = 'Uploaded image is too big. Size: <b>'.$file['size'].' bytes</b>, Max. size: <b>'.$max_image_size_b.' bytes</b>.';
|
||||
}
|
||||
|
||||
$type = strtolower($file['type']);
|
||||
if(!in_array($type, $allowed_ext)) {
|
||||
$upload_errors[] = 'Your file type isn\' allowed. Allowed: <b>gif, jpg, bmp, png</b>. Your file type: <b>'.$type.'</b> If it\'s valid image contact with admin.';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$upload_errors[] = 'You didn\'t send file or file is too big. Limit: <b>'.$config['guild_image_size_kb'].' KB</b>.';
|
||||
}
|
||||
|
||||
if(empty($upload_errors)) {
|
||||
$extension = $ext_name[$type];
|
||||
if(!move_uploaded_file($file['tmp_name'], $save_path.'.'.$extension)) {
|
||||
$upload_errors[] = "Sorry! Can't save your image.";
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($upload_errors))
|
||||
{
|
||||
$guild_logo = $guild->getCustomField('logo_name');
|
||||
$guild_logo = str_replace(array('..', '/', '\\'), array('','',''), $guild->getCustomField('logo_name'));
|
||||
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo)) {
|
||||
$guild_logo = "default.gif";
|
||||
}
|
||||
|
||||
if($guild_logo != "default.gif" && $guild_logo != $save_file_name.'.'.$extension) {
|
||||
unlink('images/guilds/' . $guild_logo);
|
||||
}
|
||||
}
|
||||
|
||||
//show errors or save file
|
||||
if(!empty($upload_errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $upload_errors));
|
||||
}
|
||||
else {
|
||||
success('Logo has been changed.');
|
||||
$guild->setCustomField('logo_name', $save_file_name.'.'.$extension);
|
||||
}
|
||||
}
|
||||
|
||||
$guild_logo = $guild->getCustomField('logo_name');
|
||||
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo)) {
|
||||
$guild_logo = "default.gif";
|
||||
}
|
||||
|
||||
echo $twig->render('guilds.change_logo.html.twig', array(
|
||||
'guild_logo' => $guild_logo,
|
||||
'guild' => $guild,
|
||||
'max_image_size_b' => $max_image_size_b
|
||||
));
|
||||
|
||||
}
|
||||
else {
|
||||
$errors[] = 'You are not a leader of guild!';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$errors[] = 'You are not logged. You can\'t manage guild.';
|
||||
}
|
||||
}
|
||||
if(!empty($errors)) {
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
echo $twig->render('guilds.back_button.html.twig', array(
|
||||
'new_line' => true,
|
||||
'action' => '?subtopic=guilds'
|
||||
));
|
||||
}
|
||||
?>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user