Esempio n. 1
0
		$subject = ($post_data['first_post']) ? $post_info['topic_title'] : $post_info['post_subject'];
		$message = $post_info['post_text'];
		if ($mode == 'editpost')
		{
			$topic_desc = '';
			$topic_title_clean = '';
			$topic_tags = '';
			if ($post_data['first_post'])
			{
				$topic_desc = $post_info['topic_desc'];

				$topic_title_clean = (empty($post_info['topic_title_clean']) ? $subject : $post_info['topic_title_clean']);
				$topic_title_clean = substr(ip_clean_string($topic_title_clean, $lang['ENCODING']), 0, 254);

				@include_once(IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
				$class_topics_tags = new class_topics_tags();
				$topic_tags = (empty($post_info['topic_tags']) ? '' : $post_info['topic_tags']);
				if (!empty($topic_tags))
				{
					$topic_tags_array = $class_topics_tags->create_tags_array($topic_tags);
					$topic_tags = implode(', ', array_filter(array_unique($topic_tags_array)));
					$topic_tags = substr($topic_tags, 0, 254);
				}
				unset($class_topics_tags);
			}

			$attach_sig = ($post_info['enable_sig'] && $post_info['user_sig'] != '') ? 1 : 0;
			$user_sig = $post_info['user_sig'];

			$topic_show_portal = ($post_info['topic_show_portal']) ? 1 : 0;
			$html_on = ($post_info['enable_html']) ? 1 : 0;
Esempio n. 2
0
$cms_page['page_id'] = 'tags';
$cms_page['page_nav'] = (isset($cms_config_layouts[$cms_page['page_id']]['page_nav']) ? $cms_config_layouts[$cms_page['page_id']]['page_nav'] : true);
$cms_page['global_blocks'] = (!empty($cms_config_layouts[$cms_page['page_id']]['global_blocks']) ? true : false);
$cms_auth_level = (isset($cms_config_layouts[$cms_page['page_id']]['view']) ? $cms_config_layouts[$cms_page['page_id']]['view'] : AUTH_ALL);
check_page_auth($cms_page['page_id'], $cms_auth_level);
// CMS - END

// COMMON - BEGIN
@include_once(IP_ROOT_PATH . 'includes/class_form.' . PHP_EXT);
$class_form = new class_form();

@include_once(IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT);
$class_topics = new class_topics();

@include_once(IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
$class_topics_tags = new class_topics_tags();
// COMMON - END

// CONFIG - BEGIN
$table_fields = array(
	'tag_count' => array('lang_key' => 'TAG_COUNT', 'view_level' => AUTH_ALL),
	'tag_text' => array('lang_key' => 'TAG_TEXT', 'view_level' => AUTH_ALL),
);
// CONFIG - END

// VARS - BEGIN
$tag_id = request_var('tag_id', 0);
$tag_id = ($tag_id < 0) ? 0 : $tag_id;

$tag_text = request_var('tag_text', '', true);
$tag_text = ip_clean_string(urldecode(trim($tag_text)), $lang['ENCODING'], true);
Esempio n. 3
0
 /**
  * prepares a list of articles.
  *
  * @param integer (optional) the article id to the article to be displayed.
  *
  * @return void
  *
  * @access private
  */
 function prepareArticles($articles, $show_abstract = false, $show_attachments = true)
 {
     global $lang, $config, $images, $is_auth, $theme, $user, $block_id, $cms_config_var;
     if (isset($cms_config_var['md_news_length'])) {
         $news_trim = $cms_config_var['md_news_length'];
     } else {
         $news_trim = $this->config['news_item_trim'];
     }
     if (is_array($articles)) {
         if ($config['display_tags_box']) {
             @(include_once IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
             $class_topics_tags = new class_topics_tags();
         }
         foreach ($articles as $article) {
             $trimmed = false;
             // Trim the post body if needed.
             if ($show_abstract && $news_trim > 0) {
                 $article['post_abstract'] = $this->trimText($article['post_text'], $news_trim, $trimmed);
                 $article['post_abstract'] = $this->parseMessage($article['post_abstract'] . ' ... ', $article['enable_bbcode'], $article['enable_html'], $article['enable_smilies'], $article['enable_autolinks_acronyms']);
             }
             $article['post_text'] = $this->parseMessage($article['post_text'], $article['enable_bbcode'], $article['enable_html'], $article['enable_smilies'], $article['enable_autolinks_acronyms']);
             if ($show_attachments == true) {
                 init_display_post_attachments($article['topic_attachment'], $article, false, $block_id);
             }
             $sql = '';
             $dateformat = $user->data['user_id'] == ANONYMOUS ? $config['default_dateformat'] : $user->data['user_dateformat'];
             $timezone = $user->data['user_id'] == ANONYMOUS ? $config['board_timezone'] : $user->data['user_timezone'];
             $this->setVariables(array('L_REPLIES' => $lang['Replies'], 'L_REPLY_NEWS' => $lang['News_Reply'], 'L_PRINT_NEWS' => $lang['News_Print'], 'L_EMAIL_NEWS' => $lang['News_Email'], 'MINIPOST_IMG' => $images['icon_minipost'], 'NEWS_REPLY_IMG' => $images['news_reply'], 'NEWS_PRINT_IMG' => $images['news_print'], 'NEWS_EMAIL_IMG' => $images['news_email']));
             //$index_file = CMS_PAGE_HOME;
             $index_file = !empty($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : getenv('SCRIPT_NAME');
             //$page_query = $_SERVER['QUERY_STRING'];
             //$page_query = (!empty($_SERVER['QUERY_STRING'])) ? explode('&', $_SERVER['QUERY_STRING']) : explode('&', getenv('QUERY_STRING'));
             if ($this->config['news_base_url'] != '') {
                 $index_file = $this->config['news_base_url'] . $index_file;
             }
             $index_file = htmlspecialchars(urldecode($index_file));
             $portal_page_id = request_var('page', 0);
             $portal_page_id = !empty($portal_page_id) ? 'page=' . $portal_page_id . '&amp;' : '';
             $ubid_link = request_var('ubid', 0);
             $ubid_link = !empty($ubid_link) ? 'ubid=' . $ubid_link . '&amp;' : '';
             $format = 'r';
             $gmepoch = $article['post_time'];
             $tz = $timezone;
             $news_dst_sec = get_dst($gmepoch, $tz);
             $news_date = @gmdate($format, $gmepoch + 3600 * $tz + $news_dst_sec);
             $topic_tags_links = '';
             $topic_tags_display = false;
             if ($config['display_tags_box']) {
                 $topic_id = $article['topic_id'];
                 $topic_tags_links = $class_topics_tags->build_tags_list(array($topic_id));
                 $topic_tags_display = !empty($topic_tags_links) ? true : false;
             }
             // Convert and clean special chars!
             $topic_title = htmlspecialchars_clean($article['topic_title']);
             $this->setBlockVariables('articles', array('L_TITLE' => $topic_title, 'ID' => $article['topic_id'], 'KEY' => !empty($article['article_key']) ? $article['article_key'] : '', 'DAY' => $this->getDay($article['topic_time']), 'MONTH' => $this->getMonth($article['topic_time']), 'YEAR' => $this->getYear($article['topic_time']), 'CATEGORY' => $article['news_category'], 'CAT_ID' => $article['news_id'], 'COUNT_VIEWS' => $article['topic_views'], 'CAT_IMG' => $article['news_image'] ? $this->root_path . $config['news_path'] . '/' . $article['news_image'] : '', 'POST_DATE' => create_date_ip($dateformat, $article['post_time'], $timezone, true), 'RFC_POST_DATE' => $news_date, 'L_POSTER' => colorize_username($article['user_id'], $article['username'], $article['user_color'], $article['user_active']), 'L_COMMENTS' => $article['topic_replies'], 'S_TOPIC_TAGS' => $topic_tags_display, 'TOPIC_TAGS' => $topic_tags_links, 'U_COMMENTS' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $article['forum_id'] . '&amp;' . POST_TOPIC_URL . '=' . $article['topic_id']), 'U_COMMENT' => append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_FORUM_URL . '=' . $article['forum_id'] . '&amp;' . POST_TOPIC_URL . '=' . $article['topic_id']), 'U_VIEWS' => append_sid('topic_view_users.' . PHP_EXT . '?' . POST_TOPIC_URL . '=' . $article['topic_id']), 'U_POST_COMMENT' => append_sid('posting.' . PHP_EXT . '?mode=reply&amp;' . POST_FORUM_URL . '=' . $article['forum_id'] . '&amp;' . POST_TOPIC_URL . '=' . $article['topic_id']), 'U_PRINT_TOPIC' => append_sid('printview.' . PHP_EXT . '?' . POST_FORUM_URL . '=' . $article['forum_id'] . '&amp;' . POST_TOPIC_URL . '=' . $article['topic_id'] . '&amp;start=0'), 'U_EMAIL_TOPIC' => append_sid('tellafriend.' . PHP_EXT . '?topic_title=' . urlencode(ip_utf8_decode($article['topic_title'])) . '&amp;topic_id=' . $article['topic_id']), 'L_TITLE_HTML' => urlencode(ip_utf8_decode($article['topic_title'])), 'COUNT_COMMENTS' => $article['topic_replies'], 'BODY' => $show_abstract && $trimmed ? $article['post_abstract'] : $article['post_text'], 'READ_MORE_LINK' => $show_abstract && $trimmed ? '<a href="' . $index_file . '?' . $portal_page_id . $ubid_link . 'topic_id=' . $article['topic_id'] . '">' . $lang['Read_More'] . '</a>' : ''));
             if ($show_attachments) {
                 display_attachments($article['post_id'], 'articles');
             }
             $post_id = $article['post_id'];
         }
     }
     if (sizeof($articles) == 0) {
         $this->setBlockVariables('no_articles', array('L_NO_NEWS' => $lang['No_articles']));
     }
 }
Esempio n. 4
0
 /**
  * Merge topic(s)
  */
 function topic_merge($topics, $new_topic_id, $forum_id)
 {
     global $db, $cache, $config, $user, $lang;
     $topics_ids = array();
     for ($i = 0; $i < sizeof($topics); $i++) {
         if ($topics[$i] != $new_topic_id) {
             $topics_ids[] = $topics[$i];
         }
     }
     $db->sql_transaction('begin');
     $sql = "UPDATE " . POSTS_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $result = $db->sql_query($sql);
     // UPI2DB - BEGIN
     $sql = "UPDATE " . UPI2DB_ALWAYS_READ_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     $sql = "UPDATE " . UPI2DB_UNREAD_POSTS_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     $sql = "UPDATE " . UPI2DB_LAST_POSTS_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     // UPI2DB - END
     $sql = "DELETE FROM " . TOPICS_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $result = $db->sql_query($sql);
     $sql = "DELETE FROM  " . TOPICS_WATCH_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $result = $db->sql_query($sql);
     $sql = "DELETE FROM " . BOOKMARK_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     $sql = "DELETE FROM " . RATINGS_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     $sql = "DELETE FROM " . TOPIC_VIEW_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     $sql = "UPDATE " . DRAFTS_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     $sql = "UPDATE " . POSTS_LIKES_TABLE . "\n\t\t\tSET topic_id = '" . $new_topic_id . "'\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     $sql = "DELETE FROM " . REGISTRATION_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     $sql = "DELETE FROM " . REGISTRATION_DESC_TABLE . "\n\t\t\tWHERE " . $db->sql_in_set('topic_id', $topics_ids);
     $db->sql_query($sql);
     // TAGS - BEGIN
     @(include_once IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
     $class_topics_tags = new class_topics_tags();
     $tags = $class_topics_tags->get_topics_tags($topics);
     if (sizeof($tags) > 0) {
         $class_topics_tags->remove_tag_from_match($tags, $topics[$i]);
         $class_topics_tags->update_tag_entry($tags);
     }
     // TAGS - END
     // LIKES - BEGIN
     @(include_once IP_ROOT_PATH . 'includes/class_topics.' . PHP_EXT);
     $class_topics = new class_topics();
     $class_topics->topics_posts_likes_resync();
     // LIKES - END
     $db->sql_transaction('commit');
     $this->topic_poll_delete($topics);
     $this->sync_cache(array($forum_id), array($new_topic_id));
     return true;
 }
Esempio n. 5
0
$topic_viewed_link = '';
if (empty($config['disable_topic_view']) && ($forum_topic_data['forum_topic_views'] == 1) && ($user->data['user_level'] == ADMIN))
{
	$topic_viewed_link = append_sid('topic_view_users.' . PHP_EXT . '?' . $forum_id_append . '&amp;' . $topic_id_append);
}

if ($config['show_social_bookmarks'])
{
	$template->assign_block_vars('social_bookmarks', array());
}

if ($config['display_tags_box'])
{
	@include_once(IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
	$class_topics_tags = new class_topics_tags();
	$topic_tags_links = $class_topics_tags->build_tags_list(array($topic_id));
	$template->assign_vars(array(
		'S_TOPIC_TAGS' => true,
		'TOPIC_TAGS' => $topic_tags_links,
		)
	);
}

if ($config['enable_featured_image'])
{
	$template->assign_var('S_FEATURED_IMAGE', true);
}

$topic_title_enc = urlencode(ip_utf8_decode($topic_title));
$topic_title_enc_utf8 = urlencode($topic_title);
Esempio n. 6
0
function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$topic_type, &$bbcode_on, &$html_on, &$acro_auto_on, &$smilies_on, &$attach_sig, $post_username, $post_subject, $topic_title_clean, $topic_tags, $post_message, $poll_title, &$poll_options, &$poll_data, &$reg_active, &$reg_reset, &$reg_max_option1, &$reg_max_option2, &$reg_max_option3, &$reg_length, &$news_category, &$topic_show_portal, &$mark_edit, &$topic_desc, $topic_calendar_time = 0, $topic_calendar_duration = 0)
{
    global $db, $cache, $config, $user, $lang;
    // CrackerTracker v5.x
    if (($mode == 'newtopic' || $mode == 'reply') && ($config['ctracker_spammer_blockmode'] > 0 || $config['ctracker_spam_attack_boost'] == 1) && $user->data['user_level'] != ANONYMOUS) {
        include_once IP_ROOT_PATH . 'includes/ctracker/classes/class_ct_userfunctions.' . PHP_EXT;
        $login_functions = new ct_userfunctions();
        $login_functions->handle_postings();
        unset($login_functions);
    }
    // CrackerTracker v5.x
    // BEGIN cmx_slash_news_mod
    if (isset($news_category) && is_numeric($news_category)) {
        $news_id = intval($news_category);
        //$topic_type = POST_NEWS;
    } else {
        $news_id = 0;
    }
    // END cmx_slash_news_mod
    include IP_ROOT_PATH . 'includes/functions_search.' . PHP_EXT;
    $current_time = time();
    if ($user->data['user_level'] != ADMIN && (!empty($config['force_large_caps_mods']) || $user->data['user_level'] != MOD)) {
        //$post_subject = strtolower($post_subject);
        $post_subject = ucwords($post_subject);
    }
    // Flood control
    if ($user->data['user_level'] != ADMIN && $user->data['user_level'] != MOD) {
        if (!function_exists('check_flood_posting')) {
            include_once IP_ROOT_PATH . 'includes/functions_flood.' . PHP_EXT;
        }
        check_flood_posting(false);
    }
    if ($mode == 'editpost') {
        remove_search_post($post_id);
    }
    if ($mode == 'newtopic' || $mode == 'editpost' && $post_data['first_post']) {
        $topic_vote = !empty($poll_title) && sizeof($poll_options) >= 2 ? 1 : 0;
        $topic_show_portal = $topic_show_portal == true ? 1 : 0;
        $topic_calendar_duration = $topic_calendar_duration == '' ? 0 : $topic_calendar_duration;
        // Event Registration - BEGIN
        $topic_reg = 0;
        if ($reg_active == 1) {
            $topic_reg = 1;
        }
        // Event Registration - END
        $sql = $mode != 'editpost' ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_desc, topic_tags, topic_poster, topic_time, forum_id, news_id, topic_status, topic_type, topic_calendar_time, topic_calendar_duration, topic_reg, topic_show_portal) VALUES ('" . $db->sql_escape($post_subject) . "', '" . $db->sql_escape($topic_desc) . "', " . $db->sql_validate_value($topic_tags) . ", " . $user->data['user_id'] . ", {$current_time}, {$forum_id}, {$news_id}, " . TOPIC_UNLOCKED . ", {$topic_type}, {$topic_calendar_time}, {$topic_calendar_duration}, {$topic_reg}, {$topic_show_portal})" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '" . $db->sql_escape($post_subject) . "', news_id = {$news_id}, topic_desc = '" . $db->sql_escape($topic_desc) . "', topic_tags = " . $db->sql_validate_value($topic_tags) . ", topic_type = {$topic_type}, topic_calendar_time = {$topic_calendar_time}, topic_calendar_duration = {$topic_calendar_duration}, topic_reg = {$topic_reg}" . ", topic_show_portal = {$topic_show_portal}\n\t\tWHERE topic_id = {$topic_id}";
        $db->sql_query($sql);
        if ($mode == 'newtopic') {
            $topic_id = $db->sql_nextid();
        } else {
            // Event Registration - BEGIN
            if ($reg_reset) {
                $sql = "DELETE FROM " . REGISTRATION_TABLE . " WHERE topic_id = " . $topic_id;
                $db->sql_query($sql);
            }
            // Event Registration - END
        }
        if (!function_exists('create_clean_topic_title')) {
            @(include_once IP_ROOT_PATH . 'includes/functions_topics.' . PHP_EXT);
        }
        create_clean_topic_title($topic_id, $forum_id, $topic_title_clean, '');
        @(include_once IP_ROOT_PATH . 'includes/class_topics_tags.' . PHP_EXT);
        $class_topics_tags = new class_topics_tags();
        $topic_tags_array = $class_topics_tags->create_tags_array($topic_tags);
        $update_tags = $mode == 'editpost' ? true : false;
        $class_topics_tags->submit_tags($topic_id, $forum_id, $topic_tags_array, $update_tags);
        unset($class_topics_tags);
        // Empty the similar id cache for guests every time we create a new topic or edit the first post in a topic
        if ($config['similar_topics']) {
            $clear_result = clear_similar_topics();
        }
    }
    // Poll management - BEGIN
    if (($mode == 'newtopic' || $mode == 'editpost' && $post_data['edit_poll']) && !empty($poll_title) && sizeof($poll_options) >= 2) {
        $poll_title = !empty($poll_title) ? trim($poll_title) : (isset($poll_data['title']) ? trim($poll_data['title']) : '');
        $poll_start = !empty($poll_data['start']) ? $poll_data['start'] : $current_time;
        $poll_length = isset($poll_data['length']) ? max(0, intval($poll_data['length'])) : 0;
        $poll_max_options = isset($poll_data['max_options']) ? max(1, intval($poll_data['max_options'])) : 1;
        $poll_last_vote = !empty($post_data['poll_last_vote']) ? $post_data['poll_last_vote'] : 0;
        $poll_change = !empty($poll_data['change']) ? 1 : 0;
        $sql_ary = array('poll_title' => $poll_title, 'poll_start' => $poll_start, 'poll_length' => $poll_length, 'poll_max_options' => $poll_max_options, 'poll_last_vote' => $poll_last_vote, 'poll_vote_change' => $poll_change);
        $sql_poll_update = $db->sql_build_insert_update($sql_ary, false);
        $sql = "UPDATE " . TOPICS_TABLE . " SET " . $sql_poll_update . " WHERE topic_id = " . $topic_id;
        $db->sql_query($sql);
        $delete_option_sql = '';
        $old_poll_result = array();
        if ($mode == 'editpost' && $post_data['has_poll']) {
            $sql = "SELECT *\n\t\t\t\tFROM " . POLL_OPTIONS_TABLE . "\n\t\t\t\tWHERE topic_id = {$topic_id}\n\t\t\t\tORDER BY poll_option_id ASC";
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $old_poll_result[$row['poll_option_id']] = $row['poll_option_total'];
                if (!isset($poll_options[$row['poll_option_id']])) {
                    $delete_option_sql .= ($delete_option_sql != '' ? ', ' : '') . $row['poll_option_id'];
                }
            }
        }
        $poll_option_id = 1;
        @reset($poll_options);
        while (list($option_id, $option_text) = each($poll_options)) {
            if (!empty($option_text)) {
                $option_insert = $mode != 'editpost' || !isset($old_poll_result[$option_id]) ? true : false;
                $poll_result = $option_insert ? 0 : $old_poll_result[$option_id];
                $poll_option_id = $option_insert ? $poll_option_id : $option_id;
                $sql_tmp_option_ary = array('poll_option_id' => $poll_option_id, 'topic_id' => $topic_id, 'poll_option_text' => $option_text, 'poll_option_total' => $poll_result);
                $sql_tmp_option = $db->sql_build_insert_update($sql_tmp_option_ary, $option_insert);
                if ($option_insert) {
                    $sql = "INSERT INTO " . POLL_OPTIONS_TABLE . " " . $sql_tmp_option;
                } else {
                    $sql = "UPDATE " . POLL_OPTIONS_TABLE . " SET " . $sql_tmp_option . " WHERE poll_option_id = {$option_id} AND topic_id = {$topic_id}";
                }
                $db->sql_query($sql);
                $poll_option_id++;
            }
        }
        if ($delete_option_sql != '') {
            $sql = "DELETE FROM " . POLL_OPTIONS_TABLE . "\n\t\t\t\tWHERE poll_option_id IN ({$delete_option_sql})\n\t\t\t\t\tAND topic_id = {$topic_id}";
            $db->sql_query($sql);
        }
    }
    // Poll management - END
    // Event Registration - BEGIN
    if (($mode == 'newtopic' || $mode == 'editpost') && $topic_reg == 1) {
        if ($mode == 'editpost') {
            $sql = "SELECT count(1) chk_reg FROM " . REGISTRATION_DESC_TABLE . " WHERE topic_id = {$topic_id}";
            $result = $db->sql_query($sql);
            $chk_reg = $db->sql_fetchfield('chk_reg', 0, $result) != 0 ? true : false;
        }
        $sql = $mode != 'editpost' || $mode == 'editpost' && $chk_reg == false ? "INSERT INTO " . REGISTRATION_DESC_TABLE . " (topic_id, reg_active, reg_max_option1, reg_max_option2, reg_max_option3, reg_start, reg_length) VALUES ({$topic_id}, {$reg_active}, {$reg_max_option1}, {$reg_max_option2}, {$reg_max_option3}, {$current_time}, " . $reg_length * 86400 . ")" : "UPDATE " . REGISTRATION_DESC_TABLE . " SET reg_active = {$reg_active}, reg_max_option1 = {$reg_max_option1}, reg_max_option2 = {$reg_max_option2}, reg_max_option3 = {$reg_max_option3}, reg_length = " . $reg_length * 86400 . " WHERE topic_id = {$topic_id}";
        $db->sql_query($sql);
    }
    // Event Registration - END
    // To show also admins modifications decomment this line!!!
    //if( ($user->data['user_level'] == ADMIN) && !$config['always_show_edit_by'] )
    if ($user->data['user_level'] == ADMIN) {
        $edited_sql = '';
    } else {
        // Original phpBB "Edit By"
        //$edited_sql = ($mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post']) ? ", post_edit_time = $current_time, post_edit_count = post_edit_count + 1 " : "";
        $edited_sql = ", post_edit_time = '" . $current_time . "', post_edit_count = (post_edit_count + 1), post_edit_id = '" . $user->data['user_id'] . "' ";
        if ($config['always_show_edit_by'] == true) {
            $edited_sql = $mode == 'editpost' ? $edited_sql : '';
        } else {
            $edited_sql = $mode == 'editpost' && !$post_data['last_post'] ? $edited_sql : '';
        }
    }
    $lock_post = request_boolean_var('post_locked', false);
    $sql = $mode != 'editpost' ? "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_subject, post_text, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_autolinks_acronyms, enable_sig, post_locked, post_images) VALUES (" . $topic_id . ", " . $forum_id . ", " . $user->data['user_id'] . ", '" . $db->sql_escape($post_username) . "', '" . $db->sql_escape($post_subject) . "', '" . $db->sql_escape($post_message) . "', " . $current_time . ", '" . $db->sql_escape($user->ip) . "', " . $bbcode_on . ", " . $html_on . ", " . $smilies_on . ", " . $acro_auto_on . ", " . $attach_sig . ", " . (!empty($lock_post) ? '1' : '0') . ", '" . $db->sql_escape($post_data['post_images']) . "')" : "UPDATE " . POSTS_TABLE . " SET post_username = '******', post_text = '" . $db->sql_escape($post_message) . "', post_text_compiled = '', post_subject = '" . $db->sql_escape($post_subject) . "', enable_bbcode = " . $bbcode_on . ", enable_html = " . $html_on . ", enable_smilies = " . $smilies_on . ", enable_autolinks_acronyms = " . $acro_auto_on . ", enable_sig = " . $attach_sig . ", post_locked = " . (!empty($lock_post) ? '1' : '0') . ", post_images = '" . $db->sql_escape($post_data['post_images']) . "' " . $edited_sql . " WHERE post_id = " . $post_id;
    //die($sql);
    $db->sql_transaction('begin');
    $db->sql_query($sql);
    if ($mode != 'editpost') {
        $post_id = $db->sql_nextid();
    }
    // UPI2DB - BEGIN
    if ($config['upi2db_on']) {
        $mark_edit = $user->data['user_level'] == ADMIN || $user->data['user_level'] == MOD ? $mark_edit : true;
        if ($mode != 'editpost' || $mode == 'editpost' && $post_data['last_post'] && $config['upi2db_last_edit_as_new'] && $mark_edit || $mode == 'editpost' && !$post_data['last_post'] && $config['upi2db_edit_as_new'] && $mark_edit || $mode == 'reply') {
            $sql = "SELECT post_id FROM " . UPI2DB_LAST_POSTS_TABLE . "\n\t\t\t\tWHERE post_id = " . $post_id;
            $result = $db->sql_query($sql);
            $id_vorhanden = $db->sql_numrows($result);
            $db->sql_freeresult($result);
            if ($id_vorhanden == 0) {
                $pt_or_pet = $mode != 'editpost' ? "post_time" : "post_edit_time";
                $sql = "INSERT INTO " . UPI2DB_LAST_POSTS_TABLE . " (post_id, topic_id, forum_id, poster_id, " . $pt_or_pet . ", topic_type, post_edit_by) VALUES ('{$post_id}', '{$topic_id}', '{$forum_id}', '" . $user->data['user_id'] . "', '{$current_time}', '{$topic_type}', '" . $user->data['user_id'] . "')";
            } else {
                $sql = "UPDATE " . UPI2DB_LAST_POSTS_TABLE . " SET post_edit_time = '" . $current_time . "', topic_type = '" . $topic_type . "', post_edit_by = '" . $user->data['user_id'] . "' WHERE post_id = " . $post_id;
            }
            $db->sql_query($sql);
        }
        // Edited By Mighty Gorgon - BEGIN
        if ($user->data['user_level'] != ADMIN && $user->data['user_level'] != MOD) {
            if ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE || $topic_type == POST_GLOBAL_ANNOUNCE) {
                $sql = "DELETE FROM " . UPI2DB_ALWAYS_READ_TABLE . "\n\t\t\t\t\tWHERE forum_id =  " . $forum_id;
                $db->sql_query($sql);
            }
        }
        // Edited By Mighty Gorgon - END
    }
    // UPI2DB - END
    add_search_words('single', $post_id, $post_message, $post_subject);
    // DOWNLOADS - BEGIN
    if (!empty($config['plugins']['downloads']['enabled'])) {
        setup_extra_lang(array('lang_downloads'), IP_ROOT_PATH . PLUGINS_PATH . $config['plugins']['downloads']['dir'] . 'language/');
        include IP_ROOT_PATH . PLUGINS_PATH . $config['plugins']['downloads']['dir'] . 'classes/class_dlmod.' . PHP_EXT;
        $dl_mod = new dlmod();
        $dl_config = $dl_mod->get_config();
        if ($dl_config['enable_post_dl_traffic']) {
            if (!$dl_config['delay_post_traffic'] || (time() - $user->data['user_regdate']) / 84600 > $dl_config['delay_post_traffic']) {
                $dl_traffic = 0;
                if ($mode == 'newtopic') {
                    $dl_traffic = $dl_config['newtopic_traffic'];
                } elseif ($mode == 'reply' || $mode == 'quote') {
                    $dl_traffic = $dl_config['reply_traffic'];
                }
                if ($dl_traffic > 0) {
                    $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\t\tSET user_traffic = user_traffic + {$dl_traffic}\n\t\t\t\t\t\tWHERE user_id = " . $user->data['user_id'];
                    $db->sql_query($sql);
                }
            }
        }
    }
    // DOWNLOADS - END
    // ReSync last topic title if needed
    if ($mode == 'editpost' && $post_data['first_post']) {
        $sql = "UPDATE " . FORUMS_TABLE . " f\n\t\t\tSET f.forum_last_post_subject = '" . $db->sql_escape($post_subject) . "'\n\t\t\tWHERE f.forum_last_topic_id = " . $topic_id;
        $result = $db->sql_query($sql);
    }
    $db->sql_transaction('commit');
    empty_cache_folders(POSTS_CACHE_FOLDER);
    empty_cache_folders(FORUMS_CACHE_FOLDER);
    board_stats();
    cache_tree(true);
    $cash_string = '';
    // MG Cash MOD For IP - BEGIN
    if (!empty($config['plugins']['cash']['enabled'])) {
        $cash_message = $GLOBALS['cm_posting']->update_post($mode, $post_data, $forum_id, $topic_id, $post_id, $topic_type, $post_username, $post_message);
        $cash_string = '<br />' . $cash_message;
    }
    // MG Cash MOD For IP - END
    $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $post_id) . '#p' . $post_id . '">';
    $message = $lang['Stored'] . $cash_string . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . POST_POST_URL . '=' . $post_id) . '#p' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid(CMS_PAGE_VIEWFORUM . '?' . POST_FORUM_URL . '=' . $forum_id) . '">', '</a>');
    return false;
}