本文整理汇总了PHP中text2words函数的典型用法代码示例。如果您正苦于以下问题:PHP text2words函数的具体用法?PHP text2words怎么用?PHP text2words使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了text2words函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: prepareIndexes
public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded)
{
global $modSettings;
$subwords = text2words($word, null, false);
$fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"';
$wordsSearch['indexed_words'][] = $fulltextWord;
if ($isExcluded) {
$wordsExclude[] = $fulltextWord;
}
}
开发者ID:norv,项目名称:EosAlpha,代码行数:10,代码来源:SearchAPI-Sphinxql.php
示例2: prepareIndexes
public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded)
{
global $modSettings, $smcFunc;
$subwords = text2words($word, $this->min_word_length, false);
// Excluded phrases don't benefit from being split into subwords.
if (count($subwords) > 1 && $isExcluded) {
return;
} else {
foreach ($subwords as $subword) {
if (commonAPI::strlen($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) {
$wordsSearch['indexed_words'][] = $subword;
if ($isExcluded) {
$wordsExclude[] = $subword;
}
}
}
}
}
开发者ID:norv,项目名称:EosAlpha,代码行数:18,代码来源:SearchAPI-Sphinx.php
示例3: prepareIndexes
public function prepareIndexes($word, &$wordsSearch, &$wordsExclude, $isExcluded)
{
global $modSettings, $smcFunc;
$subwords = text2words($word, $this->min_word_length, true);
if (empty($modSettings['search_force_index'])) {
$wordsSearch['words'][] = $word;
}
// Excluded phrases don't benefit from being split into subwords.
if (count($subwords) > 1 && $isExcluded) {
continue;
} else {
foreach ($subwords as $subword) {
if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) {
$wordsSearch['indexed_words'][] = $subword;
if ($isExcluded) {
$wordsExclude[] = $subword;
}
}
}
}
}
开发者ID:valek0972,项目名称:hackits,代码行数:21,代码来源:SearchAPI-Custom.php
示例4: findForumErrors
//.........这里部分代码省略.........
$context['repair_errors'][] = sprintf($txt['repair_missing_senders'], $row['ID_PM'], $row['ID_MEMBER_FROM']);
}
if (mysql_num_rows($result) != 0) {
$to_fix[] = 'missing_senders';
}
mysql_free_result($result);
}
$_GET['step'] = 20;
$_GET['substep'] = 0;
pauseRepairProcess($to_fix);
}
if ($_GET['step'] <= 20) {
$result = db_query("\n\t\t\tSELECT MAX(ID_MEMBER)\n\t\t\tFROM {$db_prefix}log_notify", __FILE__, __LINE__);
list($members) = mysql_fetch_row($result);
mysql_free_result($result);
for (; $_GET['substep'] < $members; $_GET['substep'] += 500) {
pauseRepairProcess($to_fix, $members);
$result = db_query("\n\t\t\t\tSELECT ln.ID_MEMBER\n\t\t\t\tFROM {$db_prefix}log_notify AS ln\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = ln.ID_MEMBER)\n\t\t\t\tWHERE ln.ID_MEMBER BETWEEN {$_GET['substep']} AND {$_GET['substep']} + 499\n\t\t\t\t\tAND mem.ID_MEMBER IS NULL\n\t\t\t\tGROUP BY ln.ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result)) {
$context['repair_errors'][] = sprintf($txt['repair_missing_notify_members'], $row['ID_MEMBER']);
}
if (mysql_num_rows($result) != 0) {
$to_fix[] = 'missing_notify_members';
}
mysql_free_result($result);
}
$_GET['step'] = 21;
$_GET['substep'] = 0;
pauseRepairProcess($to_fix);
}
if ($_GET['step'] <= 21) {
$request = db_query("\n\t\t\tSELECT t.ID_TOPIC, fm.subject\n\t\t\tFROM ({$db_prefix}topics AS t, {$db_prefix}messages AS fm)\n\t\t\t\tLEFT JOIN {$db_prefix}log_search_subjects AS lss ON (lss.ID_TOPIC = t.ID_TOPIC)\n\t\t\tWHERE fm.ID_MSG = t.ID_FIRST_MSG\n\t\t\t\tAND lss.ID_TOPIC IS NULL", __FILE__, __LINE__);
$found_error = false;
while ($row = mysql_fetch_assoc($request)) {
if (count(text2words($row['subject'])) != 0) {
$context['repair_errors'][] = sprintf($txt['repair_missing_cached_subject'], $row['ID_TOPIC']);
$found_error = true;
}
}
mysql_free_result($request);
if ($found_error) {
$to_fix[] = 'missing_cached_subject';
}
$_GET['step'] = 22;
$_GET['substep'] = 0;
pauseRepairProcess($to_fix);
}
if ($_GET['step'] <= 22) {
$request = db_query("\n\t\t\tSELECT lss.word\n\t\t\tFROM {$db_prefix}log_search_subjects AS lss\n\t\t\t\tLEFT JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = lss.ID_TOPIC)\n\t\t\tWHERE t.ID_TOPIC IS NULL", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request)) {
$context['repair_errors'][] = sprintf($txt['repair_missing_topic_for_cache'], htmlspecialchars($row['word']));
}
if (mysql_num_rows($request) != 0) {
$to_fix[] = 'missing_topic_for_cache';
}
mysql_free_result($request);
$_GET['step'] = 23;
$_GET['substep'] = 0;
pauseRepairProcess($to_fix);
}
if ($_GET['step'] <= 23) {
$result = db_query("\n\t\t\tSELECT MAX(ID_MEMBER)\n\t\t\tFROM {$db_prefix}log_polls", __FILE__, __LINE__);
list($members) = mysql_fetch_row($result);
mysql_free_result($result);
for (; $_GET['substep'] < $members; $_GET['substep'] += 500) {
$result = db_query("\n\t\t\t\tSELECT lp.ID_POLL, lp.ID_MEMBER\n\t\t\t\tFROM {$db_prefix}log_polls AS lp\n\t\t\t\t\tLEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lp.ID_MEMBER)\n\t\t\t\tWHERE lp.ID_MEMBER BETWEEN {$_GET['substep']} AND {$_GET['substep']} + 499\n\t\t\t\t\tAND mem.ID_MEMBER IS NULL\n\t\t\t\tGROUP BY lp.ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result)) {
$context['repair_errors'][] = sprintf($txt['repair_missing_log_poll_member'], $row['ID_POLL'], $row['ID_MEMBER']);
}
if (mysql_num_rows($result) != 0) {
$to_fix[] = 'missing_member_vote';
}
mysql_free_result($result);
pauseRepairProcess($to_fix, $members);
}
$_GET['step'] = 24;
$_GET['substep'] = 0;
pauseRepairProcess($to_fix);
}
if ($_GET['step'] <= 24) {
$result = db_query("\n\t\t\tSELECT MAX(ID_POLL)\n\t\t\tFROM {$db_prefix}log_polls", __FILE__, __LINE__);
list($polls) = mysql_fetch_row($result);
mysql_free_result($result);
for (; $_GET['substep'] < $polls; $_GET['substep'] += 500) {
pauseRepairProcess($to_fix, $polls);
$result = db_query("\n\t\t\t\tSELECT lp.ID_POLL, lp.ID_MEMBER\n\t\t\t\tFROM {$db_prefix}log_polls AS lp\n\t\t\t\t\tLEFT JOIN {$db_prefix}polls AS p ON (p.ID_POLL = lp.ID_POLL)\n\t\t\t\tWHERE lp.ID_POLL BETWEEN {$_GET['substep']} AND {$_GET['substep']} + 499\n\t\t\t\t\tAND p.ID_POLL IS NULL\n\t\t\t\tGROUP BY lp.ID_POLL", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result)) {
$context['repair_errors'][] = sprintf($txt['repair_missing_log_poll_vote'], $row['ID_MEMBER'], $row['ID_POLL']);
}
if (mysql_num_rows($result) != 0) {
$to_fix[] = 'missing_log_poll_vote';
}
mysql_free_result($result);
}
$_GET['step'] = 25;
$_GET['substep'] = 0;
pauseRepairProcess($to_fix);
}
return $to_fix;
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:101,代码来源:RepairBoards.php
示例5: CreateMessageIndex
/**
* Create a custom search index for the messages table.
* Called by ?action=admin;area=managesearch;sa=createmsgindex.
* Linked from the EditSearchMethod screen.
* Requires the admin_forum permission.
* Depending on the size of the message table, the process is divided in steps.
*
* @uses ManageSearch template, 'create_index', 'create_index_progress', and 'create_index_done'
* sub-templates.
*/
function CreateMessageIndex()
{
global $modSettings, $context, $smcFunc, $db_prefix, $txt;
// Scotty, we need more time...
@set_time_limit(600);
if (function_exists('apache_reset_timeout')) {
@apache_reset_timeout();
}
$context[$context['admin_menu_name']]['current_subsection'] = 'method';
$context['page_title'] = $txt['search_index_custom'];
$messages_per_batch = 50;
$index_properties = array(2 => array('column_definition' => 'small', 'step_size' => 1000000), 4 => array('column_definition' => 'medium', 'step_size' => 1000000, 'max_size' => 16777215), 5 => array('column_definition' => 'large', 'step_size' => 100000000, 'max_size' => 2000000000));
if (isset($_REQUEST['resume']) && !empty($modSettings['search_custom_index_resume'])) {
$context['index_settings'] = unserialize($modSettings['search_custom_index_resume']);
$context['start'] = (int) $context['index_settings']['resume_at'];
unset($context['index_settings']['resume_at']);
$context['step'] = 1;
} else {
$context['index_settings'] = array('bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2);
$context['start'] = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
$context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0;
// admin timeouts are painful when building these long indexes
if ($_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) {
$_SESSION['admin_time'] = time();
}
}
if ($context['step'] !== 0) {
checkSession('request');
}
// Step 0: let the user determine how they like their index.
if ($context['step'] === 0) {
$context['sub_template'] = 'create_index';
}
// Step 1: insert all the words.
if ($context['step'] === 1) {
$context['sub_template'] = 'create_index_progress';
if ($context['start'] === 0) {
db_extend();
$tables = $smcFunc['db_list_tables'](false, $db_prefix . 'log_search_words');
if (!empty($tables)) {
$smcFunc['db_search_query']('drop_words_table', '
DROP TABLE {db_prefix}log_search_words', array());
}
$smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']);
// Temporarily switch back to not using a search index.
if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') {
updateSettings(array('search_index' => ''));
}
// Don't let simultanious processes be updating the search index.
if (!empty($modSettings['search_custom_index_config'])) {
updateSettings(array('search_custom_index_config' => ''));
}
}
$num_messages = array('done' => 0, 'todo' => 0);
$request = $smcFunc['db_query']('', '
SELECT id_msg >= {int:starting_id} AS todo, COUNT(*) AS num_messages
FROM {db_prefix}messages
GROUP BY todo', array('starting_id' => $context['start']));
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages'];
}
if (empty($num_messages['todo'])) {
$context['step'] = 2;
$context['percentage'] = 80;
$context['start'] = 0;
} else {
// Number of seconds before the next step.
$stop = time() + 3;
while (time() < $stop) {
$inserts = array();
$request = $smcFunc['db_query']('', '
SELECT id_msg, body
FROM {db_prefix}messages
WHERE id_msg BETWEEN {int:starting_id} AND {int:ending_id}
LIMIT {int:limit}', array('starting_id' => $context['start'], 'ending_id' => $context['start'] + $messages_per_batch - 1, 'limit' => $messages_per_batch));
$forced_break = false;
$number_processed = 0;
while ($row = $smcFunc['db_fetch_assoc']($request)) {
// In theory it's possible for one of these to take friggin ages so add more timeout protection.
if ($stop < time()) {
$forced_break = true;
break;
}
$number_processed++;
foreach (text2words($row['body'], $context['index_settings']['bytes_per_word'], true) as $id_word) {
$inserts[] = array($id_word, $row['id_msg']);
}
}
$num_messages['done'] += $number_processed;
$num_messages['todo'] -= $number_processed;
//.........这里部分代码省略.........
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:101,代码来源:ManageSearch.php
示例6: removeMessage
//.........这里部分代码省略.........
$topicID = empty($id_recycle_topic) ? $smcFunc['db_insert_id']('{db_prefix}topics', 'id_topic') : $id_recycle_topic;
// If the topic creation went successful, move the message.
if ($topicID > 0) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET
id_topic = {int:id_topic},
id_board = {int:recycle_board},
icon = {string:recycled},
approved = {int:is_approved}
WHERE id_msg = {int:id_msg}', array('id_topic' => $topicID, 'recycle_board' => $modSettings['recycle_board'], 'id_msg' => $message, 'recycled' => 'recycled', 'is_approved' => 1));
// Take any reported posts with us...
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_reported
SET
id_topic = {int:id_topic},
id_board = {int:recycle_board}
WHERE id_msg = {int:id_msg}', array('id_topic' => $topicID, 'recycle_board' => $modSettings['recycle_board'], 'id_msg' => $message));
// Mark recycled topic as read.
if (!$user_info['is_guest']) {
$smcFunc['db_insert']('replace', '{db_prefix}log_topics', array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), array($topicID, $user_info['id'], $modSettings['maxMsgID']), array('id_topic', 'id_member'));
}
// Mark recycle board as seen, if it was marked as seen before.
if (!empty($isRead) && !$user_info['is_guest']) {
$smcFunc['db_insert']('replace', '{db_prefix}log_boards', array('id_board' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), array($modSettings['recycle_board'], $user_info['id'], $modSettings['maxMsgID']), array('id_board', 'id_member'));
}
// Add one topic and post to the recycle bin board.
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET
num_topics = num_topics + {int:num_topics_inc},
num_posts = num_posts + 1' . ($message > $last_board_msg ? ', id_last_msg = {int:id_merged_msg}' : '') . '
WHERE id_board = {int:recycle_board}', array('num_topics_inc' => empty($id_recycle_topic) ? 1 : 0, 'recycle_board' => $modSettings['recycle_board'], 'id_merged_msg' => $message));
// Lets increase the num_replies, and the first/last message ID as appropriate.
if (!empty($id_recycle_topic)) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}topics
SET num_replies = num_replies + 1' . ($message > $last_topic_msg ? ', id_last_msg = {int:id_merged_msg}' : '') . ($message < $first_topic_msg ? ', id_first_msg = {int:id_merged_msg}' : '') . '
WHERE id_topic = {int:id_recycle_topic}', array('id_recycle_topic' => $id_recycle_topic, 'id_merged_msg' => $message));
}
// Make sure this message isn't getting deleted later on.
$recycle = true;
// Make sure we update the search subject index.
updateStats('subject', $topicID, $row['subject']);
}
// If it wasn't approved don't keep it in the queue.
if (!$row['approved']) {
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}approval_queue
WHERE id_msg = {int:id_msg}
AND id_attach = {int:id_attach}', array('id_msg' => $message, 'id_attach' => 0));
}
}
$smcFunc['db_query']('', '
UPDATE {db_prefix}boards
SET ' . ($row['approved'] ? '
num_posts = CASE WHEN num_posts = {int:no_posts} THEN 0 ELSE num_posts - 1 END' : '
unapproved_posts = CASE WHEN unapproved_posts = {int:no_unapproved} THEN 0 ELSE unapproved_posts - 1 END') . '
WHERE id_board = {int:id_board}', array('no_posts' => 0, 'no_unapproved' => 0, 'id_board' => $row['id_board']));
// If the poster was registered and the board this message was on incremented
// the member's posts when it was posted, decrease his or her post count.
if (!empty($row['id_member']) && $decreasePostCount && empty($row['count_posts']) && $row['approved']) {
updateMemberData($row['id_member'], array('posts' => '-'));
}
// Only remove posts if they're not recycled.
if (!$recycle) {
// Remove the message!
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}messages
WHERE id_msg = {int:id_msg}', array('id_msg' => $message));
if (!empty($modSettings['search_custom_index_config'])) {
$customIndexSettings = unserialize($modSettings['search_custom_index_config']);
$words = text2words($row['body'], $customIndexSettings['bytes_per_word'], true);
if (!empty($words)) {
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_search_words
WHERE id_word IN ({array_int:word_list})
AND id_msg = {int:id_msg}', array('word_list' => $words, 'id_msg' => $message));
}
}
// Delete attachment(s) if they exist.
require_once $sourcedir . '/ManageAttachments.php';
$attachmentQuery = array('attachment_type' => 0, 'id_msg' => $message);
removeAttachments($attachmentQuery);
// Allow mods to remove message related data of their own (likes, maybe?)
call_integration_hook('integrate_remove_message', array($message));
}
// Update the pesky statistics.
updateStats('message');
updateStats('topic');
updateSettings(array('calendar_updated' => time()));
// And now to update the last message of each board we messed with.
require_once $sourcedir . '/Subs-Post.php';
if ($recycle) {
updateLastMessages(array($row['id_board'], $modSettings['recycle_board']));
} else {
updateLastMessages($row['id_board']);
}
return false;
}
开发者ID:Glyph13,项目名称:SMF2.1,代码行数:101,代码来源:RemoveTopic.php
示例7: modifyPost
function modifyPost(&$msgOptions, &$topicOptions, &$posterOptions)
{
global $user_info, $modSettings, $smcFunc, $context;
$topicOptions['poll'] = isset($topicOptions['poll']) ? (int) $topicOptions['poll'] : null;
$topicOptions['lock_mode'] = isset($topicOptions['lock_mode']) ? $topicOptions['lock_mode'] : null;
$topicOptions['sticky_mode'] = isset($topicOptions['sticky_mode']) ? $topicOptions['sticky_mode'] : null;
// This is longer than it has to be, but makes it so we only set/change what we have to.
$messages_columns = array();
if (isset($posterOptions['name'])) {
$messages_columns['poster_name'] = $posterOptions['name'];
}
if (isset($posterOptions['email'])) {
$messages_columns['poster_email'] = $posterOptions['email'];
}
if (isset($msgOptions['icon'])) {
$messages_columns['icon'] = $msgOptions['icon'];
}
if (isset($msgOptions['subject'])) {
$messages_columns['subject'] = $msgOptions['subject'];
}
if (isset($msgOptions['body'])) {
$messages_columns['body'] = $msgOptions['body'];
if (!empty($modSettings['search_custom_index_config'])) {
$request = $smcFunc['db_query']('', '
SELECT body
FROM {db_prefix}messages
WHERE id_msg = {int:id_msg}', array('id_msg' => $msgOptions['id']));
list($old_body) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
}
}
if (!empty($msgOptions['modify_time'])) {
$messages_columns['modified_time'] = $msgOptions['modify_time'];
$messages_columns['modified_name'] = $msgOptions['modify_name'];
$messages_columns['id_msg_modified'] = $modSettings['maxMsgID'];
}
if (isset($msgOptions['smileys_enabled'])) {
$messages_columns['smileys_enabled'] = empty($msgOptions['smileys_enabled']) ? 0 : 1;
}
// Which columns need to be ints?
$messageInts = array('modified_time', 'id_msg_modified', 'smileys_enabled');
$update_parameters = array('id_msg' => $msgOptions['id']);
foreach ($messages_columns as $var => $val) {
$messages_columns[$var] = $var . ' = {' . (in_array($var, $messageInts) ? 'int' : 'string') . ':var_' . $var . '}';
$update_parameters['var_' . $var] = $val;
}
// Nothing to do?
if (empty($messages_columns)) {
return true;
}
// Change the post.
$smcFunc['db_query']('', '
UPDATE {db_prefix}messages
SET ' . implode(', ', $messages_columns) . '
WHERE id_msg = {int:id_msg}', $update_parameters);
// Lock and or sticky the post.
if ($topicOptions['sticky_mode'] !== null || $topicOptions['lock_mode'] !== null || $topicOptions['poll'] !== null) {
$smcFunc['db_query']('', '
UPDATE {db_prefix}topics
SET
is_sticky = {raw:is_sticky},
locked = {raw:locked},
id_poll = {raw:id_poll}
WHERE id_topic = {int:id_topic}', array('is_sticky' => $topicOptions['sticky_mode'] === null ? 'is_sticky' : (int) $topicOptions['sticky_mode'], 'locked' => $topicOptions['lock_mode'] === null ? 'locked' : (int) $topicOptions['lock_mode'], 'id_poll' => $topicOptions['poll'] === null ? 'id_poll' : (int) $topicOptions['poll'], 'id_topic' => $topicOptions['id']));
}
// Mark the edited post as read.
if (!empty($topicOptions['mark_as_read']) && !$user_info['is_guest']) {
// Since it's likely they *read* it before editing, let's try an UPDATE first.
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_topics
SET id_msg = {int:id_msg}
WHERE id_member = {int:current_member}
AND id_topic = {int:id_topic}', array('current_member' => $user_info['id'], 'id_msg' => $modSettings['maxMsgID'], 'id_topic' => $topicOptions['id']));
$flag = $smcFunc['db_affected_rows']() != 0;
if (empty($flag)) {
$smcFunc['db_insert']('ignore', '{db_prefix}log_topics', array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), array($topicOptions['id'], $user_info['id'], $modSettings['maxMsgID']), array('id_topic', 'id_member'));
}
}
// If there's a custom search index, it needs to be modified...
if (isset($msgOptions['body']) && !empty($modSettings['search_custom_index_config'])) {
$customIndexSettings = unserialize($modSettings['search_custom_index_config']);
$stopwords = empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']);
$old_index = text2words($old_body, $customIndexSettings['bytes_per_word'], true);
$new_index = text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true);
// Calculate the words to be added and removed from the index.
$removed_words = array_diff(array_diff($old_index, $new_index), $stopwords);
$inserted_words = array_diff(array_diff($new_index, $old_index), $stopwords);
// Delete the removed words AND the added ones to avoid key constraints.
if (!empty($removed_words)) {
$removed_words = array_merge($removed_words, $inserted_words);
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_search_words
WHERE id_msg = {int:id_msg}
AND id_word IN ({array_int:removed_words})', array('removed_words' => $removed_words, 'id_msg' => $msgOptions['id']));
}
// Add the new words to be indexed.
if (!empty($inserted_words)) {
$inserts = array();
foreach ($inserted_words as $word) {
$inserts[] = array($word, $msgOptions['id']);
//.........这里部分代码省略.........
开发者ID:AhoyLemon,项目名称:ballpit,代码行数:101,代码来源:Subs-Post.php
示例8: updateStats
function updateStats($type, $parameter1 = null, $parameter2 = null)
{
global $sourcedir, $modSettings, $smcFunc;
switch ($type) {
case 'member':
$changes = array('memberlist_updated' => time());
// #1 latest member ID, #2 the real name for a new registration.
if (is_numeric($parameter1)) {
$changes['latestMember'] = $parameter1;
$changes['latestRealName'] = $parameter2;
updateSettings(array('totalMembers' => true), true);
} else {
// Update the latest activated member (highest id_member) and count.
$result = $smcFunc['db_query']('', '
SELECT COUNT(*), MAX(id_member)
FROM {db_prefix}members
WHERE is_activated = {int:is_activated}', array('is_activated' => 1));
list($changes['totalMembers'], $changes['latestMember']) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);
// Get the latest activated member's display name.
$result = $smcFunc['db_query']('', '
SELECT real_name
FROM {db_prefix}members
WHERE id_member = {int:id_member}
LIMIT 1', array('id_member' => (int) $changes['latestMember']));
list($changes['latestRealName']) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);
// Are we using registration approval?
if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 2 || !empty($modSettings['approveAccountDeletion'])) {
// Update the amount of members awaiting approval - ignoring COPPA accounts, as you can't approve them until you get permission.
$result = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}members
WHERE is_activated IN ({array_int:activation_status})', array('activation_status' => array(3, 4)));
list($changes['unapprovedMembers']) = $smcFunc['db_fetch_row']($result);
$smcFunc['db_free_result']($result);
}
}
updateSettings($changes);
break;
case 'message':
if ($parameter1 === true && $parameter2 !== null) {
updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
} else {
// SUM and MAX on a smaller table is better for InnoDB tables.
$result = $smcFunc['db_query']('', '
SELECT SUM(num_posts + unapproved_posts) AS total_messages, MAX(id_last_msg) AS max_msg_id
FROM {db_prefix}boards
WHERE redirect = {string:blank_redirect}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND id_board != {int:recycle_board}' : ''), array('recycle_board' => isset($modSettings['recycle_board']) ? $modSettings['recycle_board'] : 0, 'blank_redirect' => ''));
$row = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);
updateSettings(array('totalMessages' => $row['total_messages'] === null ? 0 : $row['total_messages'], 'maxMsgID' => $row['max_msg_id'] === null ? 0 : $row['max_msg_id']));
}
break;
case 'subject':
// Remove the previous subject (if any).
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_search_subjects
WHERE id_topic = {int:id_topic}', array('id_topic' => (int) $parameter1));
// Insert the new subject.
if ($parameter2 !== null) {
$parameter1 = (int) $parameter1;
$parameter2 = text2words($parameter2);
$inserts = array();
foreach ($parameter2 as $word) {
$inserts[] = array($word, $parameter1);
}
if (!empty($inserts)) {
$smcFunc['db_insert']('ignore', '{db_prefix}log_search_subjects', array('word' => 'string', 'id_topic' => 'int'), $inserts, array('word', 'id_topic'));
}
}
break;
case 'topic':
if ($parameter1 === true) {
updateSettings(array('totalTopics' => true), true);
} else {
// Get the number of topics - a SUM is better for InnoDB tables.
// We also ignore the recycle bin here because there will probably be a bunch of one-post topics there.
$result = $smcFunc['db_query']('', '
SELECT SUM(num_topics + unapproved_topics) AS total_topics
FROM {db_prefix}boards' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
WHERE id_board != {int:recycle_board}' : ''), array('recycle_board' => !empty($modSettings['recycle_board']) ? $modSettings['recycle_board'] : 0));
$row = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);
updateSettings(array('totalTopics' => $row['total_topics'] === null ? 0 : $row['total_topics']));
}
break;
case 'postgroups':
// Parameter two is the updated columns: we should check to see if we base groups off any of these.
if ($parameter2 !== null && !in_array('posts', $parameter2)) {
return;
}
if (($postgroups = cache_get_data('updateStats:postgroups', 360)) == null) {
// Fetch the postgroups!
$request = $smcFunc['db_query']('', '
SELECT id_group, min_posts
FROM {db_prefix}membergroups
WHERE min_posts != {int:min_posts}', array('min_posts' => -1));
$postgroups = array();
//.........这里部分代码省略.........
开发者ID:AhoyLemon,项目名称:ballpit,代码行数:101,代码来源:Subs.backup.2.php
示例9: modifyPost
//.........这里部分代码省略.........
$context['no_astream'] = true;
}
$context['no_astream'] = isset($context['no_astream']) ? $context['no_astream'] : 0;
// Lock and or sticky the post.
if ($topicOptions['sticky_mode'] !== null || $topicOptions['lock_mode'] !== null || $topicOptions['poll'] !== null) {
smf_db_query('
UPDATE {db_prefix}topics
SET
is_sticky = {raw:is_sticky},
locked = {raw:locked},
id_poll = {raw:id_poll}
WHERE id_topic = {int:id_topic}', array('is_sticky' => $topicOptions['sticky_mode'] === null ? 'is_sticky' : (int) $topicOptions['sticky_mode'], 'locked' => $topicOptions['lock_mode'] === null ? 'locked' : (int) $topicOptions['lock_mode'], 'id_poll' => $topicOptions['poll'] === null ? 'id_poll' : (int) $topicOptions['poll'], 'id_topic' => $topicOptions['id']));
}
if (isset($topicOptions['id_first_msg']) && $msgOptions['id'] == $topicOptions['id_first_msg']) {
if (isset($topicOptions['topic_prefix'])) {
smf_db_query('
UPDATE {db_prefix}topics
SET
id_prefix = {int:id_prefix}
WHERE id_topic = {int:id_topic}', array('id_prefix' => $topicOptions['topic_prefix'], 'id_topic' => $topicOptions['id']));
}
if (isset($topicOptions['topic_layout'])) {
smf_db_query('
UPDATE {db_prefix}topics
SET
id_layout = {int:id_layout}
WHERE id_topic = {int:id_topic}', array('id_layout' => $topicOptions['topic_layout'], 'id_topic' => $topicOptions['id']));
}
}
// Mark the edited post as read.
if (!empty($topicOptions['mark_as_read']) && !$user_info['is_guest']) {
// Since it's likely they *read* it before editing, let's try an UPDATE first.
smf_db_query('
UPDATE {db_prefix}log_topics
SET id_msg = {int:id_msg}
WHERE id_member = {int:current_member}
AND id_topic = {int:id_topic}', array('current_member' => $user_info['id'], 'id_msg' => $modSettings['maxMsgID'], 'id_topic' => $topicOptions['id']));
$flag = smf_db_affected_rows() != 0;
if (empty($flag)) {
smf_db_insert('ignore', '{db_prefix}log_topics', array('id_topic' => 'int', 'id_member' => 'int', 'id_msg' => 'int'), array($topicOptions['id'], $user_info['id'], $modSettings['maxMsgID']), array('id_topic', 'id_member'));
}
}
if (count($tagged_users) > 0) {
notifyTaggedUsers($tagged_users, array('id_topic' => $topicOptions['id'], 'id_message' => $msgOptions['id']));
}
// If there's a custom search index, it needs to be modified...
if (isset($msgOptions['body']) && !empty($modSettings['search_custom_index_config'])) {
$customIndexSettings = unserialize($modSettings['search_custom_index_config']);
$stopwords = empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']);
$old_index = text2words($old_body, $customIndexSettings['bytes_per_word'], true);
$new_index = text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true);
// Calculate the words to be added and removed from the index.
$removed_words = array_diff(array_diff($old_index, $new_index), $stopwords);
$inserted_words = array_diff(array_diff($new_index, $old_index), $stopwords);
// Delete the removed words AND the added ones to avoid key constraints.
if (!empty($removed_words)) {
$removed_words = array_merge($removed_words, $inserted_words);
smf_db_query('
DELETE FROM {db_prefix}log_search_words
WHERE id_msg = {int:id_msg}
AND id_word IN ({array_int:removed_words})', array('removed_words' => $removed_words, 'id_msg' => $msgOptions['id']));
}
// Add the new words to be indexed.
if (!empty($inserted_words)) {
$inserts = array();
foreach ($inserted_words as $word) {
$inserts[] = array($word, $msgOptions['id']);
}
smf_db_insert('insert', '{db_prefix}log_search_words', array('id_word' => 'string', 'id_msg' => 'int'), $inserts, array('id_word', 'id_msg'));
}
}
if (isset($msgOptions['subject'])) {
// Only update the subject if this was the first message in the topic.
$request = smf_db_query('
SELECT id_topic
FROM {db_prefix}topics
WHERE id_first_msg = {int:id_first_msg}
LIMIT 1', array('id_first_msg' => $msgOptions['id']));
if (mysql_num_rows($request) == 1) {
updateStats('subject', $topicOptions['id'], $msgOptions['subject']);
// Added by Related Topics
if (isset($modSettings['have_related_topics']) && $modSettings['have_related_topics']) {
require_once $sourcedir . '/lib/Subs-Related.php';
relatedUpdateTopics($topicOptions['id']);
}
// Related Topics END
}
mysql_free_result($request);
}
// Finally, if we are setting the approved state we need to do much more work :(
if ($modSettings['postmod_active'] && isset($msgOptions['approved'])) {
approvePosts($msgOptions['id'], $msgOptions['approved']);
}
// record in activity stream
if ($modSettings['astream_active'] && !$context['no_astream']) {
require_once $sourcedir . '/lib/Subs-Activities.php';
aStreamAdd($user_info['id'], ACT_MODIFY_POST, array('member_name' => $user_info['name'], 'topic_title' => $msgOptions['subject']), $topicOptions['board'], $topicOptions['id'], $msgOptions['id'], $msgOptions['id_owner']);
}
return true;
}
开发者ID:norv,项目名称:EosAlpha,代码行数:101,代码来源:Subs-Post.php
示例10: updateStats
function updateStats($type, $parameter1 = null, $parameter2 = null)
{
global $db_prefix, $sourcedir, $modSettings;
switch ($type) {
case 'member':
$changes = array('memberlist_updated' => time());
// Are we using registration approval?
if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 2) {
// Update the latest activated member (highest ID_MEMBER) and count.
$result = db_query("\n\t\t\t\tSELECT COUNT(*), MAX(ID_MEMBER)\n\t\t\t\tFROM {$db_prefix}members\n\t\t\t\tWHERE is_activated = 1", __FILE__, __LINE__);
list($changes['totalMembers'], $changes['latestMember']) = mysql_fetch_row($result);
mysql_free_result($result);
// Get the latest activated member's display name.
$result = db_query("\n\t\t\t\tSELECT realName\n\t\t\t\tFROM {$db_prefix}members\n\t\t\t\tWHERE ID_MEMBER = " . (int) $changes['latestMember'] . "\n\t\t\t\tLIMIT 1", __FILE__, __LINE__);
list($changes['latestRealName']) = mysql_fetch_row($result);
mysql_free_result($result);
// Update the amount of members awaiting approval - ignoring COPPA accounts, as you can't approve them until you get permission.
$result = db_query("\n\t\t\t\tSELECT COUNT(*)\n\t\t\t\tFROM {$db_prefix}members\n\t\t\t\tWHERE is_activated IN (3, 4)", __FILE__, __LINE__);
list($changes['unapprovedMembers']) = mysql_fetch_row($result);
mysql_free_result($result);
} elseif ($parameter1 !== null && $parameter1 !== false) {
$changes['latestMember'] = $parameter1;
$changes['latestRealName'] = $parameter2;
updateSettings(array('totalMembers' => true), true);
} elseif ($parameter1 !== false) {
// Update the latest member (highest ID_MEMBER) and count.
$result = db_query("\n\t\t\t\tSELECT COUNT(*), MAX(ID_MEMBER)\n\t\t\t\tFROM {$db_prefix}members", __FILE__, __LINE__);
list($changes['totalMembers'], $changes['latestMember']) = mysql_fetch_row($result);
mysql_free_result($result);
// Get the latest member's display name.
$result = db_query("\n\t\t\t\tSELECT realName\n\t\t\t\tFROM {$db_prefix}members\n\t\t\t\tWHERE ID_MEMBER = " . (int) $changes['latestMember'] . "\n\t\t\t\tLIMIT 1", __FILE__, __LINE__);
list($changes['latestRealName']) = mysql_fetch_row($result);
mysql_free_result($result);
}
updateSettings($changes);
break;
case 'message':
if ($parameter1 === true && $parameter2 !== null) {
updateSettings(array('totalMessages' => true, 'maxMsgID' => $parameter2), true);
} else {
// SUM and MAX on a smaller table is better for InnoDB tables.
$result = db_query("\n\t\t\t\tSELECT SUM(numPosts) AS totalMessages, MAX(ID_LAST_MSG) AS maxMsgID\n\t\t\t\tFROM {$db_prefix}boards", __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
updateSettings(array('totalMessages' => $row['totalMessages'], 'maxMsgID' => $row['maxMsgID'] === null ? 0 : $row['maxMsgID']));
}
break;
case 'subject':
// Remove the previous subject (if any).
db_query("\n\t\t\tDELETE FROM {$db_prefix}log_search_subjects\n\t\t\tWHERE ID_TOPIC = " . (int) $parameter1, __FILE__, __LINE__);
// Insert the new subject.
if ($parameter2 !== null) {
$parameter1 = (int) $parameter1;
$parameter2 = text2words($parameter2);
$inserts = array();
foreach ($parameter2 as $word) {
$inserts[] = "'{$word}', {$parameter1}";
}
if (!empty($inserts)) {
db_query("\n\t\t\t\t\tINSERT IGNORE INTO {$db_prefix}log_search_subjects\n\t\t\t\t\t\t(word, ID_TOPIC)\n\t\t\t\t\tVALUES (" . implode('),
(', array_unique($inserts)) . ")", __FILE__, __LINE__);
}
}
break;
case 'topic':
if ($parameter1 === true) {
updateSettings(array('totalTopics' => true), true);
} else {
// Get the number of topics - a SUM is better for InnoDB tables.
// We also ignore the recycle bin here because there will probably be a bunch of one-post topics there.
$result = db_query("\n\t\t\t\tSELECT SUM(numTopics) AS totalTopics\n\t\t\t\tFROM {$db_prefix}boards" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "\n\t\t\t\tWHERE ID_BOARD != {$modSettings['recycle_board']}" : ''), __FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
mysql_free_result($result);
updateSettings(array('totalTopics' => $row['totalTopics']));
}
break;
case 'calendar':
require_once $sourcedir . '/Calendar.php';
// Calculate the YYYY-MM-DD of the lowest and highest days.
$low_date = strftime('%Y-%m-%d', forum_time(false) - 24 * 3600);
$high_date = strftime('%Y-%m-%d', forum_time(false) + $modSettings['cal_days_for_index'] * 24 * 3600);
$holidays = calendarHolidayArray($low_date, $high_date);
$bday = calendarBirthdayArray($low_date, $high_date);
$events = calendarEventArray($low_date, $high_date, false);
// Cache the results in the settings.
updateSettings(array('cal_today_updated' => strftime('%Y%m%d', forum_time(false)), 'cal_today_holiday' => addslashes(serialize($holidays)), 'cal_today_birthday' => addslashes(serialize($bday)), 'cal_today_event' => addslashes(serialize($events))));
break;
case 'postgroups':
// Parameter two is the updated columns: we should check to see if we base groups off any of these.
if ($parameter2 !== null && !in_array('posts', $parameter2)) {
return;
}
if (($postgroups = cache_get_data('updateStats:postgroups', 360)) == null) {
// Fetch the postgroups!
$request = db_query("\n\t\t\t\tSELECT ID_GROUP, minPosts\n\t\t\t\tFROM {$db_prefix}membergroups\n\t\t\t\tWHERE minPosts != -1", __FILE__, __LINE__);
$postgroups = array();
while ($row = mysql_fetch_assoc($request)) {
$postgroups[$row['ID_GROUP']] = $row['minPosts'];
}
mysql_free_result($request);
//.........这里部分代码省略.........
开发者ID:bbon,项目名称:mjncms,代码行数:101,代码来源:Subs.php
示例11: PlushSearch2
//.........这里部分代码省略.........
// Initialize two arrays storing the words that have to be searched for.
$orParts = array();
$searchWords = array();
// Make sure at least one word is being searched for.
if (empty($searchArray)) {
$context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
} elseif (empty($search_params['searchtype'])) {
$orParts[0] = $searchArray;
} else {
foreach ($searchArray as $index => $value) {
$orParts[$index] = array($value);
}
}
// Don't allow duplicate error messages if one string is too short.
if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) {
unset($context['search_errors']['invalid_search_string']);
}
// Make sure the excluded words are in all or-branches.
foreach ($orParts as $orIndex => $andParts) {
foreach ($excludedWords as $word) {
$orParts[$orIndex][] = $word;
}
}
// Determine the or-branches and the fulltext search words.
foreach ($orParts as $orIndex => $andParts) {
$searchWords[$orIndex] = array('indexed_words' => array(), 'words' => array(), 'subject_words' => array(), 'all_words' => array());
// Sort the indexed words (large words -> small words -> excluded words).
if ($searchAPI->supportsMethod('searchSort')) {
usort($orParts[$orIndex], 'searchSort');
}
foreach ($orParts[$orIndex] as $word) {
$is_excluded = in_array($word, $excludedWords);
$searchWords[$orIndex]['all_words'][] = $word;
$subjectWords = text2words($word);
if (!$is_excluded || count($subjectWords) === 1) {
$searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords);
if ($is_excluded) {
$excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
}
} else {
$excludedPhrases[] = $word;
}
// Have we got indexes to prepare?
if ($searchAPI->supportsMethod('prepareIndexes')) {
$searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
}
}
// Search_force_index requires all AND parts to have at least one fulltext word.
if (!empty($modSettings['search_force_index']) && empty($searchWords[$orIndex]['indexed_words'])) {
$context['search_errors']['query_not_specific_enough'] = true;
break;
} elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords)) {
$context['search_errors']['query_not_specific_enough'] = true;
break;
} else {
$searchWords[$orIndex]['indexed_words'] = array_slice($searchWords[$orIndex]['indexed_words'], 0, 7);
$searchWords[$orIndex]['subject_words'] = array_slice($searchWords[$orIndex]['subject_words'], 0, 7);
}
}
// *** Spell checking
$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new');
if ($context['show_spellchecking']) {
// Windows fix.
ob_start();
$old = error_reporting(0);
pspell_new('en');
开发者ID:chenhao6593,项目名称:smf,代码行数:67,代码来源:Search.php
示例12: updateSubjectStats
/**
* This function updates the log_search_subjects in the event of a topic being
* moved, removed or split. It is being sent the topic id, and optionally
* the new subject.
* Used by updateStats('subject').
*
* @param int $id_topic
* @param string|null $subject
*/
function updateSubjectStats($id_topic, $subject = null)
{
$db = database();
// Remove the previous subject (if any).
$db->query('', '
DELETE FROM {db_prefix}log_search_subjects
WHERE id_topic = {int:id_topic}', array('id_topic' => (int) $id_topic));
// Insert the new subject.
if ($subject !== null) {
$id_topic = (int) $id_topic;
$subject_words =
|
请发表评论