diff --git a/system/pages/forum/edit_post.php b/system/pages/forum/edit_post.php
index 7edc2162..2bd01350 100644
--- a/system/pages/forum/edit_post.php
+++ b/system/pages/forum/edit_post.php
@@ -13,14 +13,20 @@ defined('MYAAC') or die('Direct access not allowed!');
if(Forum::canPost($account_logged))
{
- $post_id = (int) $_REQUEST['id'];
- $thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".(int) $post_id." LIMIT 1")->fetch();
+ $post_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : false;
+ if(!$post_id) {
+ echo 'Please enter post id.';
+ return;
+ }
+
+ $thread = $db->query("SELECT `" . TABLE_PREFIX . "forum`.`author_guid`, `" . TABLE_PREFIX . "forum`.`author_aid`, `" . TABLE_PREFIX . "forum`.`first_post`, `" . TABLE_PREFIX . "forum`.`post_topic`, `" . TABLE_PREFIX . "forum`.`post_date`, `" . TABLE_PREFIX . "forum`.`post_text`, `" . TABLE_PREFIX . "forum`.`post_smile`, `" . TABLE_PREFIX . "forum`.`id`, `" . TABLE_PREFIX . "forum`.`section` FROM `" . TABLE_PREFIX . "forum` WHERE `" . TABLE_PREFIX . "forum`.`id` = ".$post_id." LIMIT 1")->fetch();
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 'Boards >> '.$sections[$thread['section']]['name'].' >> '.$first_post['post_topic'].' >> Edit post';
if($account_logged->getId() == $thread['author_aid'] || Forum::isModerator())
{
+ $char_id = $post_topic = $text = $smile = null;
$players_from_account = $db->query("SELECT `players`.`name`, `players`.`id` FROM `players` WHERE `players`.`account_id` = ".(int) $account_logged->getId())->fetchAll();
$saved = false;
if(isset($_REQUEST['save']))
@@ -43,13 +49,16 @@ if(Forum::canPost($account_logged))
if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126)
$lenght++;
}
+
if($lenght < 1 || strlen($text) > 15000)
$errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.';
if($char_id == 0)
$errors[] = 'Please select a character.';
if(empty($post_topic) && $thread['id'] == $thread['first_post'])
$errors[] = 'Thread topic can\'t be empty.';
+
$player_on_account == false;
+
if(count($errors) == 0)
{
foreach($players_from_account as $player)
@@ -58,8 +67,8 @@ if(Forum::canPost($account_logged))
if(!$player_on_account)
$errors[] = 'Player with selected ID '.$char_id.' doesn\'t exist or isn\'t on your account';
}
- if(count($errors) == 0)
- {
+
+ if(count($errors) == 0) {
$saved = true;
if($account_logged->getId() != $thread['author_aid'])
$char_id = $thread['author_guid'];
@@ -70,41 +79,35 @@ if(Forum::canPost($account_logged))
echo '
Thank you for editing post.
GO BACK TO LAST THREAD';
}
}
- else
- {
+ else {
$text = $thread['post_text'];
$char_id = (int) $thread['author_guid'];
$post_topic = $thread['post_topic'];
$smile = (int) $thread['post_smile'];
}
+
if(!$saved)
{
if(!empty($errors))
echo $twig->render('error_box.html.twig', array('errors' => $errors));
- echo '
- |