Exemple #1
0
         }
     }
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql);
     }
     $search_ids = array();
     while ($row = $db->sql_fetchrow($result)) {
         $search_ids[] = $row['post_id'];
     }
     $db->sql_freeresult($result);
     $total_match_count = count($search_ids);
 } else {
     if ($search_keywords != '') {
         $stopword_array = file('language/' . $board_config['default_lang'] . '/Forums/search_stopwords.txt');
         $synonym_array = file('language/' . $board_config['default_lang'] . '/Forums/search_synonyms.txt');
         $split_search = !strstr($multibyte_charset, $lang['ENCODING']) ? split_words(clean_words('search', $search_keywords, $stopword_array, $synonym_array), 'search') : split(' ', $search_keywords);
         $search_msg_only = !$search_fields ? "AND m.title_match = 0" : (strstr($multibyte_charset, $lang['ENCODING']) ? '' : '');
         $word_count = 0;
         $current_match_type = 'or';
         $word_match = array();
         $result_list = array();
         for ($i = 0; $i < count($split_search); $i++) {
             if (preg_match('#^[\\*%]+$#', trim($split_search[$i])) || preg_match('#^[^\\*]{1,2}$#', str_replace(array('*', '%'), '', trim($split_search[$i])))) {
                 $split_search[$i] = '';
                 continue;
             }
             switch ($split_search[$i]) {
                 case 'and':
                     $current_match_type = 'and';
                     break;
                 case 'or':
function add_search_words($mode, $post_id, $post_text, $post_title = '')
{
    global $db, $config, $lang;
    global $stopwords_array, $synonyms_array;
    stopwords_synonyms_init();
    $search_raw_words = array();
    $search_raw_words['text'] = split_words(clean_words('post', $post_text, $stopwords_array, $synonyms_array));
    $search_raw_words['title'] = split_words(clean_words('post', $post_title, $stopwords_array, $synonyms_array));
    @set_time_limit(0);
    $word = array();
    $word_insert_sql = array();
    while (list($word_in, $search_matches) = @each($search_raw_words)) {
        $word_insert_sql[$word_in] = '';
        if (!empty($search_matches)) {
            for ($i = 0; $i < sizeof($search_matches); $i++) {
                $search_matches[$i] = trim($search_matches[$i]);
                if ($search_matches[$i] != '') {
                    $word[] = $search_matches[$i];
                    if (!strstr($word_insert_sql[$word_in], "'" . $search_matches[$i] . "'")) {
                        $word_insert_sql[$word_in] .= $word_insert_sql[$word_in] != "" ? ", '" . $search_matches[$i] . "'" : "'" . $search_matches[$i] . "'";
                    }
                }
            }
        }
    }
    if (sizeof($word)) {
        sort($word);
        $prev_word = '';
        $word_text_sql = '';
        $temp_word = array();
        for ($i = 0; $i < sizeof($word); $i++) {
            if ($word[$i] != $prev_word) {
                $temp_word[] = $word[$i];
                $word_text_sql .= ($word_text_sql != '' ? ', ' : '') . "'" . $word[$i] . "'";
            }
            $prev_word = $word[$i];
        }
        $word = $temp_word;
        $check_words = array();
        $value_sql = '';
        $match_word = array();
        for ($i = 0; $i < sizeof($word); $i++) {
            $new_match = true;
            if (isset($check_words[$word[$i]])) {
                $new_match = false;
            }
            if ($new_match) {
                $value_sql .= ($value_sql != '' ? ', ' : '') . '(\'' . $word[$i] . '\', 0)';
            }
        }
        if ($value_sql != '') {
            $sql = "INSERT IGNORE INTO " . SEARCH_WORD_TABLE . " (word_text, word_common)\n\t\t\t\t\t\t\tVALUES {$value_sql}";
            $db->sql_query($sql);
        }
    }
    while (list($word_in, $match_sql) = @each($word_insert_sql)) {
        $title_match = $word_in == 'title' ? 1 : 0;
        if ($match_sql != '') {
            $sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match)\n\t\t\t\tSELECT {$post_id}, word_id, {$title_match}\n\t\t\t\t\tFROM " . SEARCH_WORD_TABLE . "\n\t\t\t\t\tWHERE word_text IN ({$match_sql})";
            $db->sql_query($sql);
        }
    }
    if ($mode == 'single') {
        remove_common('single', 4 / 10, $word);
    }
    return;
}
         echo $j->encode($open);
     }
     break;
 case 'cari':
     $search = $_GET['search'];
     $synonym_list = '';
     $stopword_list[] = '&';
     $stopword_list[] = ',';
     $stopword_list[] = '@';
     $stopword_list[] = '#';
     $stopword_list[] = '"';
     $stopword_list[] = '\'';
     $stopword_list[] = '?';
     $stopword_list[] = '!';
     $stopword_list[] = '*';
     $search = clean_words('search', $search, $stopword_list, $synonym_list);
     if (!empty($search)) {
         $num = mysql_query("SELECT id,\n\t\t \t\t\tMATCH(judul,keterangan,url) AGAINST ('{$search}'  IN BOOLEAN MODE) AS score \n\t  \t\t\t\tFROM `mod_download` where MATCH(judul,keterangan,url) AGAINST ('{$search}'  IN BOOLEAN MODE)\n\t  \t\t\t\t");
         $jumlah = mysql_num_rows($num);
         mysql_free_result($num);
         $limit = 8;
         $pembagian = new paging($limit);
         $pagging = $pembagian->getPagingajax($jumlah, $pg, $stg);
         if (is_array($pagging)) {
             $ddl = '';
             foreach ($pagging as $k => $v) {
                 if ($v['link'] == "") {
                     $ddl .= $v['title'] . ' | ';
                 } else {
                     $ddl .= '<a onclick="download.cariclick(\'' . $v['link'] . '\');" style="cursor:pointer" title="Page ' . $v['title'] . '">' . $v['title'] . '</a> | ';
                 }
/**
* Get similar topics
* If user is guest or bot it will create a cache list in topics table to save some SQL charge
*/
function get_similar_topics($similar_forums_auth, $topic_id, $topic_title, $similar_topics_ids = '', $topic_desc = '')
{
    global $db, $config, $user, $lang;
    $similar_topics = array();
    if ($similar_topics_ids !== '' && (!$user->data['session_logged_in'] || $user->data['is_bot'])) {
        if ($similar_topics_ids == 'empty') {
            return $similar_topics;
        }
        $topics_array = $similar_topics_ids;
        $sql = "SELECT t.*, u.user_id, u.username, u.user_active, u.user_color, u2.username as user2, u2.user_id as id2, u2.user_active as user_active2, u2.user_color as user_color2, f.forum_id, f.forum_name, p.post_time, p.post_username\n\t\t\t\t\tFROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2\n\t\t\t\t\tWHERE t.topic_id IN (" . $topics_array . ")\n\t\t\t\t\t\tAND t.forum_id = f.forum_id\n\t\t\t\t\t\tAND p.poster_id = u2.user_id\n\t\t\t\t\t\tAND p.post_id = t.topic_last_post_id\n\t\t\t\t\t\tAND t.topic_poster = u.user_id\n\t\t\t\t\t\tAND t.topic_status <> " . TOPIC_MOVED . "\n\t\t\t\t\tGROUP BY t.topic_id\n\t\t\t\t\tORDER BY p.post_time";
        $result = $db->sql_query($sql);
        $similar_topics = $db->sql_fetchrowset($result);
        $db->sql_freeresult($result);
        return $similar_topics;
    }
    if ($config['similar_ignore_forums_ids']) {
        $ignore_forums_ids = array_map('intval', explode("\n", trim($config['similar_ignore_forums_ids'])));
    } else {
        $ignore_forums_ids = array();
    }
    // Get forum auth information to insure privacy of hidden topics
    $forums_auth_sql = '';
    //foreach ($similar_forums_auth as $k=>$v)
    //$similar_forums_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $user->data);
    foreach ($similar_forums_auth as $k => $v) {
        if (sizeof($ignore_forums_ids) && in_array($k, $ignore_forums_ids)) {
            continue;
        }
        if ($v['auth_view'] && $v['auth_read']) {
            $forums_auth_sql .= ($forums_auth_sql == '' ? '' : ', ') . $k;
        }
    }
    if ($forums_auth_sql != '') {
        $forums_auth_sql = ' AND t.forum_id IN (' . $forums_auth_sql . ') ';
    }
    if ($config['similar_stopwords']) {
        // encoding match for workaround
        $multibyte_charset = 'utf-8, big5, shift_jis, euc-kr, gb2312';
        // check against stopwords start
        @(include_once IP_ROOT_PATH . 'includes/functions_search.' . PHP_EXT);
        stopwords_synonyms_init();
        $synonyms_array = array();
        // check against stopwords end
        $title_search = '';
        $title_search_array = !strstr($multibyte_charset, $lang['ENCODING']) ? split_words(clean_words('post', $topic_title, $stopwords_array, $synonyms_array), 'search') : split(' ', $topic_title);
        for ($i = 0; $i < sizeof($title_search_array); $i++) {
            $title_search .= ($title_search == '' ? '' : ' ') . $title_search_array[$i];
        }
    } else {
        $title_search = $topic_title;
    }
    /*
    if (!empty($topic_desc) && $config['similar_topicdesc'])
    {
    	if ($config['similar_stopwords'])
    	{
    		$topicdesc = '';
    		$topic_desc_array = (!strstr($multibyte_charset, $lang['ENCODING'])) ? split_words(clean_words('post', $topic_desc, $stopwords_array, $synonyms_array), 'search') : split(' ', $topic_desc);
    		for ($i = 0; $i < sizeof($topic_desc_array); $i++)
    		{
    			$topicdesc .= (($topicdesc == '') ? '': ' ') . $topic_desc_array[$i];
    		}
    	}
    	else
    	{
    		$topicdesc = $topic_desc;
    	}
    	$sql_topic_desc = "+MATCH(t.topic_desc) AGAINST('" . $db->sql_escape($topicdesc) . "')";
    }
    
    $sql_match = "MATCH(t.topic_title) AGAINST('" . $db->sql_escape($title_search) . "')" . $sql_topic_desc;
    */
    $sql_match = "MATCH(t.topic_title) AGAINST('" . $db->sql_escape($title_search) . "')";
    if ($config['similar_sort_type'] == 'time') {
        $sql_sort = 'p.post_time';
    } else {
        $sql_sort = 'relevance';
    }
    //ORDER BY t.topic_type DESC, ' . $sql_sort . ' DESC LIMIT 0,' . intval($config['similar_max_topics']);
    $sql = "SELECT t.*, u.user_id, u.username, u.user_active, u.user_color, u2.username as user2, u2.user_id as id2, u2.user_active as user_active2, u2.user_color as user_color2, f.forum_id, f.forum_name, p.post_time, p.post_username, {$sql_match} as relevance\n\t\t\t\tFROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2\n\t\t\t\tWHERE t.topic_id <> {$topic_id} {$forums_auth_sql}\n\t\t\t\t\tAND {$sql_match}\n\t\t\t\t\tAND t.forum_id = f.forum_id\n\t\t\t\t\tAND p.poster_id = u2.user_id\n\t\t\t\t\tAND p.post_id = t.topic_last_post_id\n\t\t\t\t\tAND t.topic_poster = u.user_id\n\t\t\t\t\tAND t.topic_status <> " . TOPIC_MOVED . "\n\t\t\t\tGROUP BY t.topic_id\n\t\t\t\tORDER BY " . $sql_sort . " DESC LIMIT 0," . intval($config['similar_max_topics']);
    $result = $db->sql_query($sql);
    $similar_topics = $db->sql_fetchrowset($result);
    $db->sql_freeresult($result);
    $count_similar = sizeof($similar_topics);
    if (!$user->data['session_logged_in'] || $user->data['is_bot']) {
        $similar_ids_array = 'empty';
        if (!empty($count_similar)) {
            $similar_ids_array = '';
            for ($i = 0; $i < $count_similar; $i++) {
                $similar_ids_array .= (empty($similar_ids_array) ? '' : ',') . $similar_topics[$i]['topic_id'];
            }
        }
        $sql = "UPDATE " . TOPICS_TABLE . " SET topic_similar_topics = '" . $similar_ids_array . "' WHERE topic_id = " . $topic_id;
        $result = $db->sql_query($sql);
    }
    return $similar_topics;
}
Exemple #5
0
 function main($action)
 {
     global $template, $lang, $config, $pafiledb_config, $db, $images, $user;
     if (!$this->auth_global['auth_search']) {
         if (!$user->data['session_logged_in']) {
             redirect(append_sid(CMS_PAGE_LOGIN . '?redirect=dload.' . PHP_EXT . '&action=stats', true));
         }
         $message = sprintf($lang['Sorry_auth_search'], $this->auth_global['auth_search_type']);
         message_die(GENERAL_MESSAGE, $message);
     }
     include IP_ROOT_PATH . 'includes/functions_search.' . PHP_EXT;
     $search_keywords = request_var('search_keywords', '', true);
     $search_keywords = htmlspecialchars_decode($search_keywords, ENT_COMPAT);
     $search_author = request_var('search_author', '', true);
     $search_author = htmlspecialchars_decode($search_author, ENT_COMPAT);
     $search_id = request_var('search_id', 0);
     $search_terms = request_var('search_terms', '');
     $search_terms = $search_terms == 'all' ? 1 : 0;
     $cat_id = request_var('cat_id', 0);
     $comments_search = request_var('comments_search', '');
     $comments_search = $comments_search == 'YES' ? 1 : 0;
     $start = request_var('start', 0);
     $start = $start < 0 ? 0 : $start;
     $sort_method = request_var('sort_method', $pafiledb_config['sort_method']);
     $sort_method = check_var_value($sort_method, array('file_name', 'file_time', 'file_dls', 'file_rating', 'file_update_time'));
     $sort_method = $sort_method == 'file_rating' ? 'rating' : $sort_method;
     $sort_order = request_var('order', $pafiledb_config['sort_order']);
     $sort_order = check_var_value($sort_order, array('DESC', 'ASC'));
     $limit_sql = $start == 0 ? $pafiledb_config['settings_file_page'] : $start . ',' . $pafiledb_config['settings_file_page'];
     // encoding match for workaround
     $multibyte_charset = 'utf-8, big5, shift_jis, euc-kr, gb2312';
     if (isset($_POST['submit']) || $search_author != '' || $search_keywords != '' || $search_id) {
         $store_vars = array('search_results', 'total_match_count', 'split_search', 'sort_method', 'sort_order');
         if ($search_author != '' || $search_keywords != '') {
             if ($search_author != '' && $search_keywords == '') {
                 $search_author = str_replace('*', '%', trim($search_author));
                 $sql = get_users_sql($search_author, true, false, true, false);
                 $result = $db->sql_query($sql);
                 $matching_userids = '';
                 if ($row = $db->sql_fetchrow($result)) {
                     do {
                         $matching_userids .= ($matching_userids != '' ? ', ' : '') . $row['user_id'];
                     } while ($row = $db->sql_fetchrow($result));
                 } else {
                     message_die(GENERAL_MESSAGE, $lang['No_search_match']);
                 }
                 $sql = "SELECT *\n\t\t\t\t\t\tFROM " . PA_FILES_TABLE . "\n\t\t\t\t\t\tWHERE user_id IN ({$matching_userids})";
                 $result = $db->sql_query($sql);
                 $search_ids = array();
                 while ($row = $db->sql_fetchrow($result)) {
                     if ($this->auth[$row['file_catid']]['auth_view']) {
                         $search_ids[] = $row['file_id'];
                     }
                 }
                 $db->sql_freeresult($result);
                 $total_match_count = sizeof($search_ids);
             } elseif ($search_keywords != '') {
                 stopwords_synonyms_init();
                 $split_search = array();
                 $split_search = !strstr($multibyte_charset, $lang['ENCODING']) ? split_words(clean_words('search', stripslashes($search_keywords), $stopwords_array, $synonyms_array), 'search') : split(' ', $search_keywords);
                 $word_count = 0;
                 $current_match_type = 'or';
                 $word_match = array();
                 $result_list = array();
                 for ($i = 0; $i < sizeof($split_search); $i++) {
                     switch ($split_search[$i]) {
                         case 'and':
                             $current_match_type = 'and';
                             break;
                         case 'or':
                             $current_match_type = 'or';
                             break;
                         case 'not':
                             $current_match_type = 'not';
                             break;
                         default:
                             if (!empty($search_terms)) {
                                 $current_match_type = 'and';
                             }
                             $match_word = addslashes('%' . str_replace('*', '', $split_search[$i]) . '%');
                             $sql = "SELECT file_id\n\t\t\t\t\t\t\t\t\tFROM " . PA_FILES_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE (file_name LIKE '{$match_word}'\n\t\t\t\t\t\t\t\t\tOR file_creator LIKE '{$match_word}'\n\t\t\t\t\t\t\t\t\tOR file_desc LIKE '{$match_word}'\n\t\t\t\t\t\t\t\t\tOR file_longdesc LIKE '{$match_word}')";
                             $result = $db->sql_query($sql);
                             $row = array();
                             while ($temp_row = $db->sql_fetchrow($result)) {
                                 $row[$temp_row['file_id']] = 1;
                                 if (!$word_count) {
                                     $result_list[$temp_row['file_id']] = 1;
                                 } elseif ($current_match_type == 'or') {
                                     $result_list[$temp_row['file_id']] = 1;
                                 } elseif ($current_match_type == 'not') {
                                     $result_list[$temp_row['file_id']] = 0;
                                 }
                             }
                             if ($current_match_type == 'and' && $word_count) {
                                 @reset($result_list);
                                 while (list($file_id, $match_count) = @each($result_list)) {
                                     if (!$row[$file_id]) {
                                         $result_list[$file_id] = 0;
                                     }
                                 }
                             }
                             if ($comments_search) {
                                 $sql = "SELECT file_id\n\t\t\t\t\t\t\t\t\tFROM " . PA_COMMENTS_TABLE . "\n\t\t\t\t\t\t\t\t\tWHERE (comments_title LIKE '{$match_word}'\n\t\t\t\t\t\t\t\t\tOR comments_text LIKE '{$match_word}')";
                                 $result = $db->sql_query($sql);
                                 $row = array();
                                 while ($temp_row = $db->sql_fetchrow($result)) {
                                     $row[$temp_row['file_id']] = 1;
                                     if (!$word_count) {
                                         $result_list[$temp_row['file_id']] = 1;
                                     } else {
                                         if ($current_match_type == 'or') {
                                             $result_list[$temp_row['file_id']] = 1;
                                         } else {
                                             if ($current_match_type == 'not') {
                                                 $result_list[$temp_row['file_id']] = 0;
                                             }
                                         }
                                     }
                                 }
                                 if ($current_match_type == 'and' && $word_count) {
                                     @reset($result_list);
                                     while (list($file_id, $match_count) = @each($result_list)) {
                                         if (!$row[$file_id]) {
                                             $result_list[$file_id] = 0;
                                         }
                                     }
                                 }
                             }
                             $word_count++;
                             $db->sql_freeresult($result);
                     }
                 }
                 @reset($result_list);
                 $search_ids = array();
                 while (list($file_id, $matches) = each($result_list)) {
                     if ($matches) {
                         $search_ids[] = $file_id;
                     }
                 }
                 unset($result_list);
                 $total_match_count = sizeof($search_ids);
             }
             // Author name search
             if ($search_author != '') {
                 $search_author = str_replace('*', '%', trim($db->sql_escape($search_author)));
             }
             if ($total_match_count) {
                 $where_sql = $cat_id ? 'AND file_catid IN (' . $this->gen_cat_ids($cat_id, '') . ')' : '';
                 if ($search_author == '') {
                     $sql = "SELECT file_id, file_catid\n\t\t\t\t\t\t\tFROM " . PA_FILES_TABLE . "\n\t\t\t\t\t\t\tWHERE file_id IN (" . implode(", ", $search_ids) . ")\n\t\t\t\t\t\t\t\t{$where_sql}\n\t\t\t\t\t\t\tGROUP BY file_id";
                 } else {
                     $from_sql = PA_FILES_TABLE . " f";
                     if ($search_author != '') {
                         $from_sql .= ", " . USERS_TABLE . " u";
                         $where_sql .= " AND u.user_id = f.user_id AND u.username LIKE '{$search_author}' ";
                     }
                     $where_sql .= $cat_id ? 'AND file_catid IN (' . $this->gen_cat_ids($cat_id, '') . ')' : '';
                     $sql = "SELECT f.file_id, f.file_catid\n\t\t\t\t\t\t\tFROM {$from_sql}\n\t\t\t\t\t\t\tWHERE f.file_id IN (" . implode(", ", $search_ids) . ")\n\t\t\t\t\t\t\t{$where_sql}\n\t\t\t\t\t\t\tGROUP BY f.file_id";
                 }
                 $result = $db->sql_query($sql);
                 $search_ids = array();
                 while ($row = $db->sql_fetchrow($result)) {
                     if ($this->auth[$row['file_catid']]['auth_view']) {
                         $search_ids[] = $row['file_id'];
                     }
                 }
                 $db->sql_freeresult($result);
                 $total_match_count = sizeof($search_ids);
             } else {
                 message_die(GENERAL_MESSAGE, $lang['No_search_match']);
             }
             //
             // Finish building query (for all combinations)
             // and run it ...
             //
             $expiry_time = $current_time - $config['session_length'];
             $sql = "SELECT session_id\n\t\t\t\t\tFROM " . SESSIONS_TABLE . "\n\t\t\t\t\tWHERE session_time > {$expiry_time}";
             $db->sql_return_on_error(true);
             $result = $db->sql_query($sql);
             $db->sql_return_on_error(false);
             if ($result) {
                 $delete_search_ids = array();
                 while ($row = $db->sql_fetchrow($result)) {
                     $delete_search_ids[] = "'" . $row['session_id'] . "'";
                 }
                 if (sizeof($delete_search_ids)) {
                     $sql = "DELETE FROM " . SEARCH_TABLE . "\n\t\t\t\t\t\t\tWHERE session_id NOT IN (" . implode(", ", $delete_search_ids) . ")";
                     $result = $db->sql_query($sql);
                 }
             }
             // Store new result data
             $search_results = implode(', ', $search_ids);
             $store_search_data = array();
             for ($i = 0; $i < sizeof($store_vars); $i++) {
                 $store_search_data[$store_vars[$i]] = ${$store_vars}[$i];
             }
             $result_array = serialize($store_search_data);
             unset($store_search_data);
             mt_srand((double) microtime() * 1000000);
             $search_id = mt_rand();
             $sql = "UPDATE " . SEARCH_TABLE . "\n\t\t\t\t\tSET search_id = {$search_id}, search_array = '" . $db->sql_escape($result_array) . "'\n\t\t\t\t\tWHERE session_id = '" . $user->data['session_id'] . "'";
             $db->sql_return_on_error(true);
             $result = $db->sql_query($sql);
             $db->sql_return_on_error(false);
             if (!$result || !$db->sql_affectedrows()) {
                 $sql = "INSERT INTO " . SEARCH_TABLE . " (search_id, session_id, search_array)\n\t\t\t\t\t\tVALUES({$search_id}, '" . $user->data['session_id'] . "', '" . $db->sql_escape($result_array) . "')";
                 $result = $db->sql_query($sql);
             }
         } else {
             $search_id = intval($search_id);
             if ($search_id) {
                 $sql = "SELECT search_array\n\t\t\t\t\t\tFROM " . SEARCH_TABLE . "\n\t\t\t\t\t\tWHERE search_id = {$search_id}\n\t\t\t\t\t\tAND session_id = '" . $user->data['session_id'] . "'";
                 $result = $db->sql_query($sql);
                 if ($row = $db->sql_fetchrow($result)) {
                     $search_data = unserialize($row['search_array']);
                     for ($i = 0; $i < sizeof($store_vars); $i++) {
                         ${$store_vars}[$i] = $search_data[$store_vars[$i]];
                     }
                 }
             }
         }
         if ($search_results != '') {
             $sql = "SELECT f1.*, AVG(r.rate_point) AS rating, COUNT(r.votes_file) AS total_votes, u.user_id, u.username, u.user_active, u.user_color, c.cat_id, c.cat_name, COUNT(cm.comments_id) AS total_comments\n\t\t\t\t\tFROM (" . PA_FILES_TABLE . " AS f1, " . PA_CATEGORY_TABLE . " AS c)\n\t\t\t\t\t\tLEFT JOIN " . PA_VOTES_TABLE . " AS r ON f1.file_id = r.votes_file\n\t\t\t\t\t\tLEFT JOIN " . USERS_TABLE . " AS u ON f1.user_id = u.user_id\n\t\t\t\t\t\tLEFT JOIN " . PA_COMMENTS_TABLE . " AS cm ON f1.file_id = cm.file_id\n\t\t\t\t\tWHERE f1.file_id IN ({$search_results})\n\t\t\t\t\tAND c.cat_id = f1.file_catid\n\t\t\t\t\tAND f1.file_approved = '1'\n\t\t\t\t\tGROUP BY f1.file_id\n\t\t\t\t\tORDER BY {$sort_method} {$sort_order}\n\t\t\t\t\tLIMIT {$limit_sql}";
             $result = $db->sql_query($sql);
             $searchset = array();
             while ($row = $db->sql_fetchrow($result)) {
                 $searchset[] = $row;
             }
             $db->sql_freeresult($result);
             $l_search_matches = $total_match_count == 1 ? sprintf($lang['Found_search_match'], $total_match_count) : sprintf($lang['Found_search_matches'], $total_match_count);
             $template->assign_vars(array('L_SEARCH_MATCHES' => $l_search_matches));
             for ($i = 0; $i < sizeof($searchset); $i++) {
                 $cat_url = append_sid('dload.' . PHP_EXT . '?action=category&amp;cat_id=' . $searchset[$i]['cat_id']);
                 $file_url = append_sid('dload.' . PHP_EXT . '?action=file&amp;file_id=' . $searchset[$i]['file_id']);
                 //===================================================
                 // Format the date for the given file
                 //===================================================
                 $date = create_date_ip($config['default_dateformat'], $searchset[$i]['file_time'], $config['board_timezone']);
                 //===================================================
                 // Get rating for the file and format it
                 //===================================================
                 //$rating = ($searchset[$i]['rating'] != 0) ? round($searchset[$i]['rating'], 2) . ' / 10' : $lang['Not_rated'];
                 //$rating2 = ($searchset[$i]['rating'] != 0) ? sprintf("%.1f", round(($searchset[$i]['rating']), 2) / 2) : '0.0';
                 $rating2 = $searchset[$i]['rating'] != 0 ? sprintf("%.1f", round($searchset[$i]['rating'], 0) / 2) : '0.0';
                 //===================================================
                 // If the file is new then put a new image in front of it
                 //===================================================
                 $is_new = false;
                 if (time() - $pafiledb_config['settings_newdays'] * 24 * 60 * 60 < $searchset[$i]['file_time']) {
                     $is_new = true;
                 }
                 $xs_new = $is_new ? '-new' : '';
                 //===================================================
                 // Get the post icon fot this file
                 //===================================================
                 if ($searchset[$i]['file_pin'] != FILE_PINNED) {
                     if ($searchset[$i]['file_posticon'] == 'none' || $searchset[$i]['file_posticon'] == 'none.gif') {
                         $posticon = '<img src="' . IP_ROOT_PATH . FILES_ICONS_DIR . 'default.png" alt="" />';
                         //$posticon = '&nbsp;';
                     } else {
                         $posticon = '<img src="' . FILES_ICONS_DIR . $searchset[$i]['file_posticon'] . '" alt="" />';
                     }
                 } else {
                     $posticon = '<img src="' . $images['forum_link'] . '" alt="" />';
                 }
                 $poster = $searchset[$i]['user_id'] == ANONYMOUS ? $lang['Guest'] : colorize_username($searchset[$i]['user_id'], $searchset[$i]['username'], $searchset[$i]['user_color'], $searchset[$i]['user_active']);
                 $template->assign_block_vars('searchresults', array('CAT_NAME' => $searchset[$i]['cat_name'], 'FILE_NEW_IMAGE' => $images['pa_file_new'], 'PIN_IMAGE' => $posticon, 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'XS_NEW' => $xs_new, 'IS_NEW_FILE' => $is_new, 'FILE_NAME' => $searchset[$i]['file_name'], 'FILE_DESC' => $searchset[$i]['file_desc'], 'FILE_SUBMITER' => $poster, 'DATE' => $date, 'RATING' => $rating2, 'DOWNLOADS' => $searchset[$i]['file_dls'], 'U_FILE' => $file_url, 'U_CAT' => $cat_url));
             }
             $base_url = append_sid('dload.' . PHP_EXT . '?action=search&amp;search_id=' . $search_id);
             $template->assign_vars(array('PAGINATION' => generate_pagination($base_url, $total_match_count, $pafiledb_config['settings_file_page'], $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $pafiledb_config['settings_file_page']) + 1, ceil($total_match_count / $pafiledb_config['settings_file_page'])), 'DOWNLOAD' => $pafiledb_config['settings_dbname'], 'L_HOME' => $lang['Home'], 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD' => append_sid('dload.' . PHP_EXT), 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'XS_NEW' => $xs_new, 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_RATE' => $lang['DlRating'], 'L_DOWNLOADS' => $lang['Dls'], 'L_DATE' => $lang['Date'], 'L_NAME' => $lang['Name'], 'L_FILE' => $lang['File'], 'L_SUBMITER' => $lang['Submiter'], 'L_CATEGORY' => $lang['Category'], 'L_NEW_FILE' => $lang['New_file']));
             $this->display($lang['Download'], 'pa_search_result.tpl');
         } else {
             message_die(GENERAL_MESSAGE, $lang['No_search_match']);
         }
     }
     if (!isset($_POST['submit']) || $search_author == '' && $search_keywords == '' && !$search_id) {
         $dropmenu = $this->jumpmenu_option();
         $template->assign_vars(array('S_SEARCH_ACTION' => append_sid('dload.php'), 'S_CAT_MENU' => $dropmenu, 'DOWNLOAD' => $pafiledb_config['settings_dbname'], 'U_INDEX_HOME' => append_sid(CMS_PAGE_HOME), 'U_DOWNLOAD' => append_sid('dload.' . PHP_EXT), 'L_HOME' => $lang['Home'], 'CURRENT_TIME' => sprintf($lang['Current_time'], create_date($config['default_dateformat'], time(), $config['board_timezone'])), 'XS_NEW' => $xs_new, 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_SEARCH_OPTIONS' => $lang['Search_options'], 'L_SEARCH_KEYWORDS' => $lang['Search_keywords'], 'L_SEARCH_KEYWORDS_EXPLAIN' => $lang['Search_keywords_explain'], 'L_SEARCH_AUTHOR' => $lang['Search_author'], 'L_SEARCH_AUTHOR_EXPLAIN' => $lang['Search_author_explain'], 'L_SEARCH_ANY_TERMS' => $lang['Search_for_any'], 'L_SEARCH_ALL_TERMS' => $lang['Search_for_all'], 'L_INCLUDE_COMMENTS' => $lang['Include_comments'], 'L_SORT_BY' => $lang['Select_sort_method'], 'L_SORT_DIR' => $lang['Order'], 'L_SORT_ASCENDING' => $lang['Sort_Ascending'], 'L_SORT_DESCENDING' => $lang['Sort_Descending'], 'L_INDEX' => sprintf($lang['Forum_Index'], $config['sitename']), 'L_RATING' => $lang['DlRating'], 'L_DOWNLOADS' => $lang['Dls'], 'L_DATE' => $lang['Date'], 'L_NAME' => $lang['Name'], 'L_UPDATE_TIME' => $lang['Update_time'], 'L_SEARCH' => $lang['Search'], 'L_SEARCH_FOR' => $lang['Search_for'], 'L_ALL' => $lang['All'], 'L_CHOOSE_CAT' => $lang['Choose_cat']));
         $this->display($lang['Download'], 'pa_search_body.tpl');
     }
 }
    }
    $result = db_query("SELECT {$select_columns} FROM {$CONFIG['TABLE_PICTURES']} WHERE MATCH(filename, title, caption, keywords) AGAINST ('{$search_string}' {$boolean_mode}) AND approved = 'YES' {$ALBUM_SET} {$limit}");
    $rowset = db_fetch_rowset($result);
    mysql_free_result($result);
    if ($set_caption) {
        foreach ($rowset as $key => $row) {
            $caption = $rowset[$key]['title'] ? "<span class=\"thumb_title\">" . $rowset[$key]['title'] . "</span>" : '';
            if ($CONFIG['caption_in_thumbview']) {
                $caption .= $rowset[$key]['caption'] ? "<span class=\"thumb_caption\">" . bb_decode($rowset[$key]['caption']) . "</span>" : '';
            }
            $rowset[$key]['caption_text'] = $caption;
        }
    }
} elseif ($search_string != '') {
    $split_search = array();
    $split_search = split(' ', clean_words($search_string, $mb_charset));
    $current_match_type = 'and';
    $pic_set = '';
    for ($i = 0; $i < count($split_search); $i++) {
        switch ($split_search[$i]) {
            case 'and':
                $current_match_type = 'and';
                break;
            case 'or':
                $current_match_type = 'or';
                break;
            case 'not':
                $current_match_type = 'not';
                break;
            default:
                if (empty($split_search[$i])) {
function add_search_words($mode, $post_id, $post_text, $post_title = '')
{
    global $db, $phpbb_root_path, $board_config, $lang;
    $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");
    $search_raw_words = array();
    $search_raw_words['text'] = split_words(clean_words('post', $post_text, $stopword_array, $synonym_array));
    $search_raw_words['title'] = split_words(clean_words('post', $post_title, $stopword_array, $synonym_array));
    @set_time_limit(0);
    $word = array();
    $word_insert_sql = array();
    while (list($word_in, $search_matches) = @each($search_raw_words)) {
        $word_insert_sql[$word_in] = '';
        if (!empty($search_matches)) {
            for ($i = 0; $i < count($search_matches); $i++) {
                $search_matches[$i] = trim($search_matches[$i]);
                if ($search_matches[$i] != '') {
                    $word[] = $search_matches[$i];
                    if (!strstr($word_insert_sql[$word_in], "'" . $search_matches[$i] . "'")) {
                        $word_insert_sql[$word_in] .= $word_insert_sql[$word_in] != "" ? ", '" . $search_matches[$i] . "'" : "'" . $search_matches[$i] . "'";
                    }
                }
            }
        }
    }
    if (count($word)) {
        sort($word);
        $prev_word = '';
        $word_text_sql = '';
        $temp_word = array();
        for ($i = 0; $i < count($word); $i++) {
            if ($word[$i] != $prev_word) {
                $temp_word[] = $word[$i];
                $word_text_sql .= ($word_text_sql != '' ? ', ' : '') . "'" . $word[$i] . "'";
            }
            $prev_word = $word[$i];
        }
        $word = $temp_word;
        $check_words = array();
        switch (SQL_LAYER) {
            case 'postgresql':
            case 'msaccess':
            case 'mssql-odbc':
            case 'oracle':
            case 'db2':
                $sql = "SELECT word_id, word_text\r\n                                        FROM " . SEARCH_WORD_TABLE . "\r\n                                        WHERE word_text IN ({$word_text_sql})";
                if (!($result = $db->sql_query($sql))) {
                    message_die(GENERAL_ERROR, 'Could not select words', '', __LINE__, __FILE__, $sql);
                }
                while ($row = $db->sql_fetchrow($result)) {
                    $check_words[$row['word_text']] = $row['word_id'];
                }
                break;
        }
        $value_sql = '';
        $match_word = array();
        for ($i = 0; $i < count($word); $i++) {
            $new_match = true;
            if (isset($check_words[$word[$i]])) {
                $new_match = false;
            }
            if ($new_match) {
                switch (SQL_LAYER) {
                    case 'mysql':
                    case 'mysql4':
                        $value_sql .= ($value_sql != '' ? ', ' : '') . '(\'' . $word[$i] . '\', 0)';
                        break;
                    case 'mssql':
                    case 'mssql-odbc':
                        $value_sql .= ($value_sql != '' ? ' UNION ALL ' : '') . "SELECT '" . $word[$i] . "', 0";
                        break;
                    default:
                        $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text, word_common)\r\n                                                        VALUES ('" . $word[$i] . "', '0')";
                        if (!$db->sql_query($sql)) {
                            message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql);
                        }
                        break;
                }
            }
        }
        if ($value_sql != '') {
            switch (SQL_LAYER) {
                case 'mysql':
                case 'mysql4':
                    $sql = "INSERT IGNORE INTO " . SEARCH_WORD_TABLE . " (word_text, word_common)\r\n                                                VALUES {$value_sql}";
                    break;
                case 'mssql':
                case 'mssql-odbc':
                    $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text, word_common)\r\n                                                {$value_sql}";
                    break;
            }
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql);
            }
        }
    }
    while (list($word_in, $match_sql) = @each($word_insert_sql)) {
        $title_match = $word_in == 'title' ? 1 : 0;
        if ($match_sql != '') {
            $sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match)\r\n                                SELECT {$post_id}, word_id, {$title_match}\r\n                                        FROM " . SEARCH_WORD_TABLE . "\r\n                                        WHERE word_text IN ({$match_sql})";
            if (!$db->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Could not insert new word matches', '', __LINE__, __FILE__, $sql);
            }
        }
    }
    if ($mode == 'single') {
        remove_common('single', 4 / 10, $word);
    }
    return;
}
Exemple #8
0
     }
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Could not obtain matched posts list', '', __LINE__, __FILE__, $sql);
     }
     $search_ids = array();
     while ($row = $db->sql_fetchrow($result)) {
         $search_ids[] = $row['post_id'];
     }
     $db->sql_freeresult($result);
     $total_match_count = count($search_ids);
 } else {
     if ($search_keywords != '') {
         $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');
         $split_search = array();
         $cleaned_search = clean_words('search', stripslashes($search_keywords), $stopword_array, $synonym_array);
         $split_search = split_words($cleaned_search, 'search');
         $search_msg_only = !$search_fields ? "AND m.title_match = 0" : '';
         $word_count = 0;
         $current_match_type = 'or';
         $word_match = array();
         $result_list = array();
         for ($i = 0; $i < count($split_search); $i++) {
             switch ($split_search[$i]) {
                 case 'and':
                     $current_match_type = 'and';
                     break;
                 case 'or':
                     $current_match_type = 'or';
                     break;
                 case 'not':
 $result_array = array(array(), array(), array());
 $i = 0;
 while ($row && ($post_size <= $board_config['dbmtnc_rebuildcfg_maxmemory'] * 1024 || $i < $board_config['dbmtnc_rebuildcfg_minposts'])) {
     $last_post = $row['post_id'];
     // handle text
     $word_list = split_words(clean_words('post', $row['post_text'], $empty_array, $empty_array));
     foreach ($word_list as $word) {
         // cutting of long words in functions_search.php seems not to work under some conditions - so check it again
         if ($word != '' && strlen($word) <= 20) {
             $result_array[0][] = $last_post;
             $result_array[1][] = 0;
             $result_array[2][] = $word;
         }
     }
     // handle subject
     $word_list = split_words(clean_words('post', $row['post_subject'], $empty_array, $empty_array));
     foreach ($word_list as $word) {
         // cutting of long words in functions_search.php seems not to work under some conditions - so check it again
         if ($word != '' && strlen($word) <= 20) {
             $result_array[0][] = $last_post;
             $result_array[1][] = 1;
             $result_array[2][] = $word;
         }
     }
     unset($word_list);
     $row = $db->sql_fetchrow($result);
     $i++;
     $post_size += strlen($row['post_text']) + strlen($row['post_subject']);
 }
 // sort array
 array_multisort($result_array[2], SORT_ASC, SORT_STRING, $result_array[0], SORT_ASC, SORT_NUMERIC, $result_array[1]);
Exemple #10
0
function add_search_words($mode, $post_id, $post_text, $post_title = '')
{
    $stopword_array = @file("core/lib/phpbb/search_stopwords.txt");
    $synonym_array = @file("core/lib/phpbb/search_synonyms.txt");
    $search_raw_words = array();
    $search_raw_words['text'] = split_words(clean_words('post', $post_text, $stopword_array, $synonym_array));
    $search_raw_words['title'] = split_words(clean_words('post', $post_title, $stopword_array, $synonym_array));
    @set_time_limit(0);
    $word = array();
    $word_insert_sql = array();
    while (list($word_in, $search_matches) = @each($search_raw_words)) {
        $word_insert_sql[$word_in] = '';
        if (!empty($search_matches)) {
            for ($i = 0; $i < count($search_matches); $i++) {
                $search_matches[$i] = trim($search_matches[$i]);
                if ($search_matches[$i] != '') {
                    $word[] = $search_matches[$i];
                    if (!strstr($word_insert_sql[$word_in], "'" . $search_matches[$i] . "'")) {
                        $word_insert_sql[$word_in] .= $word_insert_sql[$word_in] != "" ? ", '" . $search_matches[$i] . "'" : "'" . $search_matches[$i] . "'";
                    }
                }
            }
        }
    }
    if (count($word)) {
        sort($word);
        $prev_word = '';
        $word_text_sql = '';
        $temp_word = array();
        for ($i = 0; $i < count($word); $i++) {
            if ($word[$i] != $prev_word) {
                $temp_word[] = $word[$i];
                $word_text_sql .= ($word_text_sql != '' ? ', ' : '') . "'" . $word[$i] . "'";
            }
            $prev_word = $word[$i];
        }
        $word = $temp_word;
        $check_words = array();
        $value_sql = '';
        $match_word = array();
        for ($i = 0; $i < count($word); $i++) {
            $new_match = true;
            if (isset($check_words[$word[$i]])) {
                $new_match = false;
            }
            if ($new_match) {
                $value_sql .= ($value_sql != '' ? ', ' : '') . '(\'' . $word[$i] . '\', 0)';
            }
        }
        if ($value_sql != '') {
            $sql = "INSERT IGNORE INTO `z_phpbb_search_wordlist` (word_text, word_common) \n                VALUES {$value_sql}";
            mysql_query($sql);
        }
    }
    while (list($word_in, $match_sql) = @each($word_insert_sql)) {
        $title_match = $word_in == 'title' ? 1 : 0;
        if ($match_sql != '') {
            $sql = "INSERT INTO z_phpbb_search_wordmatch (post_id, word_id, title_match) \n                SELECT {$post_id}, word_id, {$title_match}  \n                FROM z_phpbb_search_wordlist \n                WHERE word_text IN ({$match_sql})";
            mysql_query($sql);
        }
    }
    if ($mode == 'single') {
        remove_common('single', 4 / 10, $word);
    }
    return;
}
Exemple #11
0
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
if ($search_string != '') {
    $split_search = array();
    $split_search = split(' ', clean_words($search_string));
    $current_match_type = 'and';
    $pic_set = '';
    for ($i = 0; $i < count($split_search); $i++) {
        switch ($split_search[$i]) {
            case 'and':
                $current_match_type = 'and';
                break;
            case 'or':
                $current_match_type = 'or';
                break;
            case 'not':
                $current_match_type = 'not';
                break;
            default:
                if (empty($split_search[$i])) {
function add_search_words($mode, $post_id, $post_text, $post_title = '', $topic_id = '')
{
    global $ft_cfg, $lang;
    $stopword_array = @file(FT_ROOT . 'language/lang_' . $ft_cfg['default_lang'] . "/search_stopwords.txt");
    $synonym_array = @file(FT_ROOT . 'language/lang_' . $ft_cfg['default_lang'] . "/search_synonyms.txt");
    $search_raw_words = array();
    $search_raw_words['text'] = split_words(clean_words('post', $post_text, $stopword_array, $synonym_array));
    $search_raw_words['title'] = split_words(clean_words('post', $post_title, $stopword_array, $synonym_array));
    @set_time_limit(0);
    $word = array();
    $word_insert_sql = array();
    while (list($word_in, $search_matches) = @each($search_raw_words)) {
        $word_insert_sql[$word_in] = '';
        if (!empty($search_matches)) {
            for ($i = 0, $cnt = count($search_matches); $i < $cnt; $i++) {
                $search_matches[$i] = @$search_matches[$i] ? trim($search_matches[$i]) : '';
                if ($search_matches[$i] != '') {
                    $word[] = $search_matches[$i];
                    if (!strstr($word_insert_sql[$word_in], "'" . $search_matches[$i] . "'")) {
                        $word_insert_sql[$word_in] .= $word_insert_sql[$word_in] != "" ? ", '" . $search_matches[$i] . "'" : "'" . $search_matches[$i] . "'";
                    }
                }
            }
        }
    }
    if (count($word)) {
        sort($word);
        $prev_word = '';
        $word_text_sql = '';
        $temp_word = array();
        for ($i = 0; $i < count($word); $i++) {
            if ($word[$i] != $prev_word) {
                $temp_word[] = $word[$i];
                $word_text_sql .= ($word_text_sql != '' ? ', ' : '') . "'" . $word[$i] . "'";
            }
            $prev_word = $word[$i];
        }
        $word = $temp_word;
        $check_words = array();
        $value_sql = '';
        $match_word = array();
        for ($i = 0; $i < count($word); $i++) {
            $new_match = true;
            if (isset($check_words[$word[$i]])) {
                $new_match = false;
            }
            if ($new_match) {
                $sql = "INSERT INTO " . SEARCH_WORD_TABLE . " (word_text, word_common)\n\t\t\t\t\tVALUES ('" . $word[$i] . "', 0)";
                if (!DB()->sql_query($sql)) {
                    message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql);
                }
            }
        }
        if ($value_sql != '') {
            $sql = "INSERT IGNORE INTO " . SEARCH_WORD_TABLE . " (word_text, word_common)\n\t\t\t\tVALUES {$value_sql}";
            if (!DB()->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Could not insert new word', '', __LINE__, __FILE__, $sql);
            }
        }
    }
    while (list($word_in, $match_sql) = @each($word_insert_sql)) {
        $title_match = $word_in == 'title' ? 1 : 0;
        if ($match_sql != '') {
            $sql = "INSERT INTO " . SEARCH_MATCH_TABLE . " (post_id, word_id, title_match)\n\t\t\t\tSELECT {$post_id}, word_id, {$title_match}\n\t\t\t\t\tFROM " . SEARCH_WORD_TABLE . "\n\t\t\t\t\tWHERE word_text IN ({$match_sql})";
            if (!DB()->sql_query($sql)) {
                message_die(GENERAL_ERROR, 'Could not insert new word matches', '', __LINE__, __FILE__, $sql);
            }
        }
    }
    if ($mode == 'single') {
        remove_common('single', 4 / 10, $word);
    }
    return;
}