mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-25 16:59:21 +02:00
* added new forum option: "Enable HTML"
* will be by default enabled for newses * fixed bbcode parsing
This commit is contained in:
parent
bf71c1aee8
commit
c133482659
@ -27,7 +27,7 @@ session_start();
|
||||
|
||||
define('MYAAC', true);
|
||||
define('MYAAC_VERSION', '0.8.0-dev');
|
||||
define('DATABASE_VERSION', 20);
|
||||
define('DATABASE_VERSION', 21);
|
||||
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'));
|
||||
|
@ -109,6 +109,7 @@ CREATE TABLE `myaac_forum`
|
||||
`post_text` text NOT NULL,
|
||||
`post_topic` varchar(255) NOT NULL DEFAULT '',
|
||||
`post_smile` tinyint(1) NOT NULL default '0',
|
||||
`post_html` tinyint(1) NOT NULL default '0',
|
||||
`post_date` int(20) NOT NULL default '0',
|
||||
`last_edit_aid` int(20) NOT NULL default '0',
|
||||
`edit_date` int(20) NOT NULL default '0',
|
||||
|
@ -37,7 +37,20 @@ class Forum
|
||||
{
|
||||
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']))) {
|
||||
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_html' => 1,
|
||||
'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);
|
||||
}
|
||||
@ -45,7 +58,7 @@ class Forum
|
||||
return $thread_id;
|
||||
}
|
||||
|
||||
static public function add_post($thread_id, $section, $author_aid, $author_guid, $post_text, $post_topic, $smile)
|
||||
static public function add_post($thread_id, $section, $author_aid, $author_guid, $post_text, $post_topic, $smile, $html)
|
||||
{
|
||||
global $db;
|
||||
$db->insert(TABLE_PREFIX . 'forum', array(
|
||||
@ -56,6 +69,7 @@ class Forum
|
||||
'post_text' => $post_text,
|
||||
'post_topic' => $post_topic,
|
||||
'post_smile' => $smile,
|
||||
'post_html' => $html,
|
||||
'post_date' => time(),
|
||||
'post_ip' => $_SERVER['REMOTE_ADDR']
|
||||
));
|
||||
@ -232,18 +246,18 @@ class Forum
|
||||
foreach($tags as $search => $replace)
|
||||
$text = preg_replace($search, $replace, $text);
|
||||
|
||||
return ($smiles == 0 ? Forum::parseSmiles($text) : $text);
|
||||
return ($smiles ? Forum::parseSmiles($text) : $text);
|
||||
}
|
||||
|
||||
public static function showPost($topic, $text, $smiles, $bb_code = true)
|
||||
public static function showPost($topic, $text, $smiles = true, $html = false)
|
||||
{
|
||||
if(!$bb_code) {
|
||||
if($html) {
|
||||
return '<b>' . $topic . '</b><hr />' . $text;
|
||||
}
|
||||
|
||||
$post = '';
|
||||
if(!empty($topic))
|
||||
$post .= '<b>'.($smiles == 0 ? self::parseSmiles($topic) : $topic).'</b><hr />';
|
||||
$post .= '<b>'.($smiles ? self::parseSmiles($topic) : $topic).'</b><hr />';
|
||||
|
||||
$post .= self::parseBBCode(nl2br($text), $smiles);
|
||||
return $post;
|
||||
|
14
system/migrations/21.php
Normal file
14
system/migrations/21.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
$db->query("ALTER TABLE `" . TABLE_PREFIX . "forum` ADD `post_html` TINYINT(1) NOT NULL DEFAULT 0 AFTER `post_smile`;");
|
||||
|
||||
$query = $db->query("SELECT `id` FROM `" . TABLE_PREFIX . "forum_boards` WHERE `name` LIKE " . $db->quote('News') . " LIMIT 1;");
|
||||
if($query->rowCount() == 0) {
|
||||
return; // don't make anything
|
||||
}
|
||||
|
||||
$query = $query->fetch();
|
||||
$id = $query['id'];
|
||||
|
||||
// update all forum threads with is_html = 1
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `post_html` = 1 WHERE `section` = " . $id . " AND `id` = `first_post`;");
|
@ -28,7 +28,7 @@ if(!$logged)
|
||||
|
||||
require_once(LIBS . 'forum.php');
|
||||
|
||||
$canEdit = hasFlag(FLAG_CONTENT_FORUM) || superAdmin();
|
||||
$canEdit = Forum::isModerator();
|
||||
if($canEdit)
|
||||
{
|
||||
$groups = new OTS_Groups_List();
|
||||
@ -172,7 +172,7 @@ if(empty($action))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$errors = array();
|
||||
if($action == 'show_board' || $action == 'show_thread')
|
||||
{
|
||||
require(PAGES . 'forum/' . $action . '.php');
|
||||
|
@ -18,14 +18,14 @@ if(Forum::canPost($account_logged))
|
||||
return;
|
||||
}
|
||||
|
||||
$thread = $db->query("SELECT `author_guid`, `author_aid`, `first_post`, `post_topic`, `post_date`, `post_text`, `post_smile`, `id`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post_id." LIMIT 1")->fetch();
|
||||
$thread = $db->query("SELECT `author_guid`, `author_aid`, `first_post`, `post_topic`, `post_date`, `post_text`, `post_smile`, `post_html`, `id`, `section` FROM `" . TABLE_PREFIX . "forum` WHERE `id` = ".$post_id." LIMIT 1")->fetch();
|
||||
if(isset($thread['id']))
|
||||
{
|
||||
$first_post = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $thread['first_post']." LIMIT 1")->fetch();
|
||||
echo '<a href="' . getLink('forum') . '">Boards</a> >> <a href="' . getForumBoardLink($thread['section']) . '">'.$sections[$thread['section']]['name'].'</a> >> <a href="' . getForumThreadLink($thread['first_post']) . '">'.$first_post['post_topic'].'</a> >> <b>Edit post</b>';
|
||||
if(Forum::hasAccess($thread['section'] && ($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())))
|
||||
{
|
||||
$char_id = $post_topic = $text = $smile = null;
|
||||
$char_id = $post_topic = $text = $smile = $html = null;
|
||||
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
|
||||
$saved = false;
|
||||
if(isset($_REQUEST['save']))
|
||||
@ -33,9 +33,10 @@ if(Forum::canPost($account_logged))
|
||||
$text = stripslashes(trim($_REQUEST['text']));
|
||||
$char_id = (int) $_REQUEST['char_id'];
|
||||
$post_topic = stripslashes(trim($_REQUEST['topic']));
|
||||
$smile = (int) $_REQUEST['smile'];
|
||||
$smile = isset($_REQUEST['smile']) ? (int)$_REQUEST['smile'] : 0;
|
||||
$html = isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0;
|
||||
$lenght = 0;
|
||||
for($i = 0; $i <= strlen($post_topic); $i++)
|
||||
for($i = 0; $i < strlen($post_topic); $i++)
|
||||
{
|
||||
if(ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126)
|
||||
$lenght++;
|
||||
@ -43,12 +44,11 @@ if(Forum::canPost($account_logged))
|
||||
if(($lenght < 1 || strlen($post_topic) > 60) && $thread['id'] == $thread['first_post'])
|
||||
$errors[] = 'Too short or too long topic (short: '.$lenght.' long: '.strlen($post_topic).' letters). Minimum 1 letter, maximum 60 letters.';
|
||||
$lenght = 0;
|
||||
for($i = 0; $i <= strlen($text); $i++)
|
||||
for($i = 0; $i < strlen($text); $i++)
|
||||
{
|
||||
if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
|
||||
$lenght++;
|
||||
}
|
||||
|
||||
if($lenght < 1 || strlen($text) > 15000)
|
||||
$errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
|
||||
if($char_id == 0)
|
||||
@ -56,7 +56,7 @@ if(Forum::canPost($account_logged))
|
||||
if(empty($post_topic) && $thread['id'] == $thread['first_post'])
|
||||
$errors[] = 'Thread topic can\'t be empty.';
|
||||
|
||||
$player_on_account == false;
|
||||
$player_on_account = false;
|
||||
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
@ -71,7 +71,7 @@ if(Forum::canPost($account_logged))
|
||||
$saved = true;
|
||||
if($account_logged->getId() != $thread['author_aid'])
|
||||
$char_id = $thread['author_guid'];
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `author_guid` = ".(int) $char_id.", `post_text` = ".$db->quote($text).", `post_topic` = ".$db->quote($post_topic).", `post_smile` = ".(int) $smile.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']);
|
||||
$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` = ".$smile.", `post_html` = ".$html.", `last_edit_aid` = ".(int) $account_logged->getId().",`edit_date` = ".time()." WHERE `id` = ".(int) $thread['id']);
|
||||
$post_page = $db->query("SELECT COUNT(`" . TABLE_PREFIX . "forum`.`id`) AS posts_count FROM `players`, `" . TABLE_PREFIX . "forum` WHERE `players`.`id` = `" . TABLE_PREFIX . "forum`.`author_guid` AND `" . TABLE_PREFIX . "forum`.`post_date` <= ".$thread['post_date']." AND `" . TABLE_PREFIX . "forum`.`first_post` = ".(int) $thread['first_post'])->fetch();
|
||||
$_page = (int) ceil($post_page['posts_count'] / $config['forum_threads_per_page']) - 1;
|
||||
header('Location: ' . getForumThreadLink($thread['first_post'], $_page));
|
||||
@ -83,6 +83,7 @@ if(Forum::canPost($account_logged))
|
||||
$char_id = (int) $thread['author_guid'];
|
||||
$post_topic = $thread['post_topic'];
|
||||
$smile = (int) $thread['post_smile'];
|
||||
$html = (int) $thread['post_html'];
|
||||
}
|
||||
|
||||
if(!$saved)
|
||||
@ -94,9 +95,12 @@ if(Forum::canPost($account_logged))
|
||||
'post_id' => $post_id,
|
||||
'players' => $players_from_account,
|
||||
'player_id' => $char_id,
|
||||
'topic' => htmlspecialchars($post_topic),
|
||||
'text' => htmlspecialchars($text),
|
||||
'smile' => $smile
|
||||
'post_topic' => $canEdit ? $post_topic : htmlspecialchars($post_topic),
|
||||
'post_text' => $canEdit ? $text : htmlspecialchars($text),
|
||||
'post_smile' => $smile > 0,
|
||||
'post_html' => $html > 0,
|
||||
'html' => $html,
|
||||
'canEdit' => $canEdit
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ if(Forum::canPost($account_logged))
|
||||
$text = isset($_REQUEST['text']) ? stripslashes(trim($_REQUEST['text'])) : NULL;
|
||||
$char_id = (int) (isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
|
||||
$post_topic = isset($_REQUEST['topic']) ? stripslashes(trim($_REQUEST['topic'])) : '';
|
||||
$smile = (int) (isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
|
||||
$smile = (isset($_REQUEST['smile']) ? (int)$_REQUEST['smile'] : 0);
|
||||
$html = (isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0);
|
||||
$saved = false;
|
||||
if(isset($_REQUEST['quote']))
|
||||
{
|
||||
@ -72,7 +73,7 @@ if(Forum::canPost($account_logged))
|
||||
if(count($errors) == 0)
|
||||
{
|
||||
$saved = true;
|
||||
Forum::add_post($thread['id'], $thread['section'], $account_logged->getId(), (int) $char_id, $text, $post_topic, (int) $smile, time(), $_SERVER['REMOTE_ADDR']);
|
||||
Forum::add_post($thread['id'], $thread['section'], $account_logged->getId(), (int) $char_id, $text, $post_topic, $smile, $html, 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;
|
||||
@ -86,15 +87,12 @@ if(Forum::canPost($account_logged))
|
||||
if(!empty($errors))
|
||||
echo $twig->render('error_box.html.twig', array('errors' => $errors));
|
||||
|
||||
$threads = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`author_aid` 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();
|
||||
$threads = $db->query("SELECT `players`.`name`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`post_html`, `" . TABLE_PREFIX . "forum`.`author_aid` 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) {
|
||||
$player_account = new OTS_Account();
|
||||
$player_account->load($thread['author_aid']);
|
||||
if($player_account->isLoaded()) {
|
||||
// check if its news written in tinymce
|
||||
$hasAccess = $player_account->hasFlag(FLAG_CONTENT_NEWS) || $player_account->isSuperAdmin();
|
||||
$bb_code = ($thread['post_text'] == strip_tags($thread['post_text'])) || !$hasAccess;
|
||||
$thread['post'] = Forum::showPost(($hasAccess ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($hasAccess ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile'], $bb_code);
|
||||
$thread['post'] = Forum::showPost(($thread['post_html'] > 0 ? $thread['post_topic'] : htmlspecialchars($thread['post_topic'])), ($thread['post_html'] > 0 ? $thread['post_text'] : htmlspecialchars($thread['post_text'])), $thread['post_smile'] == 0, $thread['post_html'] > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +102,11 @@ if(Forum::canPost($account_logged))
|
||||
'players' => $players_from_account,
|
||||
'post_topic' => $post_topic,
|
||||
'post_text' => $text,
|
||||
'post_smile' => $smile,
|
||||
'post_smile' => $smile > 0,
|
||||
'post_html' => $html > 0,
|
||||
'topic' => $thread['post_topic'],
|
||||
'threads' => $threads
|
||||
'threads' => $threads,
|
||||
'canEdit' => $canEdit
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ if(Forum::canPost($account_logged))
|
||||
$text = isset($_REQUEST['text']) ? stripslashes($_REQUEST['text']) : '';
|
||||
$char_id = (int)(isset($_REQUEST['char_id']) ? $_REQUEST['char_id'] : 0);
|
||||
$post_topic = isset($_REQUEST['topic']) ? stripslashes($_REQUEST['topic']) : '';
|
||||
$smile = (int)(isset($_REQUEST['smile']) ? $_REQUEST['smile'] : 0);
|
||||
$smile = (isset($_REQUEST['smile']) ? (int)$_REQUEST['smile'] : 0);
|
||||
$html = (isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0);
|
||||
$saved = false;
|
||||
if (isset($_REQUEST['save'])) {
|
||||
$errors = array();
|
||||
@ -68,7 +69,7 @@ if(Forum::canPost($account_logged))
|
||||
}
|
||||
if (count($errors) == 0) {
|
||||
$saved = true;
|
||||
$db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
|
||||
$db->query("INSERT INTO `" . TABLE_PREFIX . "forum` (`first_post` ,`last_post` ,`section` ,`replies` ,`views` ,`author_aid` ,`author_guid` ,`post_text` ,`post_topic` ,`post_smile`, `post_html` ,`post_date` ,`last_edit_aid` ,`edit_date`, `post_ip`) VALUES ('0', '" . time() . "', '" . (int)$section_id . "', '0', '0', '" . $account_logged->getId() . "', '" . (int)$char_id . "', " . $db->quote($text) . ", " . $db->quote($post_topic) . ", '" . (int)$smile . "', '" . (int)$html . "', '" . time() . "', '0', '0', '" . $_SERVER['REMOTE_ADDR'] . "')");
|
||||
$thread_id = $db->lastInsertId();
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `first_post`=" . (int)$thread_id . " WHERE `id` = " . (int)$thread_id);
|
||||
header('Location: ' . getForumThreadLink($thread_id));
|
||||
@ -85,8 +86,10 @@ if(Forum::canPost($account_logged))
|
||||
'players' => $players_from_account,
|
||||
'post_player_id' => $char_id,
|
||||
'post_thread' => $post_topic,
|
||||
'text' => $text,
|
||||
'smiles_enabled' => $smile > 0
|
||||
'post_text' => $text,
|
||||
'post_smile' => $smile > 0,
|
||||
'post_html' => $html > 0,
|
||||
'canEdit' => $canEdit
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ for($i = 0; $i < $posts_count['posts_count'] / $config['forum_threads_per_page']
|
||||
else
|
||||
$links_to_pages .= '<b>'.($i + 1).' </b>';
|
||||
}
|
||||
$posts = $db->query("SELECT `players`.`id` as `player_id`, `" . 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` AS `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();
|
||||
$posts = $db->query("SELECT `players`.`id` as `player_id`, `" . 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` AS `date`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`post_html`, `" . 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($posts[0]['player_id'])) {
|
||||
$db->query("UPDATE `" . TABLE_PREFIX . "forum` SET `views`=`views`+1 WHERE `id` = ".(int) $thread_id);
|
||||
}
|
||||
@ -72,13 +72,9 @@ foreach($posts as &$post)
|
||||
if($guild->isLoaded())
|
||||
$post['guildRank'] = $rank->getName().' of <a href="'.getGuildLink($guild->getName(), false).'">'.$guild->getName().'</a>';
|
||||
}
|
||||
$player_account = $player->getAccount();
|
||||
$canEditForum = $player_account->hasFlag(FLAG_CONTENT_FORUM) || $player_account->isAdmin();
|
||||
|
||||
// check if its news written in tinymce
|
||||
$bb_code = ($post['post_text'] == strip_tags($post['post_text'])) || (!$player_account->hasFlag(FLAG_CONTENT_NEWS) && !$player_account->isSuperAdmin());
|
||||
|
||||
$post['content'] = Forum::showPost(($canEditForum ? $post['post_topic'] : htmlspecialchars($post['post_topic'])), ($canEditForum ? $post['post_text'] : htmlspecialchars($post['post_text'])), $post['post_smile'], $bb_code);
|
||||
$player_account = $player->getAccount();
|
||||
$post['content'] = Forum::showPost(($post['post_html'] > 0 ? $post['post_topic'] : htmlspecialchars($post['post_topic'])), ($post['post_html'] > 0 ? $post['post_text'] : htmlspecialchars($post['post_text'])), $post['post_smile'] == 0, $post['post_html'] > 0);
|
||||
|
||||
$query = $db->query("SELECT COUNT(`id`) AS 'posts' FROM `" . TABLE_PREFIX . "forum` WHERE `author_aid`=".(int) $player_account->getId())->fetch();
|
||||
$post['author_posts_count'] = (int)$query['posts'];
|
||||
|
@ -22,21 +22,27 @@
|
||||
</tr>
|
||||
<tr bgcolor="{{ config.lightborder }}">
|
||||
<td><b>Topic:</b></td>
|
||||
<td><input type="text" value="{{ topic|raw }}" name="topic" size="40" maxlength="60" /> (Optional)</td>
|
||||
<td><input type="text" value="{{ post_topic|raw }}" name="topic" size="40" maxlength="60" /> (Optional)</td>
|
||||
</tr>
|
||||
<tr bgcolor="{{ config.darkborder }}">
|
||||
<td valign="top"><b>Message:</b><font size="1"><br/>You can use:<br/>[player]Nick[/player]<br />[url]http://address.com/[/url]<br />[img]http://images.com/images3.gif[/img]<br />[code]Code[/code]<br />[b]<b>Text</b>[/b]<br />[i]<i>Text</i>[/i]<br/>[u]<u>Text</u>[/u]<br />and smileys:<br />;) , :) , :D , :( , :rolleyes:<br />:cool: , :eek: , :o , :p</font>
|
||||
</td>
|
||||
<td>
|
||||
<textarea rows="10" cols="60" name="text">{{ text|raw }}</textarea><br />(Max. 15,000 letters)
|
||||
<textarea rows="10" cols="60" name="text">{{ post_text|raw }}</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 %} checked="checked"{% endif %}/>Disable Smileys in This Post
|
||||
<input type="checkbox" name="smile" value="1"{% if post_smile %} checked="checked"{% endif %}/>Disable Smileys in This Post
|
||||
</label>
|
||||
{% if canEdit %}
|
||||
<br/>
|
||||
<label>
|
||||
<input type="checkbox" name="html" value="1"{% if post_html %} checked="checked"{% endif %}/>Enable HTML in this post (moderator only)
|
||||
</label>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -28,7 +28,17 @@
|
||||
</tr>
|
||||
<tr bgcolor="{{ config.lightborder }}">
|
||||
<td valign="top">Options:</td>
|
||||
<td><label><input type="checkbox" name="smile" value="1"{% if post_smile == 1 %} checked="checked"{% endif %}/>Disable Smileys in This Post </label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="smile" value="1"{% if post_smile %} checked="checked"{% endif %}/>Disable Smileys in This Post
|
||||
</label>
|
||||
{% if canEdit %}
|
||||
<br/>
|
||||
<label>
|
||||
<input type="checkbox" name="html" value="1"{% if post_html %} checked="checked"{% endif %}/>Enable HTML in this post (moderator only)
|
||||
</label>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<center>
|
||||
|
@ -25,11 +25,21 @@
|
||||
</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">{{ text|escape }}</textarea><br />(Max. 15,000 letters)</td>
|
||||
<td><textarea rows="10" cols="60" name="text">{{ post_text|escape }}</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 smiles_enabled %} checked="checked"{% endif %}/>Disable Smileys in This Post </label></td>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="smile" value="1"{% if post_smile %} checked="checked"{% endif %}/>Disable Smileys in This Post
|
||||
</label>
|
||||
{% if canEdit %}
|
||||
<br/>
|
||||
<label>
|
||||
<input type="checkbox" name="html" value="1"{% if post_html %} checked="checked"{% endif %}/>Enable HTML in this post (moderator only)
|
||||
</label>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<center>
|
||||
|
Loading…
x
Reference in New Issue
Block a user