예제 #1
0
        }
        $ug_rem_result = group_user_rem($ug_action_id, $profiledata['user_id'], false);
        if ($ug_rem_result === 1) {
            $message = $lang['GROUP_REMOVED_USER'];
            $add_rem_result = true;
        }
    } else {
        $s_hidden_fields = build_hidden_fields(array('sid' => $user->data['session_id'], 'ug_rem' => 1, POST_GROUPS_URL => (int) $ug_action_id));
        $nav_server_url = create_server_url();
        $breadcrumbs['address'] = $lang['Nav_Separator'] . '<a href="' . $nav_server_url . append_sid(CMS_PAGE_GROUP_CP) . '" class="nav-current">' . $lang['Group_Control_Panel'] . '</a>';
        $template->assign_vars(array('MESSAGE_TITLE' => $lang['Confirm'], 'MESSAGE_TEXT' => $lang['CONFIRM_UNSUB_USER'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'S_CONFIRM_ACTION' => append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $profiledata['user_id']), 'S_HIDDEN_FIELDS' => $s_hidden_fields));
        full_page_generation('confirm_body.tpl', $lang['Group_Control_Panel'], '', '');
    }
}
if (!empty($add_rem_result)) {
    empty_cache_folders(USERS_CACHE_FOLDER);
    $redirect_url = append_sid(CMS_PAGE_PROFILE . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $profiledata['user_id']);
    meta_refresh(3, $redirect_url);
    message_die(GENERAL_MESSAGE, $message);
}
// GROUPS - END
include_once IP_ROOT_PATH . 'includes/functions_zebra.' . PHP_EXT;
if (!empty($user->data['session_logged_in']) && $profiledata['user_id'] != $user->data['user_id']) {
    $zmode = request_var('zmode', '');
    if (!empty($zmode)) {
        // Allow only friends...
        //$zmode_types = array('friend', 'foe');
        $zmode_types = array('friend');
        $zmode = !in_array($zmode, $zmode_types) ? '' : $zmode;
    }
    if (!empty($zmode)) {
예제 #2
0
             if ($new_type == POST_CAT_URL) {
                 admin_add_error('Category_with_topics_deny');
             } elseif ($new_type == POST_FLINK_URL) {
                 admin_add_error('Forum_link_with_topics_deny');
             } else {
                 admin_add_error('Nowhere_to_move');
             }
         }
     }
 }
 // send errors
 if ($error) {
     $selected_id = $item['main'];
     $error_msg .= $return_msg;
     empty_cache_folders(FORUMS_CACHE_FOLDER);
     empty_cache_folders(TOPICS_CACHE_FOLDER);
     message_die(GENERAL_MESSAGE, $error_msg);
 }
 // get an order
 $item['order'] = 0;
 if (!empty($item['position']) && $item['position'] != 'Root') {
     $order_idx = $tree['keys'][$item['position']];
     $item['order'] = $tree['data'][$order_idx]['forum_order'];
 }
 $item['order'] += 5;
 // get an id
 $item['type'] = $item['type'] == POST_FLINK_URL ? POST_FORUM_URL : $item['type'];
 $new_item = false;
 if ((empty($fid) || $old_type != $item['type']) && !$delete_forum) {
     $new_item = true;
     $item['id'] = 0;
예제 #3
0
파일: erc.php 프로젝트: ALTUN69/icy_phoenix
                if (!$result) {
                    erc_throw_error("Couldn't delete AJAX Shoubox sessions table!", __LINE__, __FILE__, $sql);
                }
                $sql = "DELETE FROM " . SEARCH_TABLE;
                $db->sql_return_on_error(true);
                $result = $db->sql_query($sql);
                $db->sql_return_on_error(false);
                if (!$result) {
                    erc_throw_error("Couldn't delete search result table!", __LINE__, __FILE__, $sql);
                }
                success_message($lang['cls_success']);
                break;
            case 'ecf':
                // Clear Cache
                check_authorization();
                empty_cache_folders();
                success_message($lang['ecf_success']);
                break;
            case 'rdb':
                // Clear Sessions
                check_authorization();
                if (!check_mysql_version()) {
                    ?>
	<p><span class="text_red"><?php 
                    echo $lang['Old_MySQL_Version'];
                    ?>
</span></p>
<?php 
                } else {
                    ?>
	<p><?php 
예제 #4
0
				$class_notifications->send_notifications($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
			}
			// Forum Notification - END
		}

		if ($lock_subject)
		{
			$url = '<a href="' . append_sid(CMS_PAGE_VIEWTOPIC . '?' . (!empty($forum_id_append) ? ($forum_id_append . '&amp;') : '') . (!empty($topic_id_append) ? ($topic_id_append . '&amp;') : '') . POST_POST_URL . '=' . $lock_subject . '#p' . $lock_subject) . '">';
			$return_message = $lang['Report_stored'] . '<br /><br />' . sprintf($lang['Send_report'], $url, '</a>');
			$return_meta = str_replace($post_id, $lock_subject, $return_meta);
		}

		if (($error_msg == '') && ($lock) && ($mode == 'newtopic'))
		{
			empty_cache_folders(POSTS_CACHE_FOLDER);
			empty_cache_folders(FORUMS_CACHE_FOLDER);
			$sql = "UPDATE " . TOPICS_TABLE . "
				SET topic_status = " . TOPIC_LOCKED . "
				WHERE topic_id = " . $topic_id . "
					AND topic_moved_id = 0";
			$result = $db->sql_query($sql);
		}
		if (($mode == 'newtopic') || ($mode == 'reply'))
		{
			$tracking_forums = (!empty($_COOKIE[$config['cookie_name'] . '_f'])) ? unserialize($_COOKIE[$config['cookie_name'] . '_f']) : array();
			$tracking_topics = (!empty($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize($_COOKIE[$config['cookie_name'] . '_t']) : array();

			if (((sizeof($tracking_topics) + sizeof($tracking_forums)) >= 150) && empty($tracking_topics[$topic_id]))
			{
				asort($tracking_topics);
				unset($tracking_topics[key($tracking_topics)]);
예제 #5
0
    function sync_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id)
    {
        global $db, $config;
        if (!function_exists('update_user_color') || !function_exists('update_user_posts_details')) {
            include IP_ROOT_PATH . 'includes/functions_groups.' . PHP_EXT;
        }
        $sign = $mode == 'delete' ? '- 1' : '+ 1';
        $forum_update_sql = "forum_posts = forum_posts {$sign}";
        $topic_update_sql = '';
        if ($mode == 'delete') {
            if ($post_data['last_post']) {
                if ($post_data['first_post']) {
                    $forum_update_sql .= ', forum_topics = forum_topics - 1';
                } else {
                    $topic_update_sql .= 'topic_replies = topic_replies - 1';
                    $topic_data = $this->get_first_last_post_id($topic_id);
                    if (!empty($topic_data['last_post_id'])) {
                        $topic_update_sql .= ', topic_last_post_id = ' . $topic_data['last_post_id'];
                    }
                }
                if ($post_data['last_topic']) {
                    $last_post_id = $this->get_forum_last_post_id($forum_id);
                    if (!empty($last_post_id)) {
                        $forum_update_sql .= $row['last_post_id'] ? ', forum_last_post_id = ' . $last_post_id : ', forum_last_post_id = 0';
                    }
                }
            } elseif ($post_data['first_post']) {
                $topic_data = $this->get_first_last_post_id($topic_id);
                if (!empty($topic_data['first_post_id'])) {
                    $topic_update_sql .= 'topic_replies = topic_replies - 1, topic_first_post_id = ' . $topic_data['first_post_id'];
                }
            } else {
                $topic_update_sql .= 'topic_replies = topic_replies - 1';
            }
        } elseif ($mode != 'poll_delete') {
            $forum_update_sql .= ", forum_last_post_id = {$post_id}" . ($mode == 'newtopic' ? ", forum_topics = forum_topics {$sign}" : "");
            $topic_update_sql = "topic_last_post_id = {$post_id}" . ($mode == 'reply' ? ", topic_replies = topic_replies {$sign}" : ", topic_first_post_id = {$post_id}");
        } else {
            // Shall we update poll fields for this topic?
            //$topic_update_sql .= 'topic_vote = 0';
        }
        $db->sql_transaction('begin');
        if ($mode != 'poll_delete') {
            $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\tSET {$forum_update_sql}\n\t\t\t\tWHERE forum_id = {$forum_id}";
            $db->sql_query($sql);
        }
        if ($topic_update_sql != '') {
            $sql = "UPDATE " . TOPICS_TABLE . "\n\t\t\t\tSET {$topic_update_sql}\n\t\t\t\tWHERE topic_id = {$topic_id}";
            $db->sql_query($sql);
        }
        if ($mode != 'poll_delete') {
            // Disable Post count - BEGIN
            $postcount = true;
            $sql = "SELECT forum_postcount\n\t\t\t\tFROM " . FORUMS_TABLE . "\n\t\t\t\tWHERE forum_id = " . $forum_id . "\n\t\t\t\t\tAND forum_postcount = 0";
            $result = $db->sql_query($sql);
            if ($row = $db->sql_fetchrow($result)) {
                $postcount = false;
            }
            // Disable Post count - END
            $this->sync_topic_details($topic_id, $forum_id, false, false);
            if ($postcount) {
                $sql = "UPDATE " . USERS_TABLE . "\n\t\t\t\t\tSET user_posts = user_posts {$sign}\n\t\t\t\t\tWHERE user_id = {$user_id}";
                $db->sql_query($sql);
                $db->sql_transaction('commit');
                if ($config['site_history']) {
                    $current_time = time();
                    $minutes = gmdate('is', $current_time);
                    $hour_now = $current_time - 60 * ($minutes[0] . $minutes[1]) - ($minutes[2] . $minutes[3]);
                    $sql = 'UPDATE ' . SITE_HISTORY_TABLE . ' SET ' . ($mode == 'newtopic' || $post_data['first_post'] ? 'new_topics=new_topics' : 'new_posts=new_posts') . $sign . ' WHERE date=' . $hour_now;
                    $db->sql_return_on_error(true);
                    $result = $db->sql_query($sql);
                    $db->sql_return_on_error(false);
                    if (!$result || !$db->sql_affectedrows()) {
                        $sql = 'INSERT IGNORE INTO ' . SITE_HISTORY_TABLE . ' (date, ' . ($mode == 'newtopic' || $post_data['first_post'] ? 'new_topics' : 'new_posts') . ')
							VALUES (' . $hour_now . ', "1")';
                        $db->sql_query($sql);
                    }
                }
                $sql = "SELECT ug.user_id, g.group_id as g_id, u.user_posts, u.group_id, u.user_color, g.group_count, g.group_color, g.group_count_max FROM (" . GROUPS_TABLE . " g, " . USERS_TABLE . " u)\n\t\t\t\t\t\tLEFT JOIN " . USER_GROUP_TABLE . " ug ON g.group_id = ug.group_id AND ug.user_id = '" . $user_id . "'\n\t\t\t\t\t\tWHERE u.user_id = '" . $user_id . "'\n\t\t\t\t\t\tAND g.group_single_user = '******'\n\t\t\t\t\t\tAND g.group_count_enable = '1'\n\t\t\t\t\t\tAND g.group_moderator <> '" . $user_id . "'";
                $result = $db->sql_query($sql);
                while ($group_data = $db->sql_fetchrow($result)) {
                    $user_already_added = empty($group_data['user_id']) ? false : true;
                    $user_add = $group_data['group_count'] == $group_data['user_posts'] && $user_id != ANONYMOUS ? true : false;
                    $user_remove = $group_data['group_count'] > $group_data['user_posts'] || $group_data['group_count_max'] < $group_data['user_posts'] ? true : false;
                    if ($user_add && !$user_already_added) {
                        update_user_color($user_id, $group_data['group_color'], $group_data['g_id'], false, false);
                        update_user_posts_details($user_id, $group_data['group_color'], '', false, false);
                        empty_cache_folders(USERS_CACHE_FOLDER);
                        //user join a autogroup
                        $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)\n\t\t\t\t\t\t\tVALUES (" . $group_data['g_id'] . ", {$user_id}, '0')";
                        $db->sql_query($sql);
                    } elseif ($user_already_added && $user_remove) {
                        update_user_color($user_id, $config['active_users_color'], 0);
                        update_user_posts_details($user_id, '', '', false, false);
                        empty_cache_folders(USERS_CACHE_FOLDER);
                        //remove user from auto group
                        $sql = "DELETE FROM " . USER_GROUP_TABLE . "\n\t\t\t\t\t\t\tWHERE group_id = '" . $group_data['g_id'] . "'\n\t\t\t\t\t\t\tAND user_id = '" . $user_id . "'";
                        $db->sql_query($sql);
                    }
                }
            }
            $this->sync_cache(0, 0);
            board_stats();
            cache_tree(true);
        }
        return;
    }
예제 #6
0
 function autogroup($user_id)
 {
     global $db, $cache, $config, $lang;
     if ($user_id != ANONYMOUS) {
         if (!function_exists('update_user_color') || !function_exists('update_user_posts_details')) {
             include IP_ROOT_PATH . 'includes/functions_groups.' . PHP_EXT;
         }
         $sql = "SELECT ug.user_id, g.group_id as g_id, u.user_posts, u.group_id, u.user_color, g.group_count, g.group_color, g.group_count_max FROM (" . GROUPS_TABLE . " g, " . USERS_TABLE . " u)\n\t\t\t\t\tLEFT JOIN " . USER_GROUP_TABLE . " ug ON g.group_id = ug.group_id AND ug.user_id = '" . $user_id . "'\n\t\t\t\t\tWHERE u.user_id = '" . $user_id . "'\n\t\t\t\t\tAND g.group_single_user = '******'\n\t\t\t\t\tAND g.group_count_enable = '1'\n\t\t\t\t\tAND g.group_moderator <> '" . $user_id . "'";
         $result = $db->sql_query($sql);
         $user_cache_refresh = false;
         while ($group_data = $db->sql_fetchrow($result)) {
             $user_already_added = empty($group_data['user_id']) ? false : true;
             $user_add = $group_data['user_posts'] >= $group_data['group_count'] && $group_data['user_posts'] < $group_data['group_count_max'] ? true : false;
             $user_remove = $group_data['user_posts'] < $group_data['group_count'] || $group_data['user_posts'] >= $group_data['group_count_max'] ? true : false;
             if ($user_add && !$user_already_added) {
                 update_user_color($user_id, $group_data['group_color'], $group_data['g_id'], false, false);
                 update_user_posts_details($user_id, $group_data['group_color'], '', false, false);
                 $user_cache_refresh = true;
                 //user join a autogroup
                 $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending)\n\t\t\t\t\t\tVALUES (" . $group_data['g_id'] . ", {$user_id}, '0')";
                 $db->sql_query($sql);
             } elseif ($user_already_added && $user_remove) {
                 update_user_color($user_id, $config['active_users_color'], 0);
                 update_user_posts_details($user_id, '', '', false, false);
                 $user_cache_refresh = true;
                 //remove user from auto group
                 $sql = "DELETE FROM " . USER_GROUP_TABLE . "\n\t\t\t\t\t\tWHERE group_id = '" . $group_data['g_id'] . "'\n\t\t\t\t\t\tAND user_id = '" . $user_id . "'";
                 $db->sql_query($sql);
             }
         }
         $db->sql_freeresult($result);
         if (!empty($user_cache_refresh)) {
             empty_cache_folders(USERS_CACHE_FOLDER);
         }
     }
     return;
 }
if (!empty($setmodules)) {
    $file = basename(__FILE__);
    $module['1000_Configuration']['127_Clear_Cache'] = $file;
    return;
}
if (!defined('IP_ROOT_PATH')) {
    define('IP_ROOT_PATH', './../');
}
if (!defined('PHP_EXT')) {
    define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
}
require 'pagestart.' . PHP_EXT;
$confirmation = false;
$meta_tag = '';
if (check_http_var_exists('confirm_clear_cache_main', false)) {
    $files_deleted = empty_cache_folders('', CACHE_FILES_PER_STEP);
    $redirect_url = append_sid('admin_board_clearcache.' . PHP_EXT . '?confirm_clear_cache_main=' . str_replace('sid=', '', $SID));
    if ($files_deleted === CACHE_FILES_PER_STEP) {
        //meta_refresh(3, $redirect_url);
        $meta_tag = '</body><head><meta http-equiv="refresh" content="3;url=' . $redirect_url . '"></head><body>';
        $message .= $lang['MG_SW_Empty_Precompiled_Posts_InProgress'] . '<br /><br />' . $lang['MG_SW_Empty_Precompiled_Posts_InProgress_Redirect'] . '<br /><br />' . sprintf($lang['MG_SW_Empty_Precompiled_Posts_InProgress_Redirect_Click'], '<a href="' . $redirect_url . '">', '</a>');
        message_die(GENERAL_MESSAGE, $meta_tag . $message);
    }
    // Clean also data in global cache
    $cache_data = array('config', 'config_plugins', 'config_plugins_config', 'config_style', 'newest_user');
    foreach ($cache_data as $cache_data_section) {
        $cache->destroy($cache_data_section);
    }
    // Make sure cron is unlocked... just to make sure that it didn't hang somewhere in time... :-)
    set_config('cron_lock', '0');
    set_config('cron_lock_hour', 0);
예제 #8
0
/**
* Tidy topics
*/
function tidy_topics()
{
    global $db, $cache, $config;
    empty_cache_folders(POSTS_CACHE_FOLDER);
    empty_cache_folders(TOPICS_CACHE_FOLDER);
    empty_cache_folders(FORUMS_CACHE_FOLDER);
    if (CRON_DEBUG == false) {
        set_config('cron_topics_last_run', time());
    }
}
예제 #9
0
    case 'update_smileys_order':
        if ($user->data['user_level'] != ADMIN) {
            $result_ar = array('result' => AJAX_ERROR, 'error_msg' => 'NOT ALLOWED!!!');
            AJAX_message_die($result_ar);
            exit;
        }
        if (!empty($_POST['item'])) {
            $db->sql_transaction();
            $item_order = 0;
            foreach ($_POST['item'] as $smiley_item_id) {
                $item_order++;
                $sql = "UPDATE " . SMILIES_TABLE . " SET smilies_order = '" . $item_order . "' WHERE smilies_id = '" . $smiley_item_id . "'";
                $result = $db->sql_query($sql);
            }
            $db->sql_transaction('commit');
            $cache->destroy('_smileys');
            $db->clear_cache('smileys_');
        } else {
            $result_ar = array('result' => AJAX_ERROR, 'error_msg' => 'Invalid smiley position');
            AJAX_message_die($result_ar);
            exit;
        }
        break;
    default:
        $result_ar = array('result' => AJAX_ERROR, 'error_msg' => 'Invalid mode: ' . $mode);
        AJAX_message_die($result_ar);
        exit;
}
$cache->destroy('_cms_layouts_config');
empty_cache_folders(CMS_CACHE_FOLDER);
예제 #10
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;
}
예제 #11
0
function reorder_tree()
{
    global $tree, $db;
    // Make sure forums cache is empty...
    empty_cache_folders(FORUMS_CACHE_FOLDER);
    empty_cache_folders(TOPICS_CACHE_FOLDER);
    // Read the tree
    read_tree(true);
    // Update with new order
    $order = 0;
    for ($i = 0; $i < sizeof($tree['data']); $i++) {
        if (!empty($tree['id'][$i])) {
            $order += 10;
            $sql = "UPDATE " . FORUMS_TABLE . "\n\t\t\t\t\t\tSET forum_order = " . $order . "\n\t\t\t\t\t\tWHERE forum_id = " . intval($tree['id'][$i]);
            $db->sql_query($sql);
        }
    }
    convert_forum_order();
    // Make sure forums cache is empty again...
    empty_cache_folders(FORUMS_CACHE_FOLDER);
    empty_cache_folders(TOPICS_CACHE_FOLDER);
    // Re-cache the tree
    cache_tree(true);
    board_stats();
}