'f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.first_post_id, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies', 'FROM' => 'posts AS p', 'JOINS' => array( array( 'INNER JOIN' => 'topics AS t', 'ON' => 't.id=p.topic_id' ), array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ), array( 'LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')' ) ), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id ); ($hook = get_hook('ed_qr_get_post_info')) ? eval($hook) : null; $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); if (!$forum_db->num_rows($result)) message($lang_common['Bad request']); $cur_post = $forum_db->fetch_assoc($result); // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = ($cur_post['moderators'] != '') ? unserialize($cur_post['moderators']) : array(); $forum_page['is_admmod'] = ($forum_user['g_id'] == FORUM_ADMIN || ($forum_user['g_moderator'] == '1' && array_key_exists($forum_user['username'], $mods_array))) ? true : false; ($hook = get_hook('ed_pre_permission_check')) ? eval($hook) : null; // Do we have permission to edit this post? if (($forum_user['g_edit_posts'] == '0' || $cur_post['poster_id'] != $forum_user['id'] || $cur_post['closed'] == '1') && !$forum_page['is_admmod']) message($lang_common['No permission']); $can_edit_subject = $id == $cur_post['first_post_id']; ($hook = get_hook('ed_post_selected')) ? eval($hook) : null; // Start with a clean slate $errors = array(); if (isset($_POST['form_sent'])) { ($hook = get_hook('ed_form_submitted')) ? eval($hook) : null; // If it is a topic it must contain a subject if ($can_edit_subject) { $subject = forum_trim($_POST['req_subject']); if ($subject == '') $errors[] = $lang_post['No subject']; else if (utf8_strlen($subject) > 70) $errors[] = $lang_post['Too long subject']; else if ($forum_config['p_subject_all_caps'] == '0' && utf8_strtoupper($subject) == $subject && !$forum_page['is_admmod']) $subject = utf8_ucwords(utf8_strtolower($subject)); } // Clean up message from POST $message = forum_linebreaks(forum_trim($_POST['req_message'])); if (strlen($message) > FORUM_MAX_POSTSIZE_BYTES) $errors[] = sprintf($lang_post['Too long message'], forum_number_format(strlen($message)), forum_number_format(FORUM_MAX_POSTSIZE_BYTES)); else if ($forum_config['p_message_all_caps'] == '0' && utf8_strtoupper($message) == $message && !$forum_page['is_admmod']) $message = utf8_ucwords(utf8_strtolower($message)); // Validate BBCode syntax if ($forum_config['p_message_bbcode'] == '1' || $forum_config['o_make_links'] == '1') { if (!defined('FORUM_PARSER_LOADED')) require FORUM_ROOT.'include/parser.php'; $message = preparse_bbcode($message, $errors); } if ($message == '') $errors[] = $lang_post['No message']; $hide_smilies = isset($_POST['hide_smilies']) ? 1 : 0; ($hook = get_hook('ed_end_validation')) ? eval($hook) : null; // Did everything go according to plan? if (empty($errors) && !isset($_POST['preview'])) { ($hook = get_hook('ed_pre_post_edited')) ? eval($hook) : null; if (!defined('FORUM_SEARCH_IDX_FUNCTIONS_LOADED')) require FORUM_ROOT.'include/search_idx.php'; if ($can_edit_subject) { // Update the topic and any redirect topics $query = array( 'UPDATE' => 'topics', 'SET' => 'subject=\''.$forum_db->escape($subject).'\'', 'WHERE' => 'id='.$cur_post['tid'].' OR moved_to='.$cur_post['tid'] ); ($hook = get_hook('ed_qr_update_subject')) ? eval($hook) : null; $forum_db->query_build($query) or error(__FILE__, __LINE__); // We changed the subject, so we need to take that into account when we update the search words update_search_index('edit', $id, $message, $subject); } else update_search_index('edit', $id, $message); // Update the post $query = array( 'UPDATE' => 'posts', 'SET' => 'message=\''.$forum_db->escape($message).'\', hide_smilies=\''.$hide_smilies.'\'', 'WHERE' => 'id='.$id ); if (!isset($_POST['silent']) || !$forum_page['is_admmod']) $query['SET'] .= ', edited='.time().', edited_by=\''.$forum_db->escape($forum_user['username']).'\''; ($hook = get_hook('ed_qr_update_post')) ? eval($hook) : null; $forum_db->query_build($query) or error(__FILE__, __LINE__); ($hook = get_hook('ed_pre_redirect')) ? eval($hook) : null; redirect(forum_link($forum_url['post'], $id), $lang_post['Edit redirect']); } } // Setup error messages if (!empty($errors)) { $forum_page['errors'] = array(); foreach ($errors as $cur_error) $forum_page['errors'][] = '
  • '.$cur_error.'
  • '; } // Setup form $forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0; $forum_page['form_action'] = forum_link($forum_url['edit'], $id); $forum_page['form_attributes'] = array(); $forum_page['hidden_fields'] = array( 'form_sent' => '', 'csrf_token' => '' ); // Setup help $forum_page['main_head_options'] = array(); if ($forum_config['p_message_bbcode'] == '1') $forum_page['text_options']['bbcode'] = ''.$lang_common['BBCode'].''; if ($forum_config['p_message_img_tag'] == '1') $forum_page['text_options']['img'] = ''.$lang_common['Images'].''; if ($forum_config['o_smilies'] == '1') $forum_page['text_options']['smilies'] = ''.$lang_common['Smilies'].''; // Setup breadcrumbs $forum_page['crumbs'] = array( array($forum_config['o_board_title'], forum_link($forum_url['index'])), array($cur_post['forum_name'], forum_link($forum_url['forum'], array($cur_post['fid'], sef_friendly($cur_post['forum_name'])))), array($cur_post['subject'], forum_link($forum_url['topic'], array($cur_post['tid'], sef_friendly($cur_post['subject'])))), (($id == $cur_post['first_post_id']) ? $lang_post['Edit topic'] : $lang_post['Edit reply']) ); ($hook = get_hook('ed_pre_header_load')) ? eval($hook) : null; define('FORUM_PAGE', 'postedit'); require FORUM_ROOT.'header.php'; // START SUBST - ob_start(); ($hook = get_hook('ed_main_output_start')) ? eval($hook) : null; ?>

    #'; $forum_page['post_ident']['byline'] = ''; $forum_page['post_ident']['link'] = ''.format_time(time()).''; $forum_page['preview_message'] = parse_message($message, $hide_smilies); ($hook = get_hook('ed_preview_pre_display')) ? eval($hook) : null; ?>

    '.sprintf($lang_common['You may use'], implode(' ', $forum_page['text_options'])).'

    '."\n"; // If there were any errors, show them if (isset($forum_page['errors'])) { ?>

    '.$lang_common['Required'].'') ?>

    >

    '; else $forum_page['checkboxes']['hide_smilies'] = '
    '; } if ($forum_page['is_admmod']) { if ((isset($_POST['form_sent']) && isset($_POST['silent'])) || !isset($_POST['form_sent'])) $forum_page['checkboxes']['silent'] = '
    '; else $forum_page['checkboxes']['silent'] = '
    '; } ($hook = get_hook('ed_pre_checkbox_display')) ? eval($hook) : null; if (!empty($forum_page['checkboxes'])) { ?>
    ', $tpl_temp, $tpl_main); ob_end_clean(); // END SUBST - require FORUM_ROOT.'footer.php';