mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 09:19:22 +02:00
* added news ticker for kathrine template
* (internal) moved news tickers to twig template * (internal) moved Forum class to separate file * (internal) moved deprecated functions to compat.php
This commit is contained in:
parent
21b1383c9a
commit
5e414ebda8
@ -238,6 +238,7 @@ if($config['backward_support']) {
|
|||||||
$layout_header = template_header();
|
$layout_header = template_header();
|
||||||
$layout_name = $template_path;
|
$layout_name = $template_path;
|
||||||
$news_content = '';
|
$news_content = '';
|
||||||
|
$tickers_content = '';
|
||||||
$subtopic = PAGE;
|
$subtopic = PAGE;
|
||||||
$main_content = '';
|
$main_content = '';
|
||||||
|
|
||||||
|
64
system/compat.php
Normal file
64
system/compat.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Deprecated functions (compat)
|
||||||
|
*
|
||||||
|
* @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!');
|
||||||
|
|
||||||
|
function check_name($name, &$errors = '') {
|
||||||
|
if(Validator::characterName($name))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$errors = Validator::getLastError();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_account_id($id, &$errors = '') {
|
||||||
|
if(Validator::accountId($id))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$errors = Validator::getLastError();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_account_name($name, &$errors = '') {
|
||||||
|
if(Validator::accountName($name))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$errors = Validator::getLastError();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_name_new_char($name, &$errors = '') {
|
||||||
|
if(Validator::newCharacterName($name))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$errors = Validator::getLastError();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_rank_name($name, &$errors = '') {
|
||||||
|
if(Validator::rankName($name))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$errors = Validator::getLastError();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_guild_name($name, &$errors = '') {
|
||||||
|
if(Validator::guildName($name))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
$errors = Validator::getLastError();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function news_place() {
|
||||||
|
return tickers();
|
||||||
|
}
|
||||||
|
?>
|
@ -9,6 +9,7 @@
|
|||||||
* @link http://my-aac.org
|
* @link http://my-aac.org
|
||||||
*/
|
*/
|
||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
|
|
||||||
function success($message, $return = false) {
|
function success($message, $return = false) {
|
||||||
if($return)
|
if($return)
|
||||||
return '<p class="success">' . $message . '</p>';
|
return '<p class="success">' . $message . '</p>';
|
||||||
@ -411,42 +412,16 @@ function short_text($text, $limit)
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
function news_place()
|
function tickers()
|
||||||
{
|
{
|
||||||
global $template_path, $news_content;
|
global $tickers_content;
|
||||||
|
|
||||||
$news = '';
|
if(PAGE == 'news') {
|
||||||
if(PAGE == 'news')
|
if(isset($tickers_content))
|
||||||
{
|
return $tickers_content;
|
||||||
//add tickers to site - without it tickers will not be showed
|
|
||||||
if(isset($news_content))
|
|
||||||
$news .= $news_content;
|
|
||||||
|
|
||||||
//featured article
|
|
||||||
/* $news .= ' <div id="featuredarticle" class="Box">
|
|
||||||
<div class="Corner-tl" style="background-image:url('.$template_path.'/images/content/corner-tl.gif);"></div>
|
|
||||||
<div class="Corner-tr" style="background-image:url('.$template_path.'/images/content/corner-tr.gif);"></div>
|
|
||||||
<div class="Border_1" style="background-image:url('.$template_path.'/images/content/border-1.gif);"></div>
|
|
||||||
<div class="BorderTitleText" style="background-image:url('.$template_path.'/images/content/title-background-green.gif);"></div>
|
|
||||||
<img class="Title" src="'.$template_path.'/images/strings/headline-featuredarticle.gif" alt="Contentbox headline" />
|
|
||||||
<div class="Border_2">
|
|
||||||
<div class="Border_3">
|
|
||||||
<div class="BoxContent" style="background-image:url('.$template_path.'/images/content/scroll.gif);">
|
|
||||||
<div id=\'TeaserThumbnail\'><img src="'.$template_path.'/images/news/features.jpg" width=150 height=100 border=0 alt="" /></div><div id=\'TeaserText\'><div style="position: relative; top: -2px; margin-bottom: 2px;" >
|
|
||||||
<b>Tutaj wpisz tytul</b></div>
|
|
||||||
tutaj wpisz tresc newsa<br>
|
|
||||||
zdjecie laduje sie w <i>tibiacom/images/news/features.jpg</i><br>
|
|
||||||
skad sie laduje mozesz zmienic linijke ponad komentarzem
|
|
||||||
</div> </div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="Border_1" style="background-image:url('.$template_path.'/images/content/border-1.gif);"></div>
|
|
||||||
<div class="CornerWrapper-b"><div class="Corner-bl" style="background-image:url('.$template_path.'/images/content/corner-bl.gif);"></div></div>
|
|
||||||
<div class="CornerWrapper-b"><div class="Corner-br" style="background-image:url('.$template_path.'/images/content/corner-br.gif);"></div></div>
|
|
||||||
</div>';*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $news;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -485,8 +460,7 @@ function template_header($is_admin = false)
|
|||||||
<meta http-equiv="content-type" content="text/html; charset=' . $charset . '" />';
|
<meta http-equiv="content-type" content="text/html; charset=' . $charset . '" />';
|
||||||
if(!$is_admin)
|
if(!$is_admin)
|
||||||
$ret .= '
|
$ret .= '
|
||||||
<title>' . $title_full . '</title>
|
<title>' . $title_full . '</title>';
|
||||||
<base href="' . BASE_URL . '" />';
|
|
||||||
|
|
||||||
$ret .= '
|
$ret .= '
|
||||||
<meta name="description" content="' . $config['meta_description'] . '" />
|
<meta name="description" content="' . $config['meta_description'] . '" />
|
||||||
@ -958,6 +932,7 @@ function str_replace_first($search, $replace, $subject) {
|
|||||||
if ($pos !== false) {
|
if ($pos !== false) {
|
||||||
return substr_replace($subject, $replace, $pos, strlen($search));
|
return substr_replace($subject, $replace, $pos, strlen($search));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $subject;
|
return $subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -976,52 +951,5 @@ function unsetSession($key) {
|
|||||||
|
|
||||||
// validator functions
|
// validator functions
|
||||||
require_once(LIBS . 'validator.php');
|
require_once(LIBS . 'validator.php');
|
||||||
|
require_once(SYSTEM . 'compat.php');
|
||||||
function check_name($name, &$errors = '') {
|
|
||||||
if(Validator::characterName($name))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
$errors = Validator::getLastError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_account_id($id, &$errors = '') {
|
|
||||||
if(Validator::accountId($id))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
$errors = Validator::getLastError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_account_name($name, &$errors = '') {
|
|
||||||
if(Validator::accountName($name))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
$errors = Validator::getLastError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_name_new_char($name, &$errors = '') {
|
|
||||||
if(Validator::newCharacterName($name))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
$errors = Validator::getLastError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_rank_name($name, &$errors = '') {
|
|
||||||
if(Validator::rankName($name))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
$errors = Validator::getLastError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_guild_name($name, &$errors = '') {
|
|
||||||
if(Validator::guildName($name))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
$errors = Validator::getLastError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
286
system/libs/forum.php
Normal file
286
system/libs/forum.php
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Forum 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 Forum
|
||||||
|
{
|
||||||
|
static public function canPost($account)
|
||||||
|
{
|
||||||
|
global $db, $config;
|
||||||
|
|
||||||
|
if(!$account->isLoaded() || $account->isBanned())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(self::isModerator())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return
|
||||||
|
$db->query(
|
||||||
|
'SELECT `id` FROM `players` WHERE `account_id` = ' . $db->quote($account->getId()) .
|
||||||
|
' AND `level` >= ' . $db->quote($config['forum_level_required']) .
|
||||||
|
' LIMIT 1')->rowCount() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function isModerator() {
|
||||||
|
return hasFlag(FLAG_CONTENT_FORUM) || superAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function add_thread($title, $body, $section_id, $player_id, $account_id, &$errors)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
$thread_id = 0;
|
||||||
|
if($db->insert(TABLE_PREFIX . 'forum', array('first_post' => 0, 'last_post' => time(), 'section' => $section_id, 'replies' => 0, 'views' => 0, 'author_aid' => isset($account_id) ? $account_id : 0, 'author_guid' => isset($player_id) ? $player_id : 0, 'post_text' => $body, 'post_topic' => $title, 'post_smile' => 0, 'post_date' => time(), 'last_edit_aid' => 0, 'edit_date' => 0, 'post_ip' => $_SERVER['REMOTE_ADDR']))) {
|
||||||
|
$thread_id = $db->lastInsertId();
|
||||||
|
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $thread_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
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]))
|
||||||
|
{
|
||||||
|
$query = $db->select(TABLE_PREFIX . 'forum_boards', array('name' => $name));
|
||||||
|
|
||||||
|
if($query === false)
|
||||||
|
{
|
||||||
|
$query =
|
||||||
|
$db->query(
|
||||||
|
'SELECT ' . $db->fieldName('ordering') .
|
||||||
|
' FROM ' . $db->tableName(TABLE_PREFIX . 'forum_boards') .
|
||||||
|
' ORDER BY ' . $db->fieldName('ordering') . ' DESC LIMIT 1'
|
||||||
|
);
|
||||||
|
|
||||||
|
$ordering = 0;
|
||||||
|
if($query->rowCount() > 0) {
|
||||||
|
$query = $query->fetch();
|
||||||
|
$ordering = $query['ordering'] + 1;
|
||||||
|
}
|
||||||
|
$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.';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$errors[] = 'Please fill all inputs.';
|
||||||
|
|
||||||
|
return !count($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function get_board($id) {
|
||||||
|
global $db;
|
||||||
|
return $db->select(TABLE_PREFIX . 'forum_boards', array('id' => $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function update_board($id, $name, $access, $guild, $description) {
|
||||||
|
global $db;
|
||||||
|
$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)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
if(isset($id))
|
||||||
|
{
|
||||||
|
if(self::get_board($id) !== false)
|
||||||
|
$db->delete(TABLE_PREFIX . 'forum_boards', array('id' => $id));
|
||||||
|
else
|
||||||
|
$errors[] = 'Forum board with id ' . $id . ' does not exists.';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$errors[] = 'id not set';
|
||||||
|
|
||||||
|
return !count($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function toggleHidden_board($id, &$errors)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
if(isset($id))
|
||||||
|
{
|
||||||
|
$query = self::get_board($id);
|
||||||
|
if($query !== false)
|
||||||
|
$db->update(TABLE_PREFIX . 'forum_boards', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
||||||
|
else
|
||||||
|
$errors[] = 'Forum board with id ' . $id . ' does not exists.';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$errors[] = 'id not set';
|
||||||
|
|
||||||
|
return !count($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
static public function move_board($id, $i, &$errors)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
$query = self::get_board($id);
|
||||||
|
if($query !== false)
|
||||||
|
{
|
||||||
|
$ordering = $query['ordering'] + $i;
|
||||||
|
$old_record = $db->select(TABLE_PREFIX . 'forum_boards', array('ordering' => $ordering));
|
||||||
|
if($old_record !== false)
|
||||||
|
$db->update(TABLE_PREFIX . 'forum_boards', array('ordering' => $query['ordering']), array('ordering' => $ordering));
|
||||||
|
|
||||||
|
$db->update(TABLE_PREFIX . 'forum_boards', array('ordering' => $ordering), array('id' => $id));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$errors[] = 'Forum board with id ' . $id . ' does not exists.';
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -11,7 +11,8 @@
|
|||||||
*/
|
*/
|
||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
|
|
||||||
class Items {
|
class Items
|
||||||
|
{
|
||||||
private static $error = '';
|
private static $error = '';
|
||||||
|
|
||||||
public static function loadFromXML($show = false)
|
public static function loadFromXML($show = false)
|
||||||
|
@ -27,6 +27,8 @@ if(strtolower($config['forum']) != 'site')
|
|||||||
if(!$logged)
|
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 />';
|
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 />';
|
||||||
|
|
||||||
|
require_once(LIBS . 'forum.php');
|
||||||
|
|
||||||
$canEdit = hasFlag(FLAG_CONTENT_FORUM) || superAdmin();
|
$canEdit = hasFlag(FLAG_CONTENT_FORUM) || superAdmin();
|
||||||
if($canEdit)
|
if($canEdit)
|
||||||
{
|
{
|
||||||
@ -188,263 +190,4 @@ if(file_exists(PAGES . 'forum/' . $action . '.php')) {
|
|||||||
require(PAGES . 'forum/' . $action . '.php');
|
require(PAGES . 'forum/' . $action . '.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
class Forum
|
?>
|
||||||
{
|
|
||||||
static public function canPost($account)
|
|
||||||
{
|
|
||||||
global $db, $config;
|
|
||||||
|
|
||||||
if(!$account->isLoaded() || $account->isBanned())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if(self::isModerator())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return
|
|
||||||
$db->query(
|
|
||||||
'SELECT `id` FROM `players` WHERE `account_id` = ' . $db->quote($account->getId()) .
|
|
||||||
' AND `level` >= ' . $db->quote($config['forum_level_required']) .
|
|
||||||
' LIMIT 1')->rowCount() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static public function isModerator() {
|
|
||||||
return hasFlag(FLAG_CONTENT_FORUM) || admin();
|
|
||||||
}
|
|
||||||
|
|
||||||
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]))
|
|
||||||
{
|
|
||||||
$query = $db->select(TABLE_PREFIX . 'forum_boards', array('name' => $name));
|
|
||||||
|
|
||||||
if($query === false)
|
|
||||||
{
|
|
||||||
$query =
|
|
||||||
$db->query(
|
|
||||||
'SELECT ' . $db->fieldName('ordering') .
|
|
||||||
' FROM ' . $db->tableName(TABLE_PREFIX . 'forum_boards') .
|
|
||||||
' ORDER BY ' . $db->fieldName('ordering') . ' DESC LIMIT 1'
|
|
||||||
);
|
|
||||||
|
|
||||||
$ordering = 0;
|
|
||||||
if($query->rowCount() > 0) {
|
|
||||||
$query = $query->fetch();
|
|
||||||
$ordering = $query['ordering'] + 1;
|
|
||||||
}
|
|
||||||
$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.';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$errors[] = 'Please fill all inputs.';
|
|
||||||
|
|
||||||
return !count($errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
static public function get_board($id) {
|
|
||||||
global $db;
|
|
||||||
return $db->select(TABLE_PREFIX . 'forum_boards', array('id' => $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
static public function update_board($id, $name, $access, $guild, $description) {
|
|
||||||
global $db;
|
|
||||||
$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)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
if(isset($id))
|
|
||||||
{
|
|
||||||
if(self::get_board($id) !== false)
|
|
||||||
$db->delete(TABLE_PREFIX . 'forum_boards', array('id' => $id));
|
|
||||||
else
|
|
||||||
$errors[] = 'Forum board with id ' . $id . ' does not exists.';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$errors[] = 'id not set';
|
|
||||||
|
|
||||||
return !count($errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
static public function toggleHidden_board($id, &$errors)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
if(isset($id))
|
|
||||||
{
|
|
||||||
$query = self::get_board($id);
|
|
||||||
if($query !== false)
|
|
||||||
$db->update(TABLE_PREFIX . 'forum_boards', array('hidden' => ($query['hidden'] == 1 ? 0 : 1)), array('id' => $id));
|
|
||||||
else
|
|
||||||
$errors[] = 'Forum board with id ' . $id . ' does not exists.';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$errors[] = 'id not set';
|
|
||||||
|
|
||||||
return !count($errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
static public function move_board($id, $i, &$errors)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
$query = self::get_board($id);
|
|
||||||
if($query !== false)
|
|
||||||
{
|
|
||||||
$ordering = $query['ordering'] + $i;
|
|
||||||
$old_record = $db->select(TABLE_PREFIX . 'forum_boards', array('ordering' => $ordering));
|
|
||||||
if($old_record !== false)
|
|
||||||
$db->update(TABLE_PREFIX . 'forum_boards', array('ordering' => $query['ordering']), array('ordering' => $ordering));
|
|
||||||
|
|
||||||
$db->update(TABLE_PREFIX . 'forum_boards', array('ordering' => $ordering), array('id' => $id));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$errors[] = 'Forum board with id ' . $id . ' does not exists.';
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
* @link http://my-aac.org
|
* @link http://my-aac.org
|
||||||
*/
|
*/
|
||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
header('X-XSS-Protection: 0');
|
|
||||||
|
require_once(LIBS . 'forum.php');
|
||||||
|
|
||||||
if(isset($_GET['archive']))
|
if(isset($_GET['archive']))
|
||||||
{
|
{
|
||||||
@ -67,13 +68,8 @@ if(isset($_GET['archive']))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
echo "This news doesn't exist or is hidden.<br/>";
|
echo "This news doesn't exist or is hidden.<br/>";
|
||||||
?>
|
|
||||||
<center>
|
echo $twig->render('news.back_button.html.twig');
|
||||||
<table cellspacing="0" cellpadding="0" border="0"><form method="post" action="<?php echo getLink('news/archive'); ?>"><tbody><tr><td>
|
|
||||||
<input width="120" height="18" border="0" type="image" src="<?php echo $template_path; ?>/images/global/buttons/sbutton_back.gif" alt="Back" name="Back">
|
|
||||||
</form></td></tr></tbody></table>
|
|
||||||
</center>
|
|
||||||
<?php
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -99,6 +95,7 @@ if(isset($_GET['archive']))
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header('X-XSS-Protection: 0');
|
||||||
$title = 'Latest News';
|
$title = 'Latest News';
|
||||||
|
|
||||||
$news_cached = false;
|
$news_cached = false;
|
||||||
@ -124,7 +121,7 @@ if($canEdit)
|
|||||||
|
|
||||||
if($action == 'add') {
|
if($action == 'add') {
|
||||||
if(isset($forum_section) && $forum_section != '-1') {
|
if(isset($forum_section) && $forum_section != '-1') {
|
||||||
$forum_add = Forum::add($p_title, $body, $forum_section, $player_id, $account_logged->getId(), $errors);
|
$forum_add = Forum::add_thread($p_title, $body, $forum_section, $player_id, $account_logged->getId(), $errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $errors)) {
|
if(News::add($p_title, $body, $type, $category, $player_id, isset($forum_add) && $forum_add != 0 ? $forum_add : 0, $errors)) {
|
||||||
@ -187,52 +184,25 @@ if(!$news_cached)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tickers =
|
$tickers_db =
|
||||||
$db->query(
|
$db->query(
|
||||||
'SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news') . ' WHERE ' . $db->fieldName('type') . ' = ' . TICKET .
|
'SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news') . ' WHERE ' . $db->fieldName('type') . ' = ' . TICKET .
|
||||||
($canEdit ? '' : ' AND ' . $db->fieldName('hidden') . ' != 1') .
|
($canEdit ? '' : ' AND ' . $db->fieldName('hidden') . ' != 1') .
|
||||||
' ORDER BY ' . $db->fieldName('date') . ' DESC' .
|
' ORDER BY ' . $db->fieldName('date') . ' DESC' .
|
||||||
' LIMIT ' . $config['news_ticker_limit']);
|
' LIMIT ' . $config['news_ticker_limit']);
|
||||||
|
|
||||||
if($tickers->rowCount() > 0)
|
if($tickers_db->rowCount() > 0)
|
||||||
{
|
{
|
||||||
$rows = 0;
|
$tickers = $tickers_db->fetchAll();
|
||||||
$tickers_to_add = '';
|
foreach($tickers as &$ticker) {
|
||||||
foreach($tickers as $news)
|
$ticker['icon'] = $categories[$ticker['category']]['icon_id'];
|
||||||
{
|
$ticker['body_short'] = short_text(strip_tags($ticker['body']), 100);
|
||||||
$admin_options = '';
|
|
||||||
if($canEdit)
|
|
||||||
{
|
|
||||||
$admin_options = '<a href="?subtopic=news&action=edit&id=' . $news['id'] . '" title="Edit">
|
|
||||||
<img src="images/edit.png"/>
|
|
||||||
Edit
|
|
||||||
</a>
|
|
||||||
<a id="delete" href="' . BASE_URL . '?subtopic=news&action=delete&id=' . $news['id'] . '" onclick="return confirm(\'Are you sure?\');" title="Delete">
|
|
||||||
<img src="images/del.png"/>
|
|
||||||
Delete
|
|
||||||
</a>
|
|
||||||
<a href="?subtopic=news&action=hide&id=' . $news['id'] . '" title="' . ($news['hidden'] != 1 ? 'Hide' : 'Show') . '">
|
|
||||||
<img src="images/' . ($news['hidden'] != 1 ? 'success' : 'error') . '.png"/>
|
|
||||||
' . ($news['hidden'] != 1 ? 'Hide' : 'Show') . '
|
|
||||||
</a>';
|
|
||||||
}
|
|
||||||
$tickers_to_add .= '<div id="TickerEntry-'.$rows.'" class="Row" onclick=\'TickerAction("TickerEntry-'.$rows.'")\'>
|
|
||||||
<div class="' . (is_int($rows / 2) ? "Odd" : "Even") . '">
|
|
||||||
<div class="NewsTickerIcon" style="background-image: url('.$template_path.'/images/news/icon_'.$categories[$news['category']]['icon_id'].'_small.gif);"></div>
|
|
||||||
<div id="TickerEntry-'.$rows.'-Button" class="NewsTickerExtend" style="background-image: url('.$template_path.'/images/general/plus.gif);"></div>
|
|
||||||
<div class="NewsTickerText">
|
|
||||||
<span class="NewsTickerDate">'.date("j M Y", $news['date']).' -</span>
|
|
||||||
<div id="TickerEntry-'.$rows.'-ShortText" class="NewsTickerShortText">';
|
|
||||||
//if admin show button to delete (hide) ticker
|
|
||||||
$tickers_to_add .= short_text(strip_tags($news['body']), 100).'</div>
|
|
||||||
<div id="TickerEntry-'.$rows.'-FullText" class="NewsTickerFullText">';
|
|
||||||
//if admin show button to delete (hide) ticker
|
|
||||||
$tickers_to_add .= $news['body'] . $admin_options . '</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>';
|
|
||||||
$rows++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tickers_to_add = $twig->render('news.tickers.html.twig', array(
|
||||||
|
'tickers' => $tickers,
|
||||||
|
'canEdit' => $canEdit
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -240,30 +210,9 @@ else
|
|||||||
|
|
||||||
if(isset($tickers_to_add[0]))
|
if(isset($tickers_to_add[0]))
|
||||||
{
|
{
|
||||||
//show table with tickers
|
$tickers_content = $tickers_to_add;
|
||||||
$news_content = '<div id="newsticker" class="Box">
|
if($cache->enabled() && !$news_cached && !$canEdit)
|
||||||
<div class="Corner-tl" style="background-image: url('.$template_path.'/images/content/corner-tl.gif);"></div>
|
$cache->set('news_' . $template_name . '_' . TICKET, $tickers_to_add, 120);
|
||||||
<div class="Corner-tr" style="background-image: url('.$template_path.'/images/content/corner-tr.gif);"></div>
|
|
||||||
<div class="Border_1" style="background-image: url('.$template_path.'/images/content/border-1.gif);"></div>
|
|
||||||
<div class="BorderTitleText" style="background-image: url('.$template_path.'/images/content/title-background-green.gif);"></div>
|
|
||||||
<img class="Title" src="'.$template_path.'/images/header/headline-newsticker.gif" alt="Contentbox headline">
|
|
||||||
<div class="Border_2">
|
|
||||||
<div class="Border_3">
|
|
||||||
<div class="BoxContent" style="background-image: url('.$template_path.'/images/content/scroll.gif);">';
|
|
||||||
|
|
||||||
//add tickers list
|
|
||||||
$news_content .= $tickers_to_add;
|
|
||||||
//koniec
|
|
||||||
$news_content .= '</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="Border_1" style="background-image: url('.$template_path.'/images/content/border-1.gif);"></div>
|
|
||||||
<div class="CornerWrapper-b"><div class="Corner-bl" style="background-image: url('.$template_path.'/images/content/corner-bl.gif);"></div></div>
|
|
||||||
<div class="CornerWrapper-b"><div class="Corner-br" style="background-image: url('.$template_path.'/images/content/corner-br.gif);"></div></div>
|
|
||||||
</div>';
|
|
||||||
|
|
||||||
if($cache->enabled() && !$news_cached && !$canEdit)
|
|
||||||
$cache->set('news_' . $template_name . '_' . TICKET, $tickers_to_add, 120);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$news_cached)
|
if(!$news_cached)
|
||||||
@ -459,19 +408,4 @@ class News
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Forum
|
|
||||||
{
|
|
||||||
static public function add($title, $body, $section_id, $player_id, $account_id, &$errors)
|
|
||||||
{
|
|
||||||
global $db;
|
|
||||||
$thread_id = 0;
|
|
||||||
if($db->insert(TABLE_PREFIX . 'forum', array('first_post' => 0, 'last_post' => time(), 'section' => $section_id, 'replies' => 0, 'views' => 0, 'author_aid' => isset($account_id) ? $account_id : 0, 'author_guid' => isset($player_id) ? $player_id : 0, 'post_text' => $body, 'post_topic' => $title, 'post_smile' => 0, 'post_date' => time(), 'last_edit_aid' => 0, 'edit_date' => 0, 'post_ip' => $_SERVER['REMOTE_ADDR']))) {
|
|
||||||
$thread_id = $db->lastInsertId();
|
|
||||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $thread_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
13
system/templates/news.back_button.html.twig
Normal file
13
system/templates/news.back_button.html.twig
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<center>
|
||||||
|
<table cellspacing="0" cellpadding="0" border="0">
|
||||||
|
<form method="post" action="{{ getLink('news/archive') }}">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input width="120" height="18" border="0" type="image" src="{{ template_path }}/images/global/buttons/sbutton_back.gif" alt="Back" name="Back" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</form>
|
||||||
|
</table>
|
||||||
|
</center>
|
15
system/templates/news.tickers.html.twig
Normal file
15
system/templates/news.tickers.html.twig
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<table style="width: 100%">
|
||||||
|
<tr class="white" bgcolor="{{ config.vdarkborder }}">
|
||||||
|
<td colspan="3">Tickers</td>
|
||||||
|
</tr>
|
||||||
|
{% set i = 0 %}
|
||||||
|
{% for ticker in tickers %}
|
||||||
|
<tr bgcolor="{{ getStyle(i) }}">
|
||||||
|
<td style="width: 16px;"><img src="{{ template_path }}/images/news/icon_{{ ticker.icon }}_small.gif"/></td>
|
||||||
|
<td style="width: 80px;">{{ ticker.date|date("j M Y") }}</td>
|
||||||
|
<td>{{ ticker.body|raw }}</td>
|
||||||
|
</tr>
|
||||||
|
{% set i = i + 1 %}
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<br/>
|
@ -123,7 +123,7 @@ defined('MYAAC') or die('Direct access not allowed!');
|
|||||||
</table>
|
</table>
|
||||||
<hr noshade="noshade" size="1" />
|
<hr noshade="noshade" size="1" />
|
||||||
<div class="Content"><div id="ContentHelper">
|
<div class="Content"><div id="ContentHelper">
|
||||||
<?php echo template_place_holder('center_top') . $content; ?>
|
<?php echo tickers() . template_place_holder('center_top') . $content; ?>
|
||||||
</div></div>
|
</div></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -304,7 +304,7 @@ foreach($config['menu_categories'] as $id => $cat) { ?>
|
|||||||
<div id="ContentColumn">
|
<div id="ContentColumn">
|
||||||
<div class="Content">
|
<div class="Content">
|
||||||
<div id="ContentHelper">
|
<div id="ContentHelper">
|
||||||
<?php echo news_place(); ?>
|
<?php echo tickers(); ?>
|
||||||
|
|
||||||
|
|
||||||
<div id="<?php echo PAGE; ?>" class="Box">
|
<div id="<?php echo PAGE; ?>" class="Box">
|
||||||
|
46
templates/tibiacom/news.tickers.html.twig
Normal file
46
templates/tibiacom/news.tickers.html.twig
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<div id="newsticker" class="Box">
|
||||||
|
<div class="Corner-tl" style="background-image: url({{ template_path }}/images/content/corner-tl.gif);"></div>
|
||||||
|
<div class="Corner-tr" style="background-image: url({{ template_path }}/images/content/corner-tr.gif);"></div>
|
||||||
|
<div class="Border_1" style="background-image: url({{ template_path }}/images/content/border-1.gif);"></div>
|
||||||
|
<div class="BorderTitleText" style="background-image: url({{ template_path }}/images/content/title-background-green.gif);"></div>
|
||||||
|
<img class="Title" src="{{ template_path }}/images/header/headline-newsticker.gif" alt="Contentbox headline">
|
||||||
|
<div class="Border_2">
|
||||||
|
<div class="Border_3">
|
||||||
|
<div class="BoxContent" style="background-image: url({{ template_path }}/images/content/scroll.gif);">
|
||||||
|
{% set i = 0 %}
|
||||||
|
{% for ticker in tickers %}
|
||||||
|
<div id="TickerEntry-{{ i }}" class="Row" onclick='TickerAction("TickerEntry-{{ i }}")'>
|
||||||
|
<div class="{% if (i / 2) matches '/^\\d+$/' %}Odd{% else %}Even{% endif %}">
|
||||||
|
<div class="NewsTickerIcon" style="background-image: url({{ template_path }}/images/news/icon_{{ ticker.icon }}_small.gif);"></div>
|
||||||
|
<div id="TickerEntry-{{ i }}-Button" class="NewsTickerExtend" style="background-image: url({{ template_path }}/images/general/plus.gif);"></div>
|
||||||
|
<div class="NewsTickerText">
|
||||||
|
<span class="NewsTickerDate">{{ ticker.date|date("j M Y") }} -</span>
|
||||||
|
<div id="TickerEntry-{{ i }}-ShortText" class="NewsTickerShortText">{{ ticker.body_short|raw }}</div>
|
||||||
|
<div id="TickerEntry-{{ i }}-FullText" class="NewsTickerFullText">{{ ticker.body|raw }}
|
||||||
|
{% if canEdit %}
|
||||||
|
<a href="?subtopic=news&action=edit&id={{ ticker.id }}" title="Edit">
|
||||||
|
<img src="images/edit.png"/>
|
||||||
|
Edit
|
||||||
|
</a>
|
||||||
|
<a id="delete" href="?subtopic=news&action=delete&id={{ ticker.id }}" onclick="return confirm('Are you sure?');" title="Delete">
|
||||||
|
<img src="images/del.png"/>
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
<a href="?subtopic=news&action=hide&id={{ ticker.id }}" title="{% if ticker.hidden != 1 %}Hide{% else %}Show{% endif %}">
|
||||||
|
<img src="images/{% if ticker.hidden != 1 %}success{% else %}error{% endif %}.png"/>
|
||||||
|
{% if ticker.hidden != 1 %}Hide{% else %}Show{% endif %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% set i = i + 1 %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="Border_1" style="background-image: url({{ template_path }}/images/content/border-1.gif);"></div>
|
||||||
|
<div class="CornerWrapper-b"><div class="Corner-bl" style="background-image: url({{ template_path }}/images/content/corner-bl.gif);"></div></div>
|
||||||
|
<div class="CornerWrapper-b"><div class="Corner-br" style="background-image: url({{ template_path }}/images/content/corner-br.gif);"></div></div>
|
||||||
|
</div>
|
Loading…
x
Reference in New Issue
Block a user