Version v0.0.2

* updated forum links to use friendly_urls
* some more info will be shown when cannot connect to database
* show more error infos when creating character
* fixed forum link on newses
* fixed spells loading when there's vocation name instead of id
* fixed bug when you have changed template but it doesn't exist anymore
* fixed vocations with promotion loading
* fixed support for gesior pages and templates
* added function OTS_Acount:getGroupId()
This commit is contained in:
slawkens1
2017-05-02 18:05:29 +02:00
parent cd25eebdcb
commit e808904f76
16 changed files with 244 additions and 171 deletions

View File

@@ -45,6 +45,32 @@ function getPageLink($page, $action = null)
}
function internalLayoutLink($page, $action = null) {return getPageLink($page, $action);}
function getForumThreadLink($thread_id, $page = NULL)
{
global $config;
$url = '';
if($config['friendly_urls'])
$url = BASE_URL . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : '');
else
$url = BASE_URL . '?subtopic=forum&action=show_thread&id=' . (int)$thread_id . (isset($page) ? '&page=' . $page : '');
return $url;
}
function getForumBoardLink($board_id, $page = NULL)
{
global $config;
$url = '';
if($config['friendly_urls'])
$url = BASE_URL . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
else
$url = BASE_URL . '?subtopic=forum&action=show_board&id=' . (int)$board_id . (isset($page) ? '&page=' . $page : '');
return $url;
}
function getPlayerLink($name, $generate = true)
{
global $ots, $config;
@@ -455,7 +481,7 @@ function check_account_name($name, &$error = '')
}
//is it valid nick for new char?
function check_name_new_char($name)
function check_name_new_char($name, &$error = '')
{
global $db, $config;
@@ -464,92 +490,127 @@ function check_name_new_char($name)
$first_words_blocked = array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ', "'", '-');
foreach($first_words_blocked as $word)
{
if($word == substr($name_lower, 0, strlen($word)))
if($word == substr($name_lower, 0, strlen($word))) {
$error = 'Your name contains blocked words.';
return false;
}
}
if(substr($name_lower, -1) == "'" || substr($name_lower, -1) == "-")
if(substr($name_lower, -1) == "'" || substr($name_lower, -1) == "-") {
$error = 'Your name contains illegal characters.';
return false;
}
if(substr($name_lower, 1, 1) == ' ')
if(substr($name_lower, 1, 1) == ' ') {
$error = 'Your name contains illegal space.';
return false;
}
if(substr($name_lower, -2, 1) == " ")
if(substr($name_lower, -2, 1) == " ") {
$error = 'Your name contains illegal space.';
return false;
}
if(strtolower($config['lua']['serverName']) == $name_lower)
if(strtolower($config['lua']['serverName']) == $name_lower) {
$error = 'Your name cannot be same as server name.';
return false;
}
$names_blocked = array('admin', 'administrator', 'gm', 'cm', 'god', 'tutor');
foreach($names_blocked as $word)
{
if($word == $name_lower)
return false;
}
$name_length = strlen($name_lower);
for($i = 0; $i < $name_length; $i++)
{
if(isset($name_lower[$i - 1]) && $name_lower[$i - 1] == ' ' && isset($name_lower[$i + 1]) && $name_lower[$i + 1] == ' ')
if($word == $name_lower) {
$error = 'Your name contains blocked words.';
return false;
}
}
$words_blocked = array('admin', 'administrator', 'gamemaster', 'game master', 'game-master', "game'master", '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor');
foreach($words_blocked as $word)
{
if(!(strpos($name_lower, $word) === false))
if(!(strpos($name_lower, $word) === false)) {
$error = 'Your name contains illegal words.';
return false;
}
}
$name_length = strlen($name_lower);
for($i = 0; $i < $name_length; $i++)
{
if(isset($name_lower[$i]) && isset($name_lower[$i + 1]) && $name_lower[$i] == $name_lower[$i + 1] && isset($name_lower[$i + 2]) && $name_lower[$i] == $name_lower[$i + 2]) {
$error = 'Your name is invalid.';
return false;
}
}
for($i = 0; $i < $name_length; $i++)
{
if(isset($name_lower[$i]) && isset($name_lower[$i + 1]) && $name_lower[$i] == $name_lower[$i + 1] && isset($name_lower[$i + 2]) && $name_lower[$i] == $name_lower[$i + 2])
return false;
}
for($i = 0; $i < $name_length; $i++)
{
if(isset($name_lower[$i - 1]) && $name_lower[$i - 1] == ' ' && isset($name_lower[$i + 1]) && $name_lower[$i + 1] == ' ')
if(isset($name_lower[$i - 1]) && $name_lower[$i - 1] == ' ' && isset($name_lower[$i + 1]) && $name_lower[$i + 1] == ' ') {
$error = 'Your name contains too many spaces.';
return false;
}
}
if(isset($config['monsters']))
{
if(in_array($name_lower, $config['monsters']))
if(in_array($name_lower, $config['monsters'])) {
$error = 'Your name cannot contains monster name.';
return false;
}
}
$monsters = $db->query(
'SELECT ' . $db->fieldName('name') .
' FROM ' . $db->tableName(TABLE_PREFIX . 'monsters') .
' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($name_lower));
if($monsters->rowCount() > 0)
if($monsters->rowCount() > 0) {
$error = 'Your name cannot contains monster name.';
return false;
}
$spells_name = $db->query(
'SELECT ' . $db->fieldName('name') .
' FROM ' . $db->tableName(TABLE_PREFIX . 'spells') .
' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($name_lower));
if($spells_name->rowCount() > 0)
if($spells_name->rowCount() > 0) {
$error = 'Your name cannot contains spell name.';
return false;
}
$spells_words = $db->query(
'SELECT ' . $db->fieldName('words') .
' FROM ' . $db->tableName(TABLE_PREFIX . 'spells') .
' WHERE ' . $db->fieldName('words') . ' = ' . $db->quote($name_lower));
if($spells_words->rowCount() > 0)
if($spells_words->rowCount() > 0) {
$error = 'Your name cannot contains spell name.';
return false;
if(isset($config['npc']))
{
if(in_array($name_lower, $config['npc']))
return false;
}
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '") != $name_length)
return false;
if(isset($config['npc']))
{
if(in_array($name_lower, $config['npc'])) {
$error = 'Your name cannot contains NPC name.';
return false;
}
}
return preg_match("/[A-z ']{3,28}/", $name);
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '") != $name_length) {
$error = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.';
return false;
}
if($name_length < 3 || $name_length > 28) {
$error = 'Your name cannot be shorter than 3 characters and longer than 28 characters.';
return false;
}
if(!preg_match("/[A-z ']{3,28}/", $name)) {
$error = 'Your name containst illegal characters.';
return false;
}
return true;
}
function check_rank_name($name)
@@ -778,7 +839,7 @@ function template_form()
else
{
$templates = get_templates();
$cache->set('templates', serialize($templates), 120);
$cache->set('templates', serialize($templates), 30);
}
}
else
@@ -815,7 +876,7 @@ function getCreatureName($killer, $showStatus = false, $extendedInfo = false)
if(!$showStatus)
return $str.'<b>'.$player->getName().'</b></a>';
$str .= '<font color="'.($player->isOnline() ? 'green' : 'red').'">'.$player->getName().'</font></b></a>';
$str .= '<font color="'.($player->isOnline() ? 'green' : 'red').'">' . $player->getName() . '</font></b></a>';
if($extendedInfo) {
$str .= '<br><small>'.$player->getLevel().' '.$config['vocations'][$player->getVocation()].'</small>';
}

View File

@@ -121,10 +121,10 @@ else {
$config['vocations'] = array();
foreach($vocations->getElementsByTagName('vocation') as $vocation) {
$id = $vocation->getAttribute('id');
if($id == $vocation->getAttribute('fromvoc'))
//if($id == $vocation->getAttribute('fromvoc'))
$config['vocations'][$id] = $vocation->getAttribute('name');
else
$config['vocations'][$id + 4] = $vocation->getAttribute('name');
//else
// $config['vocations'][$id] = $vocation->getAttribute('name');
}
if($cache->enabled()) {

View File

@@ -167,7 +167,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
public function load($id)
{
// SELECT query on database
$this->data = $this->db->query('SELECT ' . $this->db->fieldName('id') . ', ' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('password') . ', ' . $this->db->fieldName('salt') . ', ' . $this->db->fieldName('email') . ', ' . $this->db->fieldName('blocked') . ', ' . $this->db->fieldName('rlname') . ', ' . $this->db->fieldName('location') . ', ' . $this->db->fieldName('web_flags') . ', ' . $this->db->fieldName('premdays') . ', ' . $this->db->fieldName('lastday') . ', ' . $this->db->fieldName('created') . ' FROM ' . $this->db->tableName('accounts') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . (int) $id)->fetch();
$this->data = $this->db->query('SELECT ' . $this->db->fieldName('id') . ', ' . $this->db->fieldName('name') . ', ' . $this->db->fieldName('password') . ', ' . $this->db->fieldName('email') . ', ' . $this->db->fieldName('blocked') . ', ' . $this->db->fieldName('rlname') . ', ' . $this->db->fieldName('location') . ', ' . $this->db->fieldName('web_flags') . ', ' . $this->db->fieldName('premdays') . ', ' . $this->db->fieldName('lastday') . ', ' . $this->db->fieldName('created') . ' FROM ' . $this->db->tableName('accounts') . ' WHERE ' . $this->db->fieldName('id') . ' = ' . (int) $id)->fetch();
}
/**
@@ -247,13 +247,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
}
// UPDATE query on database
<<<<<<< .mine
$this->db->query('UPDATE `accounts` SET `name` = ' . $this->db->quote($this->data['name']) . ', `password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `blocked` = ' . (int) $this->data['blocked'] . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', `premdays` = ' . (int) $this->data['premdays'] . ', `lastday` = ' . (int) $this->data['lastday'] . ' WHERE `id` = ' . $this->data['id']);
||||||| .r19
$this->db->query('UPDATE ' . $this->db->tableName('accounts') . ' SET ' . $this->db->fieldName('password') . ' = ' . $this->db->quote($this->data['password']) . ', ' . $this->db->fieldName('email') . ' = ' . $this->db->quote($this->data['email']) . ', ' . $this->db->fieldName('blocked') . ' = ' . (int) $this->data['blocked'] . ', ' . $this->db->fieldName('rlname') . ' = ' . $this->db->quote($this->data['rlname']) . ', ' . $this->db->fieldName('location') . ' = ' . $this->db->quote($this->data['location']) . ', ' . $this->db->fieldName('web_flags') . ' = ' . (int) $this->data['web_flags'] . ', ' . $this->db->fieldName('premdays') . ' = ' . (int) $this->data['premdays'] . ', ' . $this->db->fieldName('lastday') . ' = ' . (int) $this->data['lastday'] . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
=======
$this->db->query('UPDATE ' . $this->db->tableName('accounts') . ' SET ' . $this->db->fieldName('password') . ' = ' . $this->db->quote($this->data['password']) . ', ' . $this->db->fieldName('salt') . ' = ' . $this->db->quote($this->data['salt']) . ', ' . $this->db->fieldName('email') . ' = ' . $this->db->quote($this->data['email']) . ', ' . $this->db->fieldName('blocked') . ' = ' . (int) $this->data['blocked'] . ', ' . $this->db->fieldName('rlname') . ' = ' . $this->db->quote($this->data['rlname']) . ', ' . $this->db->fieldName('location') . ' = ' . $this->db->quote($this->data['location']) . ', ' . $this->db->fieldName('web_flags') . ' = ' . (int) $this->data['web_flags'] . ', ' . $this->db->fieldName('premdays') . ' = ' . (int) $this->data['premdays'] . ', ' . $this->db->fieldName('lastday') . ' = ' . (int) $this->data['lastday'] . ' WHERE ' . $this->db->fieldName('id') . ' = ' . $this->data['id']);
>>>>>>> .r40
}
/**
@@ -449,16 +443,6 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
$this->data['password'] = (string) $password;
}
public function getSalt()
{
if( !isset($this->data['salt']) )
{
throw new E_OTS_NotLoaded();
}
return $this->data['salt'];
}
public function setSalt($salt)
{
$this->data['salt'] = (string) $salt;
@@ -801,20 +785,20 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
*/
public function getAccess()
{
global $groups;
if(!isset($groups))
$groups = new OTS_Groups_List();
// by default
$access = 0;
if(fieldExist('group_id', 'accounts')) {
$query = $this->db->query('SELECT `group_id` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch();
// if anything was found
if(isset($query['group_id']))
$access = $query['group_id'];
return $access;
}
global $groups;
if(!isset($groups))
$groups = new OTS_Groups_List();
$group = $groups->getGroup($query['group_id']);
if(!$group) return 0;
return $group->getAccess();
}
// finds groups of all characters
foreach( $this->getPlayersList() as $player)
@@ -831,6 +815,35 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
return $access;
}
public function getGroupId()
{
global $groups;
if(!isset($groups))
$groups = new OTS_Groups_List();
$group_id = 0;
if(fieldExist('group_id', 'accounts')) {
$query = $this->db->query('SELECT `group_id` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch();
// if anything was found
if(isset($query['group_id']))
return $query['group_id'];
}
// finds groups of all characters
foreach( $this->getPlayersList() as $player)
{
$group = $player->getGroup();
// checks if group's access level is higher then previouls found highest
if( $group->getId() > $group_id)
{
$group_id = $group->getId();
}
}
return $group_id;
}
/**
* Checks highest access level of account in given guild.
*

View File

@@ -92,16 +92,7 @@ class OTS_DB_MySQL extends OTS_Base_DB
$this->prefix = $params['prefix'];
}
// PDO constructor
try
{
parent::__construct('mysql:' . implode(';', $dns), $user, $password);
}
catch(PDOException $error)
{
echo 'Can\'t connect to MySQL database.';
exit;
}
parent::__construct('mysql:' . implode(';', $dns), $user, $password);
}
/**

View File

@@ -833,8 +833,9 @@ function checkName()
if(empty($newchar_errors))
{
if(!check_name_new_char($newchar_name))
$newchar_errors[] = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.';
$error = '';
if(!check_name_new_char($newchar_name, $error))
$newchar_errors[] = $error;
if($newchar_sex != 1 && $newchar_sex != "0")
$newchar_errors[] = 'Sex must be equal <b>0 (female)</b> or <b>1 (male)</b>.';
if(!in_array($newchar_town, $config['character_towns']))

View File

@@ -11,8 +11,8 @@
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Changelog';
$_page = $_GET['page'];
$id = $_GET['id'];
$_page = isset($_GET['page']) ? $_GET['page'] : 0;
$id = isset($_GET['id']) ? $_GET['id'] : 0;
$limit = 30;
$offset = $_page * $limit;
?>

View File

@@ -138,7 +138,7 @@ if(empty($action))
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();
echo '<tr bgcolor="'.getStyle(++$number_of_rows).'"><td><a href="?subtopic=forum&action=show_board&id='.$id.'">'.$section['name'].'</a><br /><small>'.$section['description'].'</small></td><td>'.(int) (isset($counters[$id]['posts']) ? $counters[$id]['posts'] : 0).'</td><td>'.(int) (isset($counters[$id]['threads']) ? $counters[$id]['threads'] : 0).'</td><td>';
echo '<tr bgcolor="'.getStyle(++$number_of_rows).'"><td><a href="' . getForumBoardLink($id) . '">'.$section['name'].'</a><br /><small>'.$section['description'].'</small></td><td>'.(int) (isset($counters[$id]['posts']) ? $counters[$id]['posts'] : 0).'</td><td>'.(int) (isset($counters[$id]['threads']) ? $counters[$id]['threads'] : 0).'</td><td>';
if(isset($last_post['name']))
echo date('d.m.y H:i:s', $last_post['post_date']).'<br />by ' . getPlayerLink($last_post['name']);
else
@@ -158,11 +158,11 @@ if($action == 'show_board')
for($i = 0; $i < $threads_count['threads_count'] / $config['forum_threads_per_page']; $i++)
{
if($i != $_page)
$links_to_pages .= '<a href="?subtopic=forum&action=show_board&id='.$section_id.'&page='.$i.'">'.($i + 1).'</a> ';
$links_to_pages .= '<a href="' . getForumBoardLink($section_id, $i) . '">'.($i + 1).'</a> ';
else
$links_to_pages .= '<b>'.($i + 1).' </b>';
}
echo '<a href="?subtopic=forum">Boards</a> >> <b>'.$sections[$section_id]['name'].'</b>';
echo '<a href="' . getPageLink('forum') . '">Boards</a> >> <b>'.$sections[$section_id]['name'].'</b>';
if(!$sections[$section_id]['closed'] || Forum::isModerator())
{
echo '<br /><br />
@@ -182,7 +182,7 @@ if($action == 'show_board')
echo '<a href="?subtopic=forum&action=move_thread&id='.$thread['id'].'"\')"><span style="color:darkgreen">[MOVE]</span></a>';
echo '<a href="?subtopic=forum&action=remove_post&id='.$thread['id'].'" onclick="return confirm(\'Are you sure you want remove thread > '.$thread['post_topic'].' <?\')"><font color="red">[REMOVE]</font></a> ';
}
echo '<a href="?subtopic=forum&action=show_thread&id='.$thread['id'].'">'.htmlspecialchars($thread['post_topic']).'</a><br /><small>'.htmlspecialchars(substr($thread['post_text'], 0, 50)).'...</small></td><td>' . getPlayerLink($thread['name']) . '</td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';
echo '<a href="' . getForumThreadLink($thread['id']) . '">'.htmlspecialchars($thread['post_topic']).'</a><br /><small>'.htmlspecialchars(substr($thread['post_text'], 0, 50)).'...</small></td><td>' . getPlayerLink($thread['name']) . '</td><td>'.(int) $thread['replies'].'</td><td>'.(int) $thread['views'].'</td><td>';
if($thread['last_post'] > 0)
{
$last_post = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_date` FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id']." AND `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` ORDER BY `post_date` DESC LIMIT 1")->fetch();
@@ -214,14 +214,14 @@ if($action == 'show_thread')
for($i = 0; $i < $posts_count['posts_count'] / $config['forum_threads_per_page']; $i++)
{
if($i != $_page)
$links_to_pages .= '<a href="?subtopic=forum&action=show_thread&id='.$thread_id.'&page='.$i.'">'.($i + 1).'</a> ';
$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="?subtopic=forum">Boards</a> >> <a href="?subtopic=forum&action=show_board&id='.$threads[0]['section'].'">'.$sections[$threads[0]['section']]['name'].'</a> >> <b>'.$thread_name['post_topic'].'</b>';
echo '<a href="' . getPageLink('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>&nbsp;</td></tr>';
$player = $ots->createObject('Player');
foreach($threads as $thread)
@@ -296,14 +296,14 @@ if($action == 'remove_post')
if($post['id'] == $post['first_post'])
{
$db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `first_post` = ".$post['id']);
header('Location: ?subtopic=forum&action=show_board&id='.$post['section']);
header('Location: ' . getForumBoardLink($post['section']));
}
else
{
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`id` < ".$id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $post['first_post'])->fetch();
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
$db->query("DELETE FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post['id']);
header('Location: ?subtopic=forum&action=show_thread&id='.$post['first_post'].'&page='.(int) $_page);
header('Location: ' . getForumThreadLink($post['first_post'], (int) $_page));
}
}
else
@@ -319,7 +319,7 @@ if($action == 'new_post')
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
$thread_id = (int) $_REQUEST['thread_id'];
$thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread_id." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread_id." LIMIT 1")->fetch();
echo '<a href="?subtopic=forum">Boards</a> >> <a href="?subtopic=forum&action=show_board&id='.$thread['section'].'">'.$sections[$thread['section']]['name'].'</a> >> <a href="?subtopic=forum&action=show_thread&id='.$thread_id.'">'.$thread['post_topic'].'</a> >> <b>Post new reply</b><br /><h3>'.$thread['post_topic'].'</h3>';
echo '<a href="' . getPageLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread_id) . '">'.$thread['post_topic'].'</a> >> <b>Post new reply</b><br /><h3>'.$thread['post_topic'].'</h3>';
if(isset($thread['id']))
{
$quote = isset($_REQUEST['quote']) ? (int) $_REQUEST['quote'] : NULL;
@@ -374,8 +374,8 @@ if($action == 'new_post')
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `replies`=`replies`+1, `last_post`=".time()." WHERE `id` = ".(int) $thread_id);
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".time()." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['id'])->fetch();
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
header('Location: ?subtopic=forum&action=show_thread&id='.$thread_id.'&page='.$_page);
echo '<br />Thank you for posting.<br /><a href="?subtopic=forum&action=show_thread&id='.$thread_id.'">GO BACK TO LAST THREAD</a>';
header('Location: ' . getForumThreadLink($thread_id, $_page));
echo '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id, $_page) . '">GO BACK TO LAST THREAD</a>';
}
}
if(!$saved)
@@ -435,7 +435,7 @@ if($action == 'edit_post')
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="?subtopic=forum">Boards</a> >> <a href="?subtopic=forum&action=show_board&id='.$thread['section'].'">'.$sections[$thread['section']]['name'].'</a> >> <a href="?subtopic=forum&action=show_thread&id='.$thread['first_post'].'">'.$first_post['post_topic'].'</a> >> <b>Edit post</b>';
echo '<a href="' . getPageLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread['first_post']) . '">'.$first_post['post_topic'].'</a> >> <b>Edit post</b>';
if($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())
{
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
@@ -483,8 +483,8 @@ if($action == 'edit_post')
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $char_id.", `post_text` = ".$db->quote($text).", `post_topic` = ".$db->quote($post_topic).", `post_smile` = ".(int) $smile.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']);
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".$thread['post_date']." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['first_post'])->fetch();
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
header('Location: ?subtopic=forum&action=show_thread&id='.$thread['first_post'].'&page='.$_page);
echo '<br />Thank you for editing post.<br /><a href="?subtopic=forum&action=show_thread&id='.$thread['first_post'].'">GO BACK TO LAST THREAD</a>';
header('Location: ' . getForumThreadLink($thread['first_post'], $_page));
echo '<br />Thank you for editing post.<br /><a href="' . getForumThreadLink($thread['first_post'], $_page) . '">GO BACK TO LAST THREAD</a>';
}
}
else
@@ -531,7 +531,7 @@ if($action == 'new_topic')
{
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
$section_id = (int) $_REQUEST['section_id'];
echo '<a href="?subtopic=forum">Boards</a> >> <a href="?subtopic=forum&action=show_board&id='.$section_id.'">'.$sections[$section_id]['name'].'</a> >> <b>Post new thread</b><br />';
echo '<a href="' . getPageLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($section_id) . '">'.$sections[$section_id]['name'].'</a> >> <b>Post new thread</b><br />';
if(isset($sections[$section_id]['name']))
{
if($sections[$section_id]['closed'] && !Forum::isModerator())
@@ -590,8 +590,8 @@ if($action == 'new_topic')
$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', '0', '".time()."', '".(int) $section_id."', '0', '0', '".$account_logged->getId()."', '".(int) $char_id."', ".$db->quote($text).", ".$db->quote($post_topic).", '".(int) $smile."', '".time()."', '0', '0', '".$_SERVER['REMOTE_ADDR']."')");
$thread_id = $db->lastInsertId();
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id);
header('Location: ?subtopic=forum&action=show_thread&id='.$thread_id);
echo '<br />Thank you for posting.<br /><a href="?subtopic=forum&action=show_thread&id='.$thread_id.'">GO BACK TO LAST THREAD</a>';
header('Location: ' . getForumThreadLink($thread_id));
echo '<br />Thank you for posting.<br /><a href="' . getForumThreadLink($thread_id) . '">GO BACK TO LAST THREAD</a>';
}
}
if(!$saved)
@@ -648,7 +648,7 @@ if($action == 'move_thread')
<br/><strong>Select the new board:&nbsp;</strong><SELECT NAME=sektion>';
foreach($sections as $id => $section) { echo '<OPTION value="'.$id.'">'.$section['name'].'</OPTION>'; } echo '</SELECT>
<INPUT TYPE="submit" VALUE="Move Thread"></FORM>
<form action="?subtopic=forum&action=show_board&id='.$post['section'].'" method="POST">
<form action="' . getForumBoardLink($post['section']) . '" method="POST">
<input type="submit" value="Cancel"></form></td></tr></table></td></tr></table>';
}
}
@@ -672,7 +672,7 @@ if($action == 'moved_thread')
{
$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: ?subtopic=forum&action=show_board&id='.$nPost['section']);
header('Location: ' . getForumBoardLink($nPost['section']));
}
}
else

View File

@@ -48,7 +48,7 @@ if(isset($_GET['archive']))
$author = $query['name'];
}
echo news_parse($news['title'], $news['body'], $news['date'], $categories[$news['category']]['icon_id'], $config['news_author'] ? $author : '', $news['comments']);
echo news_parse($news['title'], $news['body'], $news['date'], $categories[$news['category']]['icon_id'], $config['news_author'] ? $author : '', getForumThreadLink($news['comments']));
}
else
echo 'This news doesn\'t exist or is hidden.<br>';
@@ -444,7 +444,7 @@ if(!$news_cached)
</a>';
}
echo news_parse($news['title'], $news['body'] . $admin_options, $news['date'], $categories[$news['category']]['icon_id'], $config['news_author'] ? $author : '', $news['comments']);
echo news_parse($news['title'], $news['body'] . $admin_options, $news['date'], $categories[$news['category']]['icon_id'], $config['news_author'] ? $author : '', getForumThreadLink($news['comments']));
}
}

View File

@@ -22,6 +22,7 @@ if(isset($_POST['reload_spells']) && $canEdit)
foreach($config_vocations as $voc_id => $voc_name) {
$vocations_ids[$voc_name] = $voc_id;
}
$allspells = new OTS_SpellsList($config['data_path'].'spells/spells.xml');
//add conjure spells
$conjurelist = $allspells->getConjuresList();
@@ -89,8 +90,12 @@ if(isset($_POST['reload_spells']) && $canEdit)
$nr_of_vocations = count($vocations);
$vocations_to_db = "";
$voc_nr = 0;
foreach($vocations as $vocation_to_add_name) {
$vocations_to_db .= $vocation_to_add_name;
foreach($vocations as $vocation_to_add) {
if(check_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) {
@@ -234,8 +239,10 @@ else
$showed_vocations = 0;
foreach($spell_vocations as $spell_vocation)
{
echo $config_vocations[$spell_vocation];
$showed_vocations++;
if(isset($config_vocations[$spell_vocation])) {
echo $config_vocations[$spell_vocation];
$showed_vocations++;
}
if($showed_vocations != count($spell_vocations))
echo '<br/>';
}

View File

@@ -26,14 +26,22 @@ if($config['template_allow_change'])
}
else if(isset($_SESSION['template']))
{
if(!preg_match("/[^A-z0-9_\-]/", $_SESSION['template']))
if(!preg_match("/[^A-z0-9_\-]/", $_SESSION['template'])) {
$template_name = $_SESSION['template'];
else
}
else {
$template_name = $config['template'];
}
}
}
$template_path = 'templates/' . $template_name;
if(!file_exists($template_path . '/config.php'))
{
$template_name = 'kathrine';
$template_path = 'templates/' . $template_name;
}
$file = $template_path . '/config.ini';
$exists = file_exists($file);
if($exists || ($config['backward_support'] && file_exists($template_path . '/layout_config.ini')))
@@ -92,6 +100,7 @@ $template['link_screenshots'] = internalLayoutLink('screenshots');
$template['link_movies'] = internalLayoutLink('movies');
$template['link_serverInfo'] = internalLayoutLink('serverInfo');
$template['link_experienceTable'] = internalLayoutLink('experienceTable');
$template['link_faq'] = internalLayoutLink('faq');
$template['link_points'] = internalLayoutLink('points');
$template['link_gifts'] = internalLayoutLink('gifts');
$template['link_gifts_history'] = internalLayoutLink('gifts', 'show_history');

View File

@@ -3,7 +3,6 @@ defined('MYAAC') or die('Direct access not allowed!');
function news_parse($title, $content, $date, $icon = 0, $author = '', $comments = '')
{
global $template_path, $config;
//$tmp = $template_path.'/images/letters/'.$content[0].'.gif';
//if(file_exists($tmp)) {
// $firstLetter = '<img src="' . $tmp . '" alt="'.$content[0].'" BORDER=0 ALIGN=bottom>';