mirror of
https://github.com/slawkens/myaac.git
synced 2025-09-14 04:23:34 +02:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1610a4ab91 | ||
![]() |
87a3d1e5d1 | ||
![]() |
2b6d65e955 | ||
![]() |
cd44d28674 | ||
![]() |
2edeb1b3e2 | ||
![]() |
9f946d4bc4 | ||
![]() |
5266f33af5 | ||
![]() |
85c9a1e84d | ||
![]() |
5951fe21ec | ||
![]() |
c6b6638705 | ||
![]() |
8ab7be9fb8 | ||
![]() |
762fa31c28 | ||
![]() |
c2678aa91f | ||
![]() |
d4900eac84 | ||
![]() |
f9b6e9fa2e | ||
![]() |
cfb460c137 | ||
![]() |
f9e6966687 | ||
![]() |
913b4297cf | ||
![]() |
23c1df72aa | ||
![]() |
cde42ec3fa | ||
![]() |
0104d2fd36 | ||
![]() |
85d1f3419a | ||
![]() |
e45d27b5c7 | ||
![]() |
a3d94db6eb | ||
![]() |
ef904c854b | ||
![]() |
7a7eb4e553 | ||
![]() |
c7f549742d | ||
![]() |
1850ef70d8 |
50
CHANGELOG
50
CHANGELOG
@@ -1,3 +1,53 @@
|
||||
[0.6.6 - 22.10.2017]
|
||||
- fixed some php fatal error on spells page
|
||||
- changed spells.vocations field in db size to 300
|
||||
- please reload your spells after this update!
|
||||
|
||||
[0.6.5 - 21.10.2017]
|
||||
- fixed displaying custom pages
|
||||
- fixed adding new group forum board
|
||||
|
||||
[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!)
|
||||
|
@@ -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'
|
||||
),
|
||||
|
23
common.php
23
common.php
@@ -21,14 +21,14 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
session_start();
|
||||
|
||||
define('MYAAC', true);
|
||||
define('MYAAC_VERSION', '0.6.1');
|
||||
define('DATABASE_VERSION', 11);
|
||||
define('MYAAC_VERSION', '0.6.6');
|
||||
define('DATABASE_VERSION', 16);
|
||||
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'));
|
||||
@@ -86,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']);
|
||||
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']);
|
||||
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.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
|
||||
|
29
index.php
29
index.php
@@ -21,7 +21,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
@@ -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(TOOLS . 'signature/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);
|
||||
@@ -275,7 +276,7 @@ if($load_it)
|
||||
|
||||
$ignore = false;
|
||||
|
||||
$logged_access = 0;
|
||||
$logged_access = 1;
|
||||
if($logged && $account_logged && $account_logged->isLoaded()) {
|
||||
$logged_access = $account_logged->getAccess();
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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();
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,21 +5,21 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -33,6 +33,12 @@ class Creatures {
|
||||
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
|
||||
@@ -44,10 +50,10 @@ class Creatures {
|
||||
}
|
||||
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
|
||||
@@ -67,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(self::$monstersList->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) {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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;
|
||||
global $config, $db;
|
||||
|
||||
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;
|
||||
}
|
||||
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');
|
||||
public static function getError() {
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
self::$otb = fopen(self::$files['otb'], 'rb');
|
||||
self::$dat = fopen(self::$files['dat'], 'rb');
|
||||
self::$spr = fopen(self::$files['spr'], 'rb');
|
||||
public static function getItem($id) {
|
||||
global $db;
|
||||
|
||||
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 ) ) );
|
||||
$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;
|
||||
}
|
||||
|
||||
public static function loaded() {
|
||||
return self::$loaded;
|
||||
return $s;
|
||||
}
|
||||
}
|
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.6
|
||||
* @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.6
|
||||
* @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,6 +334,9 @@ 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;
|
||||
|
||||
@@ -341,7 +344,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
//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']) )
|
||||
{
|
||||
@@ -355,6 +358,9 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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.
|
||||
*
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -25,10 +25,6 @@ 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');
|
||||
}
|
||||
@@ -36,6 +32,7 @@ class Spells {
|
||||
self::$lastError = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
//add conjure spells
|
||||
$conjurelist = self::$spellsList->getConjuresList();
|
||||
if($show) {
|
||||
@@ -44,49 +41,29 @@ class Spells {
|
||||
|
||||
foreach($conjurelist as $spellname) {
|
||||
$spell = self::$spellsList->getConjure($spellname);
|
||||
$lvl = $spell->getLevel();
|
||||
$mlvl = $spell->getMagicLevel();
|
||||
$mana = $spell->getMana();
|
||||
$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 .= ',';
|
||||
}
|
||||
}
|
||||
$words = $spell->getWords();
|
||||
if(strpos($words, '#') !== false)
|
||||
continue;
|
||||
|
||||
$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();
|
||||
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) {
|
||||
@@ -96,7 +73,7 @@ class Spells {
|
||||
}
|
||||
}
|
||||
|
||||
//add instant spells
|
||||
// add instant spells
|
||||
$instantlist = self::$spellsList->getInstantsList();
|
||||
if($show) {
|
||||
echo "<h3>Instant:</h3>";
|
||||
@@ -104,51 +81,67 @@ class Spells {
|
||||
|
||||
foreach($instantlist as $spellname) {
|
||||
$spell = self::$spellsList->getInstant($spellname);
|
||||
$lvl = $spell->getLevel();
|
||||
$mlvl = $spell->getMagicLevel();
|
||||
$mana = $spell->getMana();
|
||||
$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) {
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,33 +5,31 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @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';
|
||||
private static $report_url = 'http://my-aac.org/report_usage.php';
|
||||
|
||||
public static function report() {
|
||||
$data = json_encode(self::getStats());
|
||||
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => 'Content-type: application/json',
|
||||
'header' => 'Content-type: application/json' . "\r\n"
|
||||
. 'Content-Length: ' . strlen($data) . "\r\n",
|
||||
'method' => 'POST',
|
||||
'content' => $data
|
||||
)
|
||||
);
|
||||
|
||||
$context = stream_context_create($options);
|
||||
$result = file_get_contents($url, false, $context);
|
||||
if ($result === false) {
|
||||
return false;
|
||||
}
|
||||
$result = file_get_contents(self::$report_url, false, $context);
|
||||
|
||||
return true;
|
||||
//var_dump($result);
|
||||
return $result !== false;
|
||||
}
|
||||
|
||||
public static function getStats() {
|
||||
@@ -97,7 +95,16 @@ WHERE TABLE_SCHEMA = "forgottenserver";');
|
||||
}
|
||||
|
||||
$ret['locales'] = get_locales();
|
||||
$ret['plugins'] = get_plugins();
|
||||
$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'];
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.6
|
||||
* @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;
|
||||
}
|
||||
}
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
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
system/migrations/16.php
Normal file
5
system/migrations/16.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
// change size of spells.vocations
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "spells` MODIFY `vocations` VARCHAR(300) NOT NULL DEFAULT '';");
|
||||
?>
|
@@ -5,7 +5,7 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -87,19 +87,18 @@ else
|
||||
<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/buttons/sbutton_iagree.gif" BORDER=0 WIDTH=120 HEIGHT=17>
|
||||
<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 >
|
||||
<input type=image name="Cancel" src="' . $template_path . '/images/buttons/sbutton_cancel.gif" BORDER=0 WIDTH=120 HEIGHT=17>
|
||||
' . $twig->render('buttons.cancel.html.twig') . '
|
||||
</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>
|
||||
' . $twig->render('buttons.back.html.twig') . '
|
||||
</form>
|
||||
</td>
|
||||
<td width="30"> </td>
|
||||
@@ -123,8 +122,7 @@ else
|
||||
<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>
|
||||
' . $twig->render('buttons.cancel.html.twig') . '
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
@@ -135,8 +133,7 @@ else
|
||||
<form action="' . getLink('account/manage') . '" 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>
|
||||
' . $twig->render('buttons.back.html.twig') . '
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
@@ -155,7 +152,7 @@ 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>';
|
||||
$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',
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,68 +6,30 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @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';
|
||||
if(Creatures::loadFromXML(true))
|
||||
if(Creatures::getMonstersList()->hasErrors())
|
||||
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());
|
||||
}
|
||||
@@ -114,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>';
|
||||
@@ -173,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";
|
||||
@@ -209,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))
|
||||
@@ -222,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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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.1
|
||||
* @version 0.6.6
|
||||
* @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(
|
||||
@@ -280,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]))
|
||||
@@ -301,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.';
|
||||
@@ -317,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)
|
||||
@@ -373,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;
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -19,12 +19,12 @@ if(Forum::canPost($account_logged))
|
||||
return;
|
||||
}
|
||||
|
||||
$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` = ".$post_id." LIMIT 1")->fetch();
|
||||
$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($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())
|
||||
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();
|
||||
@@ -105,9 +105,9 @@ if(Forum::canPost($account_logged))
|
||||
echo '<br/>You are not an author of this post.';
|
||||
}
|
||||
else
|
||||
echo '<br/>Post with ID '.$post_id.' doesn\'t exist.';
|
||||
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.';
|
||||
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.";
|
||||
|
||||
?>
|
@@ -6,47 +6,60 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @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) {
|
||||
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.';
|
||||
$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 {
|
||||
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.';
|
||||
$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.';
|
||||
}
|
||||
?>
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -14,10 +14,15 @@ 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 = (int) $_REQUEST['thread_id'];
|
||||
$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']))
|
||||
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;
|
||||
@@ -43,6 +48,7 @@ if(Forum::canPost($account_logged))
|
||||
$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)
|
||||
{
|
||||
@@ -67,7 +73,7 @@ if(Forum::canPost($account_logged))
|
||||
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']."')");
|
||||
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;
|
||||
@@ -75,49 +81,32 @@ if(Forum::canPost($account_logged))
|
||||
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>';
|
||||
$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 '</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>';
|
||||
|
||||
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.';
|
||||
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.";
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -17,7 +17,7 @@ if(Forum::canPost($account_logged))
|
||||
$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(isset($sections[$section_id]['name']) && Forum::hasAccess($section_id)) {
|
||||
if ($sections[$section_id]['closed'] && !Forum::isModerator())
|
||||
$errors[] = 'You cannot create topic on this board.';
|
||||
|
||||
@@ -76,6 +76,7 @@ if(Forum::canPost($account_logged))
|
||||
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));
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -15,7 +15,7 @@ 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'] == $id && Forum::hasAccess($post['section']))
|
||||
{
|
||||
if($post['id'] == $post['first_post'])
|
||||
{
|
||||
|
@@ -6,13 +6,24 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$links_to_pages = '';
|
||||
$section_id = (int) $_REQUEST['id'];
|
||||
$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++)
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.1
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -14,72 +14,77 @@ 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` 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();
|
||||
}
|
||||
$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();
|
||||
|
||||
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
|
||||
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.1
|
||||
* @version 0.6.6
|
||||
* @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.6
|
||||
* @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.6
|
||||
* @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.6
|
||||
* @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.6
|
||||
* @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'
|
||||
));
|
||||
}
|
||||
?>
|
78
system/pages/guilds/change_motd.php
Normal file
78
system/pages/guilds/change_motd.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Change motd
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(!MOTD_EXISTS)
|
||||
return;
|
||||
|
||||
$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();
|
||||
$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') {
|
||||
$motd = htmlspecialchars(stripslashes(substr($_REQUEST['motd'],0, $config['guild_motd_chars_limit'])));
|
||||
$guild->setCustomField('motd', $motd);
|
||||
$saved = true;
|
||||
}
|
||||
|
||||
if($saved) {
|
||||
success('Changes has been saved');
|
||||
}
|
||||
|
||||
echo $twig->render('guilds.change_motd.html.twig', array(
|
||||
'guild' => $guild
|
||||
));
|
||||
}
|
||||
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'
|
||||
));
|
||||
}
|
||||
|
||||
?>
|
55
system/pages/guilds/change_nick.php
Normal file
55
system/pages/guilds/change_nick.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Change nick
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.6
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if($logged)
|
||||
{
|
||||
$name = stripslashes($_REQUEST['name']);
|
||||
$new_nick = stripslashes($_REQUEST['nick']);
|
||||
$player = new OTS_Player();
|
||||
$player->find($name);
|
||||
$player_from_account = false;
|
||||
if(strlen($new_nick) <= 40)
|
||||
{
|
||||
if($player->isLoaded())
|
||||
{
|
||||
$account_players = $account_logged->getPlayersList();
|
||||
if(count($account_players))
|
||||
{
|
||||
foreach($account_players as $acc_player)
|
||||
{
|
||||
if($acc_player->getId() == $player->getId())
|
||||
$player_from_account = true;
|
||||
}
|
||||
if($player_from_account)
|
||||
{
|
||||
$player->setGuildNick($new_nick);
|
||||
echo 'Guild nick of player <b>'.$player->getName().'</b> changed to <b>'.htmlentities($new_nick).'</b>.';
|
||||
$addtolink = '&action=show&guild='.$player->getRank()->getGuild()->getName();
|
||||
}
|
||||
else
|
||||
echo 'This player is not from your account.';
|
||||
}
|
||||
else
|
||||
echo 'This player is not from your account.';
|
||||
}
|
||||
else
|
||||
echo 'Unknow error occured.';
|
||||
}
|
||||
else
|
||||
echo 'Too long guild nick. Max. 40 chars, your length: '.strlen($new_nick);
|
||||
}
|
||||
else
|
||||
echo 'You are not logged.';
|
||||
echo '<center><h3><a href="?subtopic=guilds'.$addtolink.'">BACK</a></h3></center>';
|
||||
|
||||
?>
|
204
system/pages/guilds/change_rank.php
Normal file
204
system/pages/guilds/change_rank.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/**
|
||||
* Change rank
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.6.6
|
||||
* @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(!$logged)
|
||||
$errors[] = 'You are not logged in. You can\'t change rank.';
|
||||
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))
|
||||
{
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
echo $twig->render('guilds.back_button.html.twig');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//check is it vice or/and leader account (leader has vice + leader rights)
|
||||
$rank_list = $guild->getGuildRanksList();
|
||||
$rank_list->orderBy('level', POT::ORDER_DESC);
|
||||
$guild_leader = false;
|
||||
$guild_vice = false;
|
||||
$account_players = $account_logged->getPlayers();
|
||||
foreach($account_players as $player)
|
||||
{
|
||||
$player_rank = $player->getRank();
|
||||
if($player_rank->isLoaded()) {
|
||||
foreach($rank_list as $rank_in_guild)
|
||||
{
|
||||
if($rank_in_guild->getId() == $player_rank->getId())
|
||||
{
|
||||
$players_from_account_in_guild[] = $player->getName();
|
||||
if($player_rank->getLevel() > 1) {
|
||||
$guild_vice = true;
|
||||
$level_in_guild = $player_rank->getLevel();
|
||||
}
|
||||
if($guild->getOwner()->getId() == $player->getId()) {
|
||||
$guild_vice = true;
|
||||
$guild_leader = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($guild_vice)
|
||||
{
|
||||
$rid = 0;
|
||||
$sid = 0;
|
||||
foreach($rank_list as $rank)
|
||||
{
|
||||
if($guild_leader || $rank->getLevel() < $level_in_guild)
|
||||
{
|
||||
$ranks[$rid]['0'] = $rank->getId();
|
||||
$ranks[$rid]['1'] = $rank->getName();
|
||||
$rid++;
|
||||
|
||||
if(fieldExist('rank_id', 'players'))
|
||||
$players_with_rank = $db->query('SELECT `id`, `rank_id` FROM `players` WHERE `rank_id` = ' . $rank->getId() . ' AND `deleted` = 0;');
|
||||
else
|
||||
$players_with_rank = $db->query('SELECT `players`.`id` as `id`, `' . GUILD_MEMBERS_TABLE . '`.`rank_id` as `rank_id` FROM `players`, `' . GUILD_MEMBERS_TABLE . '` WHERE `' . GUILD_MEMBERS_TABLE . '`.`rank_id` = ' . $rank->getId() . ' AND `players`.`id` = `' . GUILD_MEMBERS_TABLE . '`.`player_id` ORDER BY `name`;');
|
||||
|
||||
$players_with_rank_number = $players_with_rank->rowCount();
|
||||
if(count($players_with_rank) > 0)
|
||||
{
|
||||
|
||||
foreach($players_with_rank as $result)
|
||||
{
|
||||
$player = new OTS_Player();
|
||||
$player->load($result['id']);
|
||||
if(!$player->isLoaded())
|
||||
continue;
|
||||
|
||||
if($guild->getOwner()->getId() != $player->getId() || $guild_leader)
|
||||
{
|
||||
$players_with_lower_rank[$sid][0] = $player->getName();
|
||||
$players_with_lower_rank[$sid][1] = $player->getName().' ('.$rank->getName().')';
|
||||
$sid++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save')
|
||||
{
|
||||
$player_name = stripslashes($_REQUEST['name']);
|
||||
$new_rank = (int) $_REQUEST['rankid'];
|
||||
if(!Validator::characterName($player_name))
|
||||
$change_errors[] = 'Invalid player name format.';
|
||||
$rank = $ots->createObject('GuildRank');
|
||||
$rank->load($new_rank);
|
||||
if(!$rank->isLoaded())
|
||||
$change_errors[] = 'Rank with this ID doesn\'t exist.';
|
||||
if($level_in_guild <= $rank->getLevel() && !$guild_leader)
|
||||
$change_errors[] = 'You can\'t set ranks with equal or higher level than your.';
|
||||
if(empty($change_errors))
|
||||
{
|
||||
$player_to_change = $ots->createObject('Player');
|
||||
$player_to_change->find($player_name);
|
||||
if(!$player_to_change->isLoaded())
|
||||
$change_errors[] = 'Player with name '.$player_name.'</b> doesn\'t exist.';
|
||||
else
|
||||
{
|
||||
$player_in_guild = false;
|
||||
if($guild->getName() == $player_to_change->getRank()->getGuild()->getName() || $guild_leader)
|
||||
{
|
||||
$player_in_guild = true;
|
||||
$player_has_lower_rank = false;
|
||||
if($player_to_change->getRank()->getLevel() < $level_in_guild || $guild_leader)
|
||||
$player_has_lower_rank = true;
|
||||
}
|
||||
}
|
||||
$rank_in_guild = false;
|
||||
foreach($rank_list as $rank_from_guild)
|
||||
if($rank_from_guild->getId() == $rank->getId())
|
||||
$rank_in_guild = true;
|
||||
if(!$player_in_guild)
|
||||
$change_errors[] = 'This player isn\'t in your guild.';
|
||||
if(!$rank_in_guild)
|
||||
$change_errors[] = 'This rank isn\'t in your guild.';
|
||||
if(!$player_has_lower_rank)
|
||||
$change_errors[] = 'This player has higher rank in guild than you. You can\'t change his/her rank.';
|
||||
}
|
||||
if(empty($change_errors))
|
||||
{
|
||||
$player_to_change->setRank($rank);
|
||||
echo $twig->render('success.html.twig', array(
|
||||
'title' => 'Rank Changed',
|
||||
'description' => 'Rank of player <b>'.$player_to_change->getName().'</b> has been changed to <b>'.$rank->getName().'</b>.',
|
||||
'custom_buttons' => ''
|
||||
));
|
||||
|
||||
unset($players_with_lower_rank);
|
||||
unset($ranks);
|
||||
$rid = 0;
|
||||
$sid= 0;
|
||||
foreach($rank_list as $rank)
|
||||
{
|
||||
if($guild_leader || $rank->getLevel() < $level_in_guild)
|
||||
{
|
||||
$ranks[$rid]['0'] = $rank->getId();
|
||||
$ranks[$rid]['1'] = $rank->getName();
|
||||
$rid++;
|
||||
|
||||
if(fieldExist('rank_id', 'players'))
|
||||
$players_with_rank = $db->query('SELECT `id`, `rank_id` FROM `players` WHERE `rank_id` = ' . $rank->getId() . ' AND `deleted` = 0;');
|
||||
else
|
||||
$players_with_rank = $db->query('SELECT `players`.`id` as `id`, `' . GUILD_MEMBERS_TABLE . '`.`rank_id` as `rank_id` FROM `players`, `' . GUILD_MEMBERS_TABLE . '` WHERE `' . GUILD_MEMBERS_TABLE . '`.`rank_id` = ' . $rank->getId() . ' AND `players`.`id` = `' . GUILD_MEMBERS_TABLE . '`.`player_id` ORDER BY `name`;');
|
||||
|
||||
$players_with_rank_number = $players_with_rank->rowCount();
|
||||
if(count($players_with_rank) > 0)
|
||||
{
|
||||
foreach($players_with_rank as $result)
|
||||
{
|
||||
$player = $ots->createObject('Player');
|
||||
$player->load($result['id']);
|
||||
if(!$player->isLoaded())
|
||||
continue;
|
||||
|
||||
if($guild->getOwner()->getId() != $player->getId() || $guild_leader)
|
||||
{
|
||||
$players_with_lower_rank[$sid][0] = $player->getName();
|
||||
$players_with_lower_rank[$sid][1] = $player->getName().' ('.$rank->getName().')';
|
||||
$sid++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $change_errors));
|
||||
}
|
||||
}
|
||||
echo $twig->render('guilds.change_rank.html.twig', array(
|
||||
'players' => $players_with_lower_rank,
|
||||
'guild_name' => $guild->getName(),
|
||||
'ranks' => $ranks
|
||||
));
|
||||
}
|
||||
else {
|
||||
echo 'Error. You are not a leader or vice leader in guild ' . $guild->getName();
|
||||
echo $twig->render('guilds.back_button.html.twig', array(
|
||||
'new_line' => true,
|
||||
'action' => getLink('guilds') . '/' . $guild->getName()
|
||||
));
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user