当前位置: 首页>>代码示例>>PHP>>正文


PHP add_search_words函数代码示例

本文整理汇总了PHP中add_search_words函数的典型用法代码示例。如果您正苦于以下问题:PHP add_search_words函数的具体用法?PHP add_search_words怎么用?PHP add_search_words使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了add_search_words函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: submit_post

function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, $post_username, $post_subject, $post_sub_title, $post_message, $poll_title, &$poll_options, &$poll_length, &$max_vote, &$hide_vote, &$tothide_vote, &$attribute_id)
{
    global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
    global $userdata, $user_ip, $post_info;
    include $phpbb_root_path . 'includes/functions_search.' . $phpEx;
    $current_time = time();
    if ($mode == 'newtopic' || $mode == 'reply' || $mode == 'editpost') {
        //
        // Flood control
        //Unless admin/mod
        if ($userdata['user_level'] != ADMIN && $userdata['user_level'] != MOD) {
            $where_sql = $userdata['user_id'] == ANONYMOUS ? "poster_ip = '{$user_ip}'" : 'poster_id = ' . $userdata['user_id'];
            $sql = "SELECT MAX(post_time) AS last_post_time\r\n\t\t\t\tFROM " . POSTS_TABLE . "\r\n\t\t\t\tWHERE {$where_sql}";
            if (($result = $db->sql_query($sql)) && ($row = $db->sql_fetchrow($result))) {
                if (intval($row['last_post_time']) > 0 && $current_time - intval($row['last_post_time']) < intval($board_config['flood_interval'])) {
                    message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
                }
            }
        }
        adr_add_experience_points($userdata['user_id'], $mode);
    }
    if ($mode == 'editpost') {
        remove_search_post($post_id);
    }
    // prepare sub-title data
    $common = new common();
    $post_sub_title = $common->sql_type_cast($post_sub_title, true);
    unset($common);
    if ($mode == 'newtopic' || $mode == 'editpost' && $post_data['first_post']) {
        $topic_vote = !empty($poll_title) && count($poll_options) >= 2 ? 1 : 0;
        //-- mod : quick title edition -------------------------------------------------
        //-- add
        $attribute = $attribute_id > -1 ? implode(',', array($attribute_id, $userdata['user_id'], time())) : '';
        //-- fin mod : quick title edition ---------------------------------------------
        $sql = $mode != "editpost" ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('{$post_subject}', " . $userdata['user_id'] . ", {$current_time}, {$forum_id}, " . TOPIC_UNLOCKED . ", {$topic_type}, {$topic_vote})" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '{$post_subject}', topic_type = {$topic_type} " . ($post_data['edit_vote'] || !empty($poll_title) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = {$topic_id}";
        //-- mod : quick title edition -------------------------------------------------
        //-- add
        if ($mode != 'editpost') {
            $sql = str_replace('INSERT INTO ' . TOPICS_TABLE . ' (', 'INSERT INTO ' . TOPICS_TABLE . ' (topic_attribute, ', $sql);
            $sql = str_replace('VALUES (', 'VALUES (\'' . $attribute . '\', ', $sql);
        } else {
            $sql = str_replace('SET ', 'SET topic_attribute = \'' . $attribute . '\', ', $sql);
        }
        //-- fin mod : quick title edition ---------------------------------------------
        // send topic sub-title data
        if ($mode != 'editpost') {
            $sql = str_replace('INSERT INTO ' . TOPICS_TABLE . ' (', 'INSERT INTO ' . TOPICS_TABLE . ' (topic_sub_title, ', $sql);
            $sql = str_replace('VALUES (', 'VALUES (' . $post_sub_title . ', ', $sql);
        } else {
            $sql = str_replace('SET ', 'SET topic_sub_title = ' . $post_sub_title . ', ', $sql);
        }
        if (!$db->sql_query($sql)) {
            message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }
        if ($mode == 'newtopic') {
            $topic_id = $db->sql_nextid();
        }
    }
    $edited_sql = $mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post'] ? ", post_edit_time = {$current_time}, post_edit_count = post_edit_count + 1 " : "";
    $sql = $mode != "editpost" ? "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, post_created, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ({$topic_id}, {$forum_id}, " . $userdata['user_id'] . ", '{$post_username}', {$current_time}, {$current_time}, '{$user_ip}', {$bbcode_on}, {$html_on}, {$smilies_on}, {$attach_sig})" : "UPDATE " . POSTS_TABLE . " SET post_username = '{$post_username}', enable_bbcode = {$bbcode_on}, enable_html = {$html_on}, enable_smilies = {$smilies_on}, enable_sig = {$attach_sig}" . $edited_sql . " WHERE post_id = {$post_id}";
    if (!$db->sql_query($sql, BEGIN_TRANSACTION)) {
        $db->clear_cache('posts_');
        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    if ($mode != 'editpost') {
        $post_id = $db->sql_nextid();
    }
    //-- mod : post description ----------------------------------------------------
    // here we added
    //	, post_sub_title
    //	, $post_sub_title
    //	, post_sub_title = $post_sub_title
    //-- modify
    $sql = $mode != 'editpost' ? "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, post_sub_title, bbcode_uid, post_text) VALUES ({$post_id}, '{$post_subject}', {$post_sub_title}, '{$bbcode_uid}', '{$post_message}')" : "UPDATE " . POSTS_TEXT_TABLE . " SET post_text = '{$post_message}',  bbcode_uid = '{$bbcode_uid}', post_subject = '{$post_subject}', post_sub_title = {$post_sub_title} WHERE post_id = {$post_id}";
    //-- fin mod : post description ------------------------------------------------
    if (!$db->sql_query($sql)) {
        exit($sql);
        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    $db->clear_cache('posts_');
    add_search_words('single', $post_id, stripslashes($post_message), stripslashes($post_subject));
    //
    // Add poll
    //
    if (($mode == 'newtopic' || $mode == 'editpost' && $post_data['edit_poll']) && !empty($poll_title) && count($poll_options) >= 2) {
        $sql = !$post_data['has_poll'] ? "INSERT INTO " . VOTE_DESC_TABLE . " (topic_id, vote_text, vote_start, vote_length, vote_max, vote_hide, vote_tothide) VALUES ({$topic_id}, '{$poll_title}', {$current_time}, " . $poll_length * 86400 . ", '{$max_vote}', '{$hide_vote}', '{$tothide_vote}')" : "UPDATE " . VOTE_DESC_TABLE . " SET vote_text = '{$poll_title}', vote_length = " . $poll_length * 86400 . ", vote_max = '{$max_vote}', vote_hide = '{$hide_vote}', vote_tothide = '{$tothide_vote}' WHERE topic_id = {$topic_id}";
        if (!$db->sql_query($sql)) {
            $db->clear_cache('posts_');
            message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }
        $delete_option_sql = '';
        $old_poll_result = array();
        if ($mode == 'editpost' && $post_data['has_poll']) {
            $sql = "SELECT vote_option_id, vote_result  \r\n\t\t\t\tFROM " . VOTE_RESULTS_TABLE . " \r\n\t\t\t\tWHERE vote_id = {$poll_id} \r\n\t\t\t\tORDER BY vote_option_id ASC";
            if (!($result = $db->sql_query($sql))) {
                $db->clear_cache('posts_');
                message_die(GENERAL_ERROR, 'Could not obtain vote data results for this topic', '', __LINE__, __FILE__, $sql);
            }
            while ($row = $db->sql_fetchrow($result)) {
                $old_poll_result[$row['vote_option_id']] = $row['vote_result'];
//.........这里部分代码省略.........
开发者ID:Nekrofage,项目名称:FJR,代码行数:101,代码来源:functions_post.php

示例2: insert_post

function insert_post($message, $subject, $forum_id, $user_id, $user_name, $user_attach_sig, $topic_id = NULL, $topic_type = POST_NORMAL, $do_notification = false, $notify_user = false, $current_time = 0, $error_die_function = '', $html_on = 0, $bbcode_on = 1, $smilies_on = 1)
{
    global $db, $board_config, $user_ip;
    // initialise some variables
    $topic_vote = 0;
    $mode = 'reply';
    $bbcode_uid = $bbcode_on ? make_bbcode_uid() : '';
    $error_die_function = $error_die_function == '' ? "message_die" : $error_die_function;
    $current_time = $current_time == 0 ? time() : $current_time;
    // parse the message and the subject (belt & braces :)
    $message = addslashes(unprepare_message($message));
    $message = prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
    $subject = addslashes(str_replace('"', '&quot;', trim($subject)));
    $username = addslashes(unprepare_message(trim($user_name)));
    // fix for \" in username - wineknow.com
    $username = str_replace("\\\"", "\"", $username);
    // if this is a new topic then insert the topic details
    if (is_null($topic_id)) {
        $mode = 'newtopic';
        $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('{$subject}', " . $user_id . ", {$current_time}, {$forum_id}, " . TOPIC_UNLOCKED . ", {$topic_type}, {$topic_vote})";
        if (!$db->sql_query($sql, BEGIN_TRANSACTION)) {
            $error_die_function(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }
        $topic_id = $db->sql_nextid();
    }
    // insert the post details using the topic id
    $sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ({$topic_id}, {$forum_id}, " . $user_id . ", '{$username}', {$current_time}, '{$user_ip}', {$bbcode_on}, {$html_on}, {$smilies_on}, {$user_attach_sig})";
    if (!$db->sql_query($sql, BEGIN_TRANSACTION)) {
        $error_die_function(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    $post_id = $db->sql_nextid();
    // insert the actual post text for our new post
    $sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ({$post_id}, '{$subject}', '{$bbcode_uid}', '{$message}')";
    if (!$db->sql_query($sql, BEGIN_TRANSACTION)) {
        $error_die_function(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    // update the post counts etc.
    $newpostsql = $mode == 'newtopic' ? ',forum_topics = forum_topics + 1' : '';
    $sql = "UPDATE " . FORUMS_TABLE . " SET \n                forum_posts = forum_posts + 1,\n                forum_last_post_id = {$post_id}\n                {$newpostsql} \t\n            WHERE forum_id = {$forum_id}";
    if (!$db->sql_query($sql, BEGIN_TRANSACTION)) {
        $error_die_function(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    // update the first / last post ids for the topic
    $first_post_sql = $mode == 'newtopic' ? ", topic_first_post_id = {$post_id}  " : ' , topic_replies=topic_replies+1';
    $sql = "UPDATE " . TOPICS_TABLE . " SET \n                topic_last_post_id = {$post_id} \n                {$first_post_sql}\n            WHERE topic_id = {$topic_id}";
    if (!$db->sql_query($sql, BEGIN_TRANSACTION)) {
        $error_die_function(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    // update the user's post count and commit the transaction
    $sql = "UPDATE " . USERS_TABLE . " SET \n                user_posts = user_posts + 1\n            WHERE user_id = {$user_id}";
    if (!$db->sql_query($sql, END_TRANSACTION)) {
        $error_die_function(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    // add the search words for our new post
    switch ($board_config['version']) {
        case '.0.0':
        case '.0.1':
        case '.0.2':
        case '.0.3':
            add_search_words($post_id, stripslashes($message), stripslashes($subject));
            break;
        default:
            add_search_words('', $post_id, stripslashes($message), stripslashes($subject));
            break;
    }
    // do we need to do user notification
    if ($mode == 'reply' && $do_notification) {
        // DP bugfix (critical): $userdata['user_id'] must be set; otherwise,
        // user_notification() will generate a bad SQL query and die.
        global $userdata;
        $userdata['user_id'] = $user_id;
        // DP bugfix (minor): We should pass the topic title, not the post subject,
        // as the third param to user_notification.
        $sql = "SELECT topic_title FROM " . TOPICS_TABLE . " WHERE topic_id = {$topic_id}";
        if (!($result = $db->sql_query($sql))) {
            $error_die_function(GENERAL_ERROR, 'Error getting topic_title', '', __LINE__, __FILE__, $sql);
        }
        list($topic_title) = $db->sql_fetchrow($result);
        $post_data = array();
        user_notification($mode, $post_data, $topic_title, $forum_id, $topic_id, $post_id, $notify_user);
    }
    // if all is well then return the id of our new post
    return array('post_id' => $post_id, 'topic_id' => $topic_id);
}
开发者ID:cpeel,项目名称:dproofreaders-shadow,代码行数:84,代码来源:functions_insert_post.php

示例3: submit_post

function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)
{
    global $board_config, $lang, $db, $phpbb_root_path, $phpEx;
    global $userdata, $user_ip;
    include "includes/functions_search.php";
    $current_time = time();
    if ($mode == 'newtopic' || $mode == 'reply' || $mode == 'editpost') {
        //
        // Flood control
        //
        $where_sql = $userdata['user_id'] == ANONYMOUS ? "poster_ip = '{$user_ip}'" : 'poster_id = ' . $userdata['user_id'];
        $sql = "SELECT MAX(post_time) AS last_post_time\r\n                        FROM " . POSTS_TABLE . "\r\n                        WHERE {$where_sql}";
        if ($result = $db->sql_query($sql)) {
            if ($row = $db->sql_fetchrow($result)) {
                if (intval($row['last_post_time']) > 0 && $current_time - intval($row['last_post_time']) < intval($board_config['flood_interval'])) {
                    message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
                }
            }
        }
    }
    if ($mode == 'editpost') {
        remove_search_post($post_id);
    }
    if ($mode == 'newtopic' || $mode == 'editpost' && $post_data['first_post']) {
        $topic_vote = !empty($poll_title) && count($poll_options) >= 2 ? 1 : 0;
        $sql = $mode != "editpost" ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('{$post_subject}', " . $userdata['user_id'] . ", '{$current_time}', '{$forum_id}', " . TOPIC_UNLOCKED . ", '{$topic_type}', '{$topic_vote}')" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '{$post_subject}', topic_type = {$topic_type} " . ($post_data['edit_vote'] || !empty($poll_title) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = '{$topic_id}'";
        if (!$db->sql_query($sql)) {
            message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }
        if ($mode == 'newtopic') {
            $topic_id = $db->sql_nextid();
            update_points(10);
        }
    }
    $edited_sql = $mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post'] ? ", post_edit_time = {$current_time}, post_edit_count = post_edit_count + 1 " : "";
    $sql = $mode != "editpost" ? "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ('{$topic_id}', '{$forum_id}', " . $userdata['user_id'] . ", '{$post_username}', '{$current_time}', '{$user_ip}', '{$bbcode_on}', '{$html_on}', '{$smilies_on}', '{$attach_sig}')" : "UPDATE " . POSTS_TABLE . " SET post_username = '{$post_username}', enable_bbcode = '{$bbcode_on}', enable_html = '{$html_on}', enable_smilies = '{$smilies_on}', enable_sig = '{$attach_sig}'" . $edited_sql . " WHERE post_id = '{$post_id}'";
    if (!$db->sql_query($sql, BEGIN_TRANSACTION)) {
        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    if ($mode != 'editpost') {
        $post_id = $db->sql_nextid();
    }
    $sql = $mode != 'editpost' ? "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ('{$post_id}', '{$post_subject}', '{$bbcode_uid}', '{$post_message}')" : "UPDATE " . POSTS_TEXT_TABLE . " SET post_text = '{$post_message}',  bbcode_uid = '{$bbcode_uid}', post_subject = '{$post_subject}' WHERE post_id = '{$post_id}'";
    if (!$db->sql_query($sql)) {
        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    add_search_words('single', $post_id, stripslashes($post_message), stripslashes($post_subject));
    //
    // Add poll
    //
    if (($mode == 'newtopic' || $mode == 'editpost' && $post_data['edit_poll']) && !empty($poll_title) && count($poll_options) >= 2) {
        $sql = !$post_data['has_poll'] ? "INSERT INTO " . VOTE_DESC_TABLE . " (topic_id, vote_text, vote_start, vote_length) VALUES ('{$topic_id}', '{$poll_title}', '{$current_time}', " . $poll_length * 86400 . ")" : "UPDATE " . VOTE_DESC_TABLE . " SET vote_text = '{$poll_title}', vote_length = " . $poll_length * 86400 . " WHERE topic_id = '{$topic_id}'";
        if (!$db->sql_query($sql)) {
            message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }
        $delete_option_sql = '';
        $old_poll_result = array();
        if ($mode == 'editpost' && $post_data['has_poll']) {
            $sql = "SELECT vote_option_id, vote_result\r\n                                FROM " . VOTE_RESULTS_TABLE . "\r\n                                WHERE vote_id = '{$poll_id}'\r\n                                ORDER BY vote_option_id ASC";
            if (!($result = $db->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not obtain vote data results for this topic', '', __LINE__, __FILE__, $sql);
            }
            while ($row = $db->sql_fetchrow($result)) {
                $old_poll_result[$row['vote_option_id']] = $row['vote_result'];
                if (!isset($poll_options[$row['vote_option_id']])) {
                    $delete_option_sql .= $delete_option_sql != '' ? ', ' . $row['vote_option_id'] : $row['vote_option_id'];
                }
            }
        } else {
            $poll_id = $db->sql_nextid();
        }
        @reset($poll_options);
        $poll_option_id = 1;
        while (list($option_id, $option_text) = each($poll_options)) {
            if (!empty($option_text)) {
                $option_text = str_replace("\\'", "''", htmlspecialchars($option_text));
                $poll_result = $mode == "editpost" && isset($old_poll_result[$option_id]) ? $old_poll_result[$option_id] : 0;
                $sql = $mode != "editpost" || !isset($old_poll_result[$option_id]) ? "INSERT INTO " . VOTE_RESULTS_TABLE . " (vote_id, vote_option_id, vote_option_text, vote_result) VALUES ('{$poll_id}', '{$poll_option_id}', '{$option_text}', '{$poll_result}')" : "UPDATE " . VOTE_RESULTS_TABLE . " SET vote_option_text = '{$option_text}', vote_result = '{$poll_result}' WHERE vote_option_id = '{$option_id}' AND vote_id = '{$poll_id}'";
                if (!$db->sql_query($sql)) {
                    message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
                }
                $poll_option_id++;
            }
        }
        if ($delete_option_sql != '') {
            $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . "\r\n                                WHERE vote_option_id IN ({$delete_option_sql})\r\n                                        AND vote_id = '{$poll_id}'";
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Error deleting pruned poll options', '', __LINE__, __FILE__, $sql);
            }
        }
    }
    $meta = '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.{$phpEx}?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">';
    $message = $lang['Stored'] . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.{$phpEx}?" . POST_FORUM_URL . "={$forum_id}") . '">', '</a>');
    return false;
}
开发者ID:BackupTheBerlios,项目名称:domsmod-svn,代码行数:95,代码来源:functions_post.php

示例4: Indexing

 // Process this many posts per loop
 $batchcount = 0;
 $total_percent = 0;
 for (; $postcounter <= $max_post_id; $postcounter += $batchsize) {
     $batchstart = $postcounter + 1;
     $batchend = $postcounter + $batchsize;
     $batchcount++;
     print " * Fulltext Indexing ( {$batchstart} to {$batchend} ) :: ";
     flush();
     $sql = "SELECT *\n\t\t\t\t\tFROM " . POSTS_TEXT_TABLE . "\n\t\t\t\t\tWHERE post_id \n\t\t\t\t\t\tBETWEEN {$batchstart} \n\t\t\t\t\t\t\tAND {$batchend}";
     $posts_result = query($sql, "Couldn't obtain post_text");
     $per_pct = ceil($db->sql_numrows($posts_result) / 40);
     $inc = 0;
     if ($row = $db->sql_fetchrow($posts_result)) {
         do {
             add_search_words('global', $row['post_id'], $row['post_text'], $row['post_subject']);
             $inc++;
             if ($inc == $per_pct) {
                 print ".";
                 flush();
                 $inc = 0;
             }
         } while ($row = $db->sql_fetchrow($posts_result));
     }
     $db->sql_freeresult($posts_result);
     // Remove common words after the first 2 batches and after every 4th batch after that.
     if ($batchcount % 4 == 3) {
         remove_common('global', 4 / 10);
     }
     print " <span class=\"ok\"><b>OK</b></span><br />\n";
 }
开发者ID:BackupTheBerlios,项目名称:flushcms,代码行数:31,代码来源:upgrade.php

示例5: phpbb_edit_post

function phpbb_edit_post($post_id = null, $subject = null, $message = null)
{
    global $CFG, $userdata, $phpbb_root_path, $phpEx;
    include_once $phpbb_root_path . 'includes/functions_post.' . $phpEx;
    include_once $phpbb_root_path . 'includes/functions_search.' . $phpEx;
    if (empty($subject)) {
        phpbb_raise_error('Subject must not be empty.');
    }
    if (empty($message)) {
        phpbb_raise_error('Message must not be empty.');
    }
    if (empty($post_id)) {
        phpbb_raise_error('Post does not exists.');
    }
    $sql = 'SELECT *
				FROM ' . POSTS_TABLE . '
				WHERE post_id = ' . $post_id;
    $result = phpbb_fetch_row($sql);
    if ($result) {
        $topic_id = $result['topic_id'];
    } else {
        phpbb_raise_error('Post does not exists.', __FILE__, __LINE__, $sql);
    }
    $sql = 'SELECT *
				FROM ' . TOPICS_TABLE . '
				WHERE topic_id = ' . $topic_id;
    $topic_info = phpbb_fetch_row($sql);
    remove_search_post($post_id);
    if ($post_id == $topic_info['topic_first_post_id']) {
        $sql = 'UPDATE ' . TOPICS_TABLE . '
					SET topic_title = \'' . str_replace("\\'", "''", $subject) . '\'
					WHERE topic_id = ' . $topic_id;
        phpbb_query($sql);
    }
    $sql = 'UPDATE ' . POSTS_TEXT_TABLE . '
				SET post_text = \'' . str_replace("\\'", "''", $message) . '\',
					post_subject = \'' . str_replace("\\'", "''", $subject) . '\'
				WHERE post_id = ' . $post_id;
    phpbb_query($sql);
    add_search_words('single', $post_id, stripslashes($message), stripslashes($subject));
}
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:41,代码来源:editor.php

示例6: list

 // get the db sizes
 list($search_data_size, $search_index_size, $search_tables_size) = get_db_sizes();
 // get the post subject/text of each post
 $result = DB()->query("\n\t\tSELECT\n\t\t\tpt.post_id, pt.post_text,\n\t\t\tIF(p.post_id = t.topic_first_post_id, t.topic_title, '') AS post_subject\n\t\tFROM\n\t\t\t" . BB_POSTS_TEXT . " pt,\n\t\t\t" . BB_POSTS . " p,\n\t\t\t" . BB_TOPICS . " t\n\t\tWHERE p.post_id = pt.post_id\n\t\t\tAND t.topic_id = p.topic_id\n\t\t\tAND p.poster_id NOT IN(" . BOT_UID . ")\n\t\t\tAND pt.post_id >= {$start}\n\t\tORDER BY pt.post_id ASC\n\t\tLIMIT {$post_limit}\n\t");
 $expire_time = $start_time + $time_limit - 5;
 $start_post_id = $end_post_id = $num_rows = 0;
 $timer_expired = false;
 $words_sql = array();
 while ($row = DB()->fetch_next($result) and !$timer_expired) {
     @set_time_limit(600);
     $start_post_id = $num_rows == 0 ? $row['post_id'] : $start_post_id;
     $end_post_id = $row['post_id'];
     // Get search words
     $s_post_text = str_replace('\\n', "\n", $row['post_text']);
     $s_post_subject = str_replace('\\n', "\n", $row['post_subject']);
     $words_sql[] = array('post_id' => (int) $row['post_id'], 'search_words' => add_search_words($row['post_id'], stripslashes($s_post_text), stripslashes($s_post_subject), true));
     $timer_expired = TIMENOW > $expire_time;
     $num_rows++;
 }
 // Store search words
 if ($words_sql) {
     DB()->query("REPLACE INTO " . BB_POSTS_SEARCH . DB()->build_array('MULTI_INSERT', $words_sql));
 }
 // find how much time the last cycle took
 $last_cycle_time = intval(TIMENOW - $start_time);
 // check if we had any data
 if ($num_rows != 0) {
     if ($mode == 'submit') {
         // insert a new session entry
         $args = DB()->build_array('INSERT', array('end_post_id' => (int) $end_post_id, 'end_time' => (int) TIMENOW, 'last_cycle_time' => (int) $last_cycle_time, 'session_time' => (int) $last_cycle_time, 'session_posts' => (int) $num_rows, 'session_cycles' => (int) 1, 'start_post_id' => (int) $start_post_id, 'start_time' => (int) $start_time, 'search_size' => (int) $search_tables_size, 'rebuild_session_status' => REBUILD_SEARCH_PROCESSED));
         DB()->query("REPLACE INTO " . BB_SEARCH_REBUILD . $args);
开发者ID:ErR163,项目名称:torrentpier,代码行数:31,代码来源:admin_rebuild_search.php

示例7: substr_count

                if ($last_msg == $message) {
                    $this->ajax_die($lang['DOUBLE_POST_ERROR']);
                }
            }
        }
        if ($bb_cfg['max_smilies']) {
            $count_smilies = substr_count(bbcode2html($message), '<img class="smile" src="' . $bb_cfg['smilies_path']);
            if ($count_smilies > $bb_cfg['max_smilies']) {
                $this->ajax_die(sprintf($lang['MAX_SMILIES_PER_POST'], $bb_cfg['max_smilies']));
            }
        }
        DB()->sql_query("INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_time, poster_ip) VALUES ({$topic_id}, " . $post['forum_id'] . ", " . $userdata['user_id'] . ", '" . TIMENOW . "', '" . USER_IP . "')");
        $post_id = DB()->sql_nextid();
        DB()->sql_query("INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ({$post_id}, '" . DB()->escape($message) . "')");
        update_post_stats('reply', $post, $post['forum_id'], $topic_id, $post_id, $userdata['user_id']);
        $s_message = str_replace('\\n', "\n", $message);
        $s_topic_title = str_replace('\\n', "\n", $post['topic_title']);
        add_search_words($post_id, stripslashes($s_message), stripslashes($s_topic_title));
        update_post_html(array('post_id' => $post_id, 'post_text' => $message));
        if ($bb_cfg['topic_notify_enabled']) {
            $notify = !empty($this->request['notify']);
            user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify);
        }
        // Update atom feed
        update_atom('topic', (int) $this->request['topic_id']);
        $this->response['redirect'] = make_url(POST_URL . "{$post_id}#{$post_id}");
        break;
    default:
        $this->ajax_die('empty type');
        break;
}
开发者ID:ErR163,项目名称:torrentpier,代码行数:31,代码来源:posts.php

示例8: submit_post

function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$topic_type, $post_username, $post_subject, $post_message, $update_post_time, $poster_rg_id, $attach_rg_sig)
{
    global $userdata, $post_info, $is_auth, $bb_cfg, $lang, $datastore;
    $current_time = TIMENOW;
    // Flood control
    $row = null;
    $where_sql = IS_GUEST ? "p.poster_ip = '" . USER_IP . "'" : "p.poster_id = {$userdata['user_id']}";
    if ($mode == 'newtopic' || $mode == 'reply') {
        $sql = "SELECT MAX(p.post_time) AS last_post_time FROM " . BB_POSTS . " p WHERE {$where_sql}";
        if ($row = DB()->fetch_row($sql) and $row['last_post_time']) {
            if ($userdata['user_level'] == USER) {
                if (TIMENOW - $row['last_post_time'] < $bb_cfg['flood_interval']) {
                    bb_die($lang['FLOOD_ERROR']);
                }
            }
        }
    }
    // Double Post Control
    if ($mode != 'editpost' && !empty($row['last_post_time']) && !IS_AM) {
        $sql = "\n\t\t\tSELECT pt.post_text\n\t\t\tFROM " . BB_POSTS . " p, " . BB_POSTS_TEXT . " pt\n\t\t\tWHERE\n\t\t\t\t\t{$where_sql}\n\t\t\t\tAND p.post_time = " . (int) $row['last_post_time'] . "\n\t\t\t\tAND pt.post_id = p.post_id\n\t\t\tLIMIT 1\n\t\t";
        if ($row = DB()->fetch_row($sql)) {
            $last_msg = DB()->escape($row['post_text']);
            if ($last_msg == $post_message) {
                bb_die($lang['DOUBLE_POST_ERROR']);
            }
        }
    }
    if ($mode == 'newtopic' || $mode == 'editpost' && $post_data['first_post']) {
        $topic_dl_type = isset($_POST['topic_dl_type']) && ($post_info['allow_reg_tracker'] || $is_auth['auth_mod']) ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL;
        $sql_insert = "\n\t\t\tINSERT INTO\n\t\t\t\t" . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type)\n\t\t\tVALUES\n\t\t\t\t('{$post_subject}', " . $userdata['user_id'] . ", {$current_time}, {$forum_id}, " . TOPIC_UNLOCKED . ", {$topic_type}, {$topic_dl_type})\n\t\t";
        $sql_update = "\n\t\t\tUPDATE\n\t\t\t\t" . BB_TOPICS . "\n\t\t\tSET\n\t\t\t\ttopic_title = '{$post_subject}',\n\t\t\t\ttopic_type = {$topic_type},\n\t\t\t\ttopic_dl_type = {$topic_dl_type}\n\t\t\tWHERE\n\t\t\t\ttopic_id = {$topic_id}\n\t\t";
        $sql = $mode != "editpost" ? $sql_insert : $sql_update;
        if (!DB()->sql_query($sql)) {
            bb_die('Error in posting #1');
        }
        if ($mode == 'newtopic') {
            $topic_id = DB()->sql_nextid();
        }
    }
    $edited_sql = $mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post'] ? ", post_edit_time = {$current_time}, post_edit_count = post_edit_count + 1" : "";
    if ($update_post_time && $mode == 'editpost' && $post_data['last_post'] && !$post_data['first_post']) {
        $edited_sql .= ", post_time = {$current_time} ";
        //lpt
        DB()->sql_query("UPDATE " . BB_TOPICS . " SET topic_last_post_time = {$current_time} WHERE topic_id = {$topic_id} LIMIT 1");
    }
    $sql = $mode != "editpost" ? "INSERT INTO " . BB_POSTS . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, poster_rg_id, attach_rg_sig) VALUES ({$topic_id}, {$forum_id}, " . $userdata['user_id'] . ", '{$post_username}', {$current_time}, '" . USER_IP . "', {$poster_rg_id}, {$attach_rg_sig})" : "UPDATE " . BB_POSTS . " SET post_username = '{$post_username}'" . $edited_sql . ", poster_rg_id = {$poster_rg_id}, attach_rg_sig = {$attach_rg_sig} WHERE post_id = {$post_id}";
    if (!DB()->sql_query($sql)) {
        bb_die('Error in posting #2');
    }
    if ($mode != 'editpost') {
        $post_id = DB()->sql_nextid();
    }
    $sql = $mode != 'editpost' ? "INSERT INTO " . BB_POSTS_TEXT . " (post_id, post_text) VALUES ({$post_id}, '{$post_message}')" : "UPDATE " . BB_POSTS_TEXT . " SET post_text = '{$post_message}' WHERE post_id = {$post_id}";
    if (!DB()->sql_query($sql)) {
        bb_die('Error in posting #3');
    }
    if ($userdata['user_id'] != BOT_UID) {
        $s_post_message = str_replace('\\n', "\n", $post_message);
        $s_post_subject = str_replace('\\n', "\n", $post_subject);
        add_search_words($post_id, stripslashes($s_post_message), stripslashes($s_post_subject));
    }
    update_post_html(array('post_id' => $post_id, 'post_text' => $post_message));
    //Обновление кеша новостей на главной
    if ($bb_cfg['show_latest_news']) {
        $news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id']));
        if (isset($news_forums[$forum_id]) && $bb_cfg['show_latest_news'] && $mode == 'newtopic') {
            $datastore->enqueue('latest_news');
            $datastore->update('latest_news');
        }
    }
    if ($bb_cfg['show_network_news']) {
        $net_forums = array_flip(explode(',', $bb_cfg['network_news_forum_id']));
        if (isset($net_forums[$forum_id]) && $bb_cfg['show_network_news'] && $mode == 'newtopic') {
            $datastore->enqueue('network_news');
            $datastore->update('network_news');
        }
    }
    meta_refresh(POST_URL . "{$post_id}#{$post_id}");
    set_die_append_msg($forum_id, $topic_id);
    return $mode;
}
开发者ID:ErR163,项目名称:torrentpier,代码行数:81,代码来源:functions_post.php

示例9: Indexing

 // Process this many posts per loop
 $batchcount = 0;
 $total_percent = 0;
 for (; $postcounter <= $max_post_id; $postcounter += $batchsize) {
     $batchstart = $postcounter + 1;
     $batchend = $postcounter + $batchsize;
     $batchcount++;
     print " * Fulltext Indexing ( {$batchstart} to {$batchend} ) :: ";
     flush();
     $sql = "SELECT *\r\n\t\t\t\t\tFROM " . POSTS_TEXT_TABLE . "\r\n\t\t\t\t\tWHERE post_id \r\n\t\t\t\t\t\tBETWEEN {$batchstart} \r\n\t\t\t\t\t\t\tAND {$batchend}";
     $posts_result = query($sql, "Couldn't obtain post_text");
     $per_pct = ceil($db->sql_numrows($posts_result) / 40);
     $inc = 0;
     if ($row = $db->sql_fetchrow($posts_result)) {
         do {
             add_search_words($row['post_id'], $row['post_text'], $row['post_subject']);
             $inc++;
             if ($inc == $per_pct) {
                 print ".";
                 flush();
                 $inc = 0;
             }
         } while ($row = $db->sql_fetchrow($posts_result));
     }
     $db->sql_freeresult($posts_result);
     // Remove common words after the first 2 batches and after every 4th batch after that.
     if ($batchcount % 4 == 3) {
         remove_common('global', 0.4);
     }
     print " <span class=\"ok\"><b>OK</b></span><br />\n";
 }
开发者ID:noikiy,项目名称:owaspbwa,代码行数:31,代码来源:upgrade.php

示例10: submit_post

function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length, $update_post_time)
{
    global $ft_cfg, $lang;
    global $userdata, $user_ip;
    global $is_auth;
    require FT_ROOT . 'includes/functions_search.php';
    $current_time = time();
    //if ($mode == 'newtopic' || $mode == 'reply' || $mode == 'editpost')
    if ($mode == 'newtopic' || $mode == 'reply') {
        //
        // Flood control
        //
        $where_sql = $userdata['user_id'] == GUEST_UID ? "poster_ip = '{$user_ip}'" : 'poster_id = ' . $userdata['user_id'];
        $sql = "SELECT MAX(post_time) AS last_post_time\n\t\t\tFROM " . POSTS_TABLE . "\n\t\t\tWHERE {$where_sql}";
        if ($result = DB()->sql_query($sql)) {
            if ($row = DB()->sql_fetchrow($result)) {
                //			if (intval($row['last_post_time']) > 0 && ($current_time - intval($row['last_post_time'])) < intval($ft_cfg['flood_interval']))
                if (!$is_auth['auth_mod'] && ($row['last_post_time'] > 0 && $current_time - $row['last_post_time'] < $ft_cfg['flood_interval'])) {
                    message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
                }
            }
        }
    }
    //dpc
    if ($mode != 'editpost') {
        $lastposttime = $row['last_post_time'];
        $where_sql = $userdata['user_id'] == GUEST_UID ? "p.poster_ip = '{$user_ip}'" : 'p.poster_id = ' . $userdata['user_id'];
        $sql = "SELECT pt.post_text, pt.bbcode_uid\n\t\t\tFROM " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " pt\n\t\t\tWHERE {$where_sql}\n\t\t\t\tAND p.post_time = {$lastposttime}\n\t\t\t\tAND pt.post_id = p.post_id\n\t\t\tLIMIT 1";
        if ($row = DB()->sql_fetchrow(DB()->sql_query($sql))) {
            DB()->sql_freeresult($result);
            $last_message = addslashes(str_replace($row['bbcode_uid'], $bbcode_uid, $row['post_text']));
            $last_message = str_replace("\\'", "''", $last_message);
            if ($last_message == $post_message) {
                message_die(GENERAL_MESSAGE, $lang['Double_Post_Error']);
            }
        }
    }
    //dpc end
    if ($mode == 'editpost') {
        remove_search_post($post_id);
    }
    if ($mode == 'newtopic' || $mode == 'editpost' && $post_data['first_post']) {
        $topic_vote = !empty($poll_title) && count($poll_options) >= 2 ? 1 : 0;
        //bt
        global $post_info, $is_auth;
        $topic_dl_type = isset($_POST['topic_dl_type']) && ($post_info['topic_dl_type'] || $post_info['allow_dl_topic'] || $is_auth['auth_mod']) ? TOPIC_DL_TYPE_DL : TOPIC_DL_TYPE_NORMAL;
        //	$sql  = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type,                topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type,                 $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type                                 " . (( $post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = $topic_id";
        $sql = $mode != "editpost" ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type, topic_vote) VALUES ('{$post_subject}', " . $userdata['user_id'] . ", {$current_time}, {$forum_id}, " . TOPIC_UNLOCKED . ", {$topic_type}, {$topic_dl_type}, {$topic_vote})" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '{$post_subject}', topic_type = {$topic_type}, topic_dl_type = {$topic_dl_type} " . (@$post_data['edit_vote'] || !empty($poll_title) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = {$topic_id}";
        //bt end
        if (!DB()->sql_query($sql)) {
            message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }
        if ($mode == 'newtopic') {
            $topic_id = DB()->sql_nextid();
        }
    }
    $edited_sql = $mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post'] ? ", post_edit_time = {$current_time}, post_edit_count = post_edit_count + 1 " : "";
    //upt
    $edited_sql .= $update_post_time && $post_data['last_post'] && $mode == 'editpost' && !$post_data['first_post'] ? ", post_time = {$current_time} " : '';
    //upt end
    $sql = $mode != "editpost" ? "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ({$topic_id}, {$forum_id}, " . $userdata['user_id'] . ", '{$post_username}', {$current_time}, '{$user_ip}', {$bbcode_on}, {$html_on}, {$smilies_on}, {$attach_sig})" : "UPDATE " . POSTS_TABLE . " SET post_username = '{$post_username}', enable_bbcode = {$bbcode_on}, enable_html = {$html_on}, enable_smilies = {$smilies_on}, enable_sig = {$attach_sig}" . $edited_sql . " WHERE post_id = {$post_id}";
    if (!DB()->sql_query($sql, BEGIN_TRANSACTION)) {
        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    if ($mode != 'editpost') {
        $post_id = DB()->sql_nextid();
    }
    $sql = $mode != 'editpost' ? "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ({$post_id}, '{$post_subject}', '{$bbcode_uid}', '{$post_message}')" : "UPDATE " . POSTS_TEXT_TABLE . " SET post_text = '{$post_message}',  bbcode_uid = '{$bbcode_uid}', post_subject = '{$post_subject}' WHERE post_id = {$post_id}";
    if (!DB()->sql_query($sql)) {
        message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }
    add_search_words('single', $post_id, stripslashes($post_message), stripslashes($post_subject), $topic_id);
    //
    // Add poll
    //
    if (($mode == 'newtopic' || $mode == 'editpost' && $post_data['edit_poll']) && !empty($poll_title) && count($poll_options) >= 2) {
        $sql = !$post_data['has_poll'] ? "INSERT INTO " . VOTE_DESC_TABLE . " (topic_id, vote_text, vote_start, vote_length) VALUES ({$topic_id}, '{$poll_title}', {$current_time}, " . $poll_length * 86400 . ")" : "UPDATE " . VOTE_DESC_TABLE . " SET vote_text = '{$poll_title}', vote_length = " . $poll_length * 86400 . " WHERE topic_id = {$topic_id}";
        if (!DB()->sql_query($sql)) {
            message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
        }
        $delete_option_sql = '';
        $old_poll_result = array();
        if ($mode == 'editpost' && $post_data['has_poll']) {
            $sql = "SELECT vote_option_id, vote_result\n\t\t\t\tFROM " . VOTE_RESULTS_TABLE . "\n\t\t\t\tWHERE vote_id = {$poll_id}\n\t\t\t\tORDER BY vote_option_id ASC";
            if (!($result = DB()->sql_query($sql))) {
                message_die(GENERAL_ERROR, 'Could not obtain vote data results for this topic', '', __LINE__, __FILE__, $sql);
            }
            while ($row = DB()->sql_fetchrow($result)) {
                $old_poll_result[$row['vote_option_id']] = $row['vote_result'];
                if (!isset($poll_options[$row['vote_option_id']])) {
                    $delete_option_sql .= $delete_option_sql != '' ? ', ' . $row['vote_option_id'] : $row['vote_option_id'];
                }
            }
        } else {
            $poll_id = DB()->sql_nextid();
        }
        @reset($poll_options);
        $poll_option_id = 1;
        while (list($option_id, $option_text) = each($poll_options)) {
            if (!empty($option_text)) {
//.........这里部分代码省略.........
开发者ID:forummaks,项目名称:forum_maks,代码行数:101,代码来源:functions_post.php

示例11: append_sid

         echo '<p class="gen"><b>' . $lang['Unlock_db'] . "</b></p>\n";
         echo '<p class="gen">' . $lang['Ignore_unlock_command'] . "</p>\n";
     }
     echo "<p class=\"gen\"><a href=\"" . append_sid("admin_db_maintenance.{$phpEx}") . "\">" . $lang['Back_to_DB_Maintenance'] . "</a></p>\n";
     // Send Information about processing time
     echo '<p class="gensmall">' . sprintf($lang['Processing_time'], getmicrotime() - $timer) . '</p>';
     include './page_footer_admin.' . $phpEx;
     exit;
 }
 $last_post = 0;
 switch ($php_ver) {
     case 3:
         // use standard method if we have PHP 3
         while ($row) {
             $last_post = $row['post_id'];
             add_search_words('single', $last_post, stripslashes($row['post_text']), stripslashes($row['post_subject']));
             $row = $db->sql_fetchrow($result);
         }
         break;
     case 4:
         // use advanced method if we have PHP 4+ (we can make use of the advanced array functions)
         $post_size = strlen($row['post_text']) + strlen($row['post_subject']);
         // needed for controlling array size
         // get stopword and synonym array
         $stopword_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_stopwords.txt");
         $synonym_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . "/search_synonyms.txt");
         if (!is_array($stopword_array)) {
             $stopword_array = array();
         }
         if (!is_array($synonym_array)) {
             $synonym_array = array();
开发者ID:Nekrofage,项目名称:FJR,代码行数:31,代码来源:admin_db_maintenance.php

示例12: submit_post


//.........这里部分代码省略.........
            $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 = '" . $db->sql_escape($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;
}
开发者ID:ALTUN69,项目名称:icy_phoenix,代码行数:101,代码来源:functions_post.php

示例13: message_die

            break;
        }
        $sql = "SELECT post_id FROM " . POSTS_TEXT_TABLE . " LIMIT " . $i . ",1";
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, $lang_admin_wsr['Error_Find_Posts'], "", __LINE__, __FILE__, $sql);
        }
        $posts = $db->sql_fetchrow($result);
        $activeid = $posts['post_id'];
        $sql = "SELECT * FROM " . POSTS_TEXT_TABLE . " WHERE post_id = " . $activeid;
        $result = $db->sql_query($sql);
        if (!$result) {
            message_die(GENERAL_ERROR, $lang_admin_wsr['Error_Find_Posts'], "", __LINE__, __FILE__, $sql);
        }
        $activepost = $db->sql_fetchrowset($result);
        add_search_words('single', $activepost[0]['post_id'], stripslashes($activepost[0]['post_text']), stripslashes($activepost[0]['post_subject']));
    }
    if ($nextpage == 1) {
        $template->assign_vars(array('META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("admin_rebuild_search.{$phpEx}?start_id={$i}") . '">'));
        $message = $i . $lang_admin_wsr['Posts_Complete'];
        $message .= "<br /><br />" . sprintf($lang_admin_wsr['Click_Here'], "<a href=\"" . append_sid("admin_rebuild_search.{$phpEx}?start_id={$i}") . "\">", "</a>");
        message_die(GENERAL_MESSAGE, $message);
    } else {
        $message = $lang_admin_wsr['Rebuild_Successful'];
        $message .= "<br /><br />" . sprintf($lang_admin_wsr['Return_Rebuild'], "<a href=\"" . append_sid("admin_rebuild_search.{$phpEx}") . "\">", "</a>") . "<br /><br />" . sprintf($lang_admin_wsr['Return_Index'], "<a href=\"" . append_sid("admin.{$phpEx}?pane=right") . "\">", "</a>");
        message_die(GENERAL_MESSAGE, $message);
    }
}
$template->set_filenames(array("body" => "admin/rebuild_search_body.tpl"));
$template->assign_vars(array("S_FORM_ACTION" => append_sid("admin_rebuild_search.{$phpEx}?start_id=0"), "L_INFO" => $output_info, "L_REBUILD_SEARCH_TITLE" => $lang_admin_wsr['Rebuild_Search_Title'], "L_REBUILD_SEARCH_EXPLAIN" => $lang_admin_wsr['Rebuild_Search_Explaine'], "L_REBUILD_SEARCH_SUBMIT" => $lang_admin_wsr['Button_Rebuild']));
include $phpbb_root_path . 'admin/page_header_admin.' . $phpEx;
开发者ID:nmpetkov,项目名称:ZphpBB2,代码行数:31,代码来源:admin_rebuild_search.php

示例14: submit_post

function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length, &$topic_icon)
{
    global $board_config, $lang, $db, $phpbb_root_path;
    global $userdata, $userinfo;
    include "includes/phpBB/functions_search.php";
    $current_time = time();
    if ($mode == 'newtopic' || $mode == 'reply' || $mode == 'editpost') {
        //
        // Flood control
        //
        $where_sql = $userdata['user_id'] > ANONYMOUS ? 'poster_id = ' . $userdata['user_id'] : 'poster_ip=' . $userinfo['user_ip'];
        $sql = "SELECT MAX(post_time) AS last_post_time FROM " . POSTS_TABLE . " WHERE {$where_sql}";
        $result = $db->sql_query($sql);
        if ($row = $db->sql_fetchrow($result)) {
            if (intval($row['last_post_time']) > 0 && $current_time - intval($row['last_post_time']) < intval($board_config['flood_interval'])) {
                message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
            }
        }
    }
    if ($mode == 'editpost') {
        remove_search_post($post_id);
    }
    if ($mode == 'newtopic' || $mode == 'editpost' && $post_data['first_post']) {
        $topic_vote = !empty($poll_title) && count($poll_options) >= 2 ? 1 : 0;
        if ($mode != "editpost") {
            $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote, icon_id) VALUES ('{$post_subject}', " . $userdata['user_id'] . ", {$current_time}, {$forum_id}, " . TOPIC_UNLOCKED . ", {$topic_type}, {$topic_vote}, {$topic_icon})";
        } else {
            $sql = "UPDATE " . TOPICS_TABLE . " SET topic_title = '{$post_subject}', topic_type = {$topic_type}, icon_id = {$topic_icon} " . (!empty($poll_title) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = {$topic_id}";
        }
        $db->sql_query($sql);
        if ($mode == 'newtopic') {
            $topic_id = $db->sql_nextid('topic_id');
        }
    }
    $edited_sql = $mode == 'editpost' && !$post_data['last_post'] && $post_data['poster_post'] ? ", post_edit_time = {$current_time}, post_edit_count = post_edit_count + 1 " : "";
    if ($mode != "editpost") {
        $sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ({$topic_id}, {$forum_id}, " . $userdata['user_id'] . ", '{$post_username}', {$current_time}, " . $userinfo['user_ip'] . ", {$bbcode_on}, {$html_on}, {$smilies_on}, {$attach_sig})";
    } else {
        $sql = "UPDATE " . POSTS_TABLE . " SET post_username = '{$post_username}', enable_bbcode = {$bbcode_on}, enable_html = {$html_on}, enable_smilies = {$smilies_on}, enable_sig = {$attach_sig}" . $edited_sql . " WHERE post_id = {$post_id}";
    }
    $db->sql_query($sql);
    if ($mode != 'editpost') {
        $post_id = $db->sql_nextid('post_id');
    }
    $sql = $mode != 'editpost' ? "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, post_text) VALUES ({$post_id}, '{$post_subject}', '{$post_message}')" : "UPDATE " . POSTS_TEXT_TABLE . " SET post_text = '{$post_message}',  post_subject = '{$post_subject}' WHERE post_id = {$post_id}";
    $db->sql_query($sql);
    add_search_words('single', $post_id, $post_message, $post_subject);
    //
    // Add poll
    //
    if (($mode == 'newtopic' || $mode == 'editpost' && $post_data['edit_poll']) && !empty($poll_title) && count($poll_options) >= 2) {
        $sql = !$post_data['has_poll'] ? "INSERT INTO " . VOTE_DESC_TABLE . " (topic_id, vote_text, vote_start, vote_length) VALUES ({$topic_id}, '{$poll_title}', {$current_time}, " . $poll_length * 86400 . ")" : "UPDATE " . VOTE_DESC_TABLE . " SET vote_text = '{$poll_title}', vote_length = " . $poll_length * 86400 . " 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 vote_option_id, vote_result FROM " . VOTE_RESULTS_TABLE . "\n\t\t\t\tWHERE vote_id = {$poll_id} ORDER BY vote_option_id ASC";
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $old_poll_result[$row['vote_option_id']] = $row['vote_result'];
                if (!isset($poll_options[$row['vote_option_id']])) {
                    $delete_option_sql .= $delete_option_sql != '' ? ', ' . $row['vote_option_id'] : $row['vote_option_id'];
                }
            }
        } else {
            $poll_id = $db->sql_nextid('vote_id');
        }
        reset($poll_options);
        $poll_option_id = 1;
        foreach ($poll_options as $option_id => $option_text) {
            if (!empty($option_text)) {
                $option_text = Fix_Quotes($option_text);
                $poll_result = $mode == "editpost" && isset($old_poll_result[$option_id]) ? $old_poll_result[$option_id] : 0;
                if ($mode != "editpost" || !isset($old_poll_result[$option_id])) {
                    $sql = "INSERT INTO " . VOTE_RESULTS_TABLE . " (vote_id, vote_option_id, vote_option_text, vote_result) VALUES ({$poll_id}, {$poll_option_id}, '{$option_text}', {$poll_result})";
                } else {
                    $sql = "UPDATE " . VOTE_RESULTS_TABLE . " SET vote_option_text = '{$option_text}', vote_result = {$poll_result} WHERE vote_option_id = {$option_id} AND vote_id = {$poll_id}";
                }
                $db->sql_query($sql);
                $poll_option_id++;
            }
        }
        if ($delete_option_sql != '') {
            $db->sql_query("DELETE FROM " . VOTE_RESULTS_TABLE . " WHERE vote_option_id IN ({$delete_option_sql}) AND vote_id = {$poll_id}");
        }
    }
    URL::refresh(URL::index("&file=viewtopic&" . POST_POST_URL . "=" . $post_id) . '#' . $post_id);
    $message = $lang['Stored'] . '<br /><br />' . sprintf($lang['Click_view_message'], '<a href="' . URL::index("&amp;file=viewtopic&amp;" . POST_POST_URL . "=" . $post_id) . '#' . $post_id . '">', '</a>') . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . URL::index("&amp;file=viewforum&amp;" . POST_FORUM_URL . "={$forum_id}") . '">', '</a>');
    return false;
}
开发者ID:cbsistem,项目名称:nexos,代码行数:90,代码来源:functions_post.php


注:本文中的add_search_words函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。