Jump to content

Recommended Posts

Well I've been asking around. I have a recent install of SWF v1.0.7 with the Enigma 2.0 RC1 mod, and it includes an "articles" section. However i have a problem I'd like some help with. No one on the E2 forum seems to understand how to mod PHP enough. The search script currently only calls up the mySQL tables for the forum, and I'd like it to call up the articles, AND downloads section (with PDF support). The search page right now is to drawn out for me also, allowing you to select the forum groups you search.

Search script code below, I need it to search /downloads & the sql database "swf_articles" I think.
[a href=\"http://s92404697.onlinehome.us/mrrtips/index.php?action=search\" target=\"_blank\"]http://s92404697.onlinehome.us/mrrtips/ind...p?action=search[/a] for the current search page...

Code:
[code]<?php
/******************************************************************************
* Search.php                                                                  *
*******************************************************************************
* SMF: Simple Machines Forum                                                  *
* Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com)                *
* =========================================================================== *
* Software Version:           SMF 1.0.7                                       *
* Software by:                Simple Machines (http://www.simplemachines.org) *
* Copyright 2001-2005 by:     Lewis Media (http://www.lewismedia.com)         *
* Support, News, Updates at:  http://www.simplemachines.org                   *
*******************************************************************************
* This program is free software; you may redistribute it and/or modify it     *
* under the terms of the provided license as published by Lewis Media.        *
*                                                                             *
* This program is distributed in the hope that it is and will be useful,      *
* but WITHOUT ANY WARRANTIES; without even any implied warranty of            *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                        *
*                                                                             *
* See the "license.txt" file for details of the Simple Machines license.      *
* The latest version can always be found at http://www.simplemachines.org.    *
******************************************************************************/
if (!defined('SMF'))
    die('Hacking attempt...');

/*    These functions are here for searching, and they are:

    void PlushSearch1()
        - shows the screen to search forum posts (action=search), and uses the
          simple version if the simpleSearch setting is enabled.
        - uses the main sub template of the Search template.
        - requires the search_posts permission.
        - decodes and loads search parameters given in the URL (if any).
        - the form redirects to index.php?action=search2.

    void PlushSearch2()
        - checks user input and searches the messages table for messages
          matching the query.
        - requires the search_posts permission.
        - stores the results into the search cache (if enabled).
        - show the results of the search query.
        - uses the results sub template of the Search template.

    array prepareSearchContext(bool reset = false)
        - callback function for the results sub template.
        - loads the necessary contextual data to show a search result.
*/

// Ask the user what they want to search for.
function PlushSearch1()
{
    global $txt, $scripturl, $db_prefix, $modSettings, $user_info, $context;

    loadTemplate('Search');

    // Check the user's permissions.
    isAllowedTo('search_posts');

    // Link tree....
    $context['linktree'][] = array(
        'url' => $scripturl . '?action=search',
        'name' => $txt[182]
    );

    // If you got back from search2 by using the linktree, you get your original search parameters back.
    if (isset($_REQUEST['params']))
    {
        $temp_params = explode('|"|', base64_decode($_REQUEST['params']));
        $context['search_params'] = array();
        foreach ($temp_params as $i => $data)
        {
            list ($k, $v) = explode('|\'|', $data);
            $context['search_params'][$k] = stripslashes($v);
        }
        if (isset($context['search_params']['brd']))
            $context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']);
    }

    if (isset($context['search_params']['search']))
        $context['search_params']['search'] = htmlspecialchars($context['search_params']['search']);
    if (isset($context['search_params']['userspec']))
        $context['search_params']['userspec'] = htmlspecialchars(stripslashes($context['search_params']['userspec']));

    // Find all the boards this user is allowed to see.
    $request = db_query("
        SELECT b.ID_CAT, c.name AS catName, b.ID_BOARD, b.name, b.childLevel
        FROM {$db_prefix}boards AS b
            LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)
        WHERE $user_info[query_see_board]
        ORDER BY c.catOrder, b.boardOrder", __FILE__, __LINE__);
    $context['num_boards'] = mysql_num_rows($request);
    $context['categories'] = array();
    while ($row = mysql_fetch_assoc($request))
    {
        // This category hasn't been set up yet..
        if (!isset($context['categories'][$row['ID_CAT']]))
            $context['categories'][$row['ID_CAT']] = array(
                'id' => $row['ID_CAT'],
                'name' => $row['catName'],
                'boards' => array()
            );

        // Set this board up, and let the template know when it's a child.  (indent them..)
        $context['categories'][$row['ID_CAT']]['boards'][$row['ID_BOARD']] = array(
            'id' => $row['ID_BOARD'],
            'name' => $row['name'],
            'child_level' => $row['childLevel']
        );
    }
    mysql_free_result($request);

    // Simple or not?
    $context['simple_search'] = !empty($modSettings['simpleSearch']) && !isset($_GET['advanced']);
    $context['page_title'] = $txt[183];
}

// Gather the results and show them.
function PlushSearch2()
{
    global $modSettings, $sourcedir;
    global $scripturl, $txt, $db_prefix, $user_info, $context, $messages_request, $attachments, $boards_can;

    $weight_factors = array(
        'frequency',
        'age',
        'length',
        'subject',
        'first_message',
    );

    $weight = array();
    $weight_total = 0;
    foreach ($weight_factors as $weight_factor)
    {
        $weight[$weight_factor] = empty($modSettings['search_weight_' . $weight_factor]) ? 0 : (int) $modSettings['search_weight_' . $weight_factor];
        $weight_total += $weight[$weight_factor];
    }

    // Zero weight. Weightless.
    if (empty($weight_total))
        fatal_lang_error('search_invalid_weights');

/*
    // Fine-tune the weight of each search factor.  These factors should add up to 100.
    $weight = array(
        // The more message within a topic match the search query, the higher the ranking.
        'frequency' => 30,
        // The more recent a message is, the higher its ranking.
        'age' => 25,
        // The larger the topic is, the higher its ranking.
        'length' => 20,
        // If a search string happens to be part of the topic subject, it's probably a better match.
        'subject' => 15,
        // If the first message of a topic is a match, then the whole topic might be more interesting.
        'first_message' => 10,
    );
*/

    // These vars don't require an interface, the're just here for tweaking.
    $recentPercentage = 0.30;
    $humungousTopicPosts = 200;
    $maxMembersToSearch = 500;

    loadTemplate('Search');

    // Are you allowed?
    isAllowedTo('search_posts');

    // So, we're allowed here, let's clean up the start variable - just incase.
    $_REQUEST['start'] = (int) $_REQUEST['start'];

    require_once($sourcedir . '/Display.php');

    // $search_params will carry all settings that differ from the default search parameters.
    // That way, the URLs involved in a search page will be kept as short as possible.
    $search_params = array();

    if (isset($_REQUEST['params']))
    {
        $temp_params = explode('|"|', base64_decode($_REQUEST['params']));
        foreach ($temp_params as $i => $data)
        {
            list ($k, $v) = explode('|\'|', $data);
            $search_params[$k] = stripslashes($v);
        }
        if (isset($search_params['brd']))
            $search_params['brd'] = $search_params['brd'] == '' ? array() : explode(',', $search_params['brd']);
    }

    // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
    if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2))
        $search_params['searchtype'] = 2;

    // Minimum age of messages. Default to zero (don't set param in that case).
    if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0))
        $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];

    // Maximum age of messages. Default to infinite (9999 days: param not set).
    if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999))
        $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];

    $timeAddition = '';
    $timeAddition .= !empty($search_params['minage']) ? ' AND m.posterTime <= ' . (time() - $search_params['minage'] * 86400) : '';
    $timeAddition .= !empty($search_params['maxage']) ? ' AND m.posterTime >= ' . (time() - $search_params['maxage'] * 86400) : '';

    // Default the user name to a wildcard matching every user (*).
    if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*'))
        $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];

    // If there's no specific user, then don't mention it in the main query.
    if (empty($search_params['userspec']))
        $userQuery = '';
    else
    {
        $userString = strtolower(addslashes(strtr($search_params['userspec'], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'))));
        // Retrieve a list of possible members.
        $request = db_query("
            SELECT ID_MEMBER
            FROM {$db_prefix}members
            WHERE realName LIKE '$userString'", __FILE__, __LINE__);
        // Simply do nothing if there're too many members matching the criteria.
        if (mysql_num_rows($request) > $maxMembersToSearch)
            $userQuery = '';
        elseif (mysql_num_rows($request) == 0)
            $userQuery = "m.ID_MEMBER = 0 AND m.posterName LIKE '$userString'";
        else
        {
            $memberlist = array();
            while ($row = mysql_fetch_assoc($request))
                $memberlist[] = $row['ID_MEMBER'];
            $userQuery = "(m.ID_MEMBER IN (" . implode(', ', $memberlist) . ") OR (m.ID_MEMBER = 0 AND m.posterName LIKE '$userString'))";
        }
    }

    // If the boards were passed by URL (params=), temporarily put them back in $_REQUEST.
    if (!empty($search_params['brd']) && is_array($search_params['brd']))
        $_REQUEST['brd'] = $search_params['brd'];

    // Make sure all boards are integers.
    if (!empty($_REQUEST['brd']))
        foreach ($_REQUEST['brd'] as $id => $brd)
            $_REQUEST['brd'][$id] = (int) $brd;

    // Select all boards you've selected AND are allowed to see.
    if ($user_info['is_admin'])
        $search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd'];
    else
    {
        $request = db_query("
            SELECT b.ID_BOARD
            FROM {$db_prefix}boards AS b
            WHERE $user_info[query_see_board]" . (empty($_REQUEST['brd']) ? '' : "
                AND b.ID_BOARD IN (" . implode(', ', $_REQUEST['brd']) . ")"), __FILE__, __LINE__);
        $search_params['brd'] = array();
        while ($row = mysql_fetch_assoc($request))
            $search_params['brd'][] = $row['ID_BOARD'];
        mysql_free_result($request);

        // This error should pro'bly only happen for hackers.
        if (empty($search_params['brd']))
            fatal_lang_error('search_no_boards');
    }

    // If we've selected all boards, this parameter can be left empty.
    $request = db_query("
        SELECT COUNT(ID_BOARD)
        FROM {$db_prefix}boards", __FILE__, __LINE__);
    list ($num_boards) = mysql_fetch_row($request);
    mysql_free_result($request);

    if ($num_boards == count($search_params['brd']))
        $search_params['brd'] = array();
    // Make sure these all boards are numbers.
    elseif (!empty($search_params['brd']))
    {
        foreach ($search_params['brd'] as $k => $v)
            $search_params['brd'][$k] = (int) $v;
    }

    $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']);
    $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']);

    $context['compact'] = !$search_params['show_complete'];

    // What are we searching for?
    $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? stripslashes($_REQUEST['search']) : '');
    // Nothing??
    if (!isset($search_params['search']) || $search_params['search'] == '')
        fatal_lang_error('no_valid_search_string', false);

    // Extract phrase parts first (e.g. some words "this is a phrase" some more words.)
    preg_match_all('/(?:^|\s)"([^"]+)"(?:$|\s)/', $search_params['search'], $matches, PREG_PATTERN_ORDER);
    $searchArray = $matches[1];

    // Remove the phrase parts and extract the words.
    $searchArray = array_merge($searchArray, explode(' ', preg_replace('/(?:^|\s)"([^"]+)"(?:$|\s)/', ' ', $search_params['search'])));

    // Trim everything and make sure there are no words that are the same.
    foreach ($searchArray as $index => $value)
    {
        $searchArray[$index] = addslashes(strtolower(trim($value)));
        if (!isset($searchArray[$index]) || $searchArray[$index] == '')
            unset($searchArray[$index]);
    }
    $searchArray = array_slice(array_unique($searchArray), 0, 10);

    if (empty($searchArray))
        fatal_lang_error('no_valid_search_string', false);

    // Each word is matched against the body and the subject.
    $searchParts = array();
    foreach ($searchArray as $word)
    {
        if (empty($modSettings['search_match_complete_words']))
            $searchParts[] = " LIKE '%" . strtr($word, array('_' => '\\_', '%' => '\\%')) . "%'";
        else
            $searchParts[] = " RLIKE '[[:<:]]" . addcslashes(preg_replace(array('/([\[\]$.+?|{}])/', '/\*/'), array('[$1]', '.+'), $word), '') . "[[:>:]]'";
    }

    $searchQuery = 0;

    // Either all words must match (searchtype == 1) or any of the words (searchtype == 2).
    if (empty($search_params['searchtype']))
    {
        if (!$search_params['subject_only'])
            $searchQuery = 'm.body' . implode(' AND m.body', $searchParts) . $timeAddition;
        $topicQuery = 'm.subject' . implode(' AND m.subject', $searchParts) . $timeAddition;
    }
    else
    {
        if (!$search_params['subject_only'])
            $searchQuery = (count($searchParts) > 1 ? '(' : '') . 'm.body' . implode(' OR m.body', $searchParts) . (count($searchParts) > 1 ? ')' : '') . $timeAddition;
        $topicQuery = (count($searchParts) > 1 ? '(' : '') . 'm.subject' . implode(' OR m.subject', $searchParts) . (count($searchParts) > 1 ? ')' : '') . $timeAddition;
    }

    // Get the sorting parameters right. Default to sort by relevance descending.
    $sort_columns = array(
        'relevance',
        'numReplies',
        'ID_MSG',
    );
    if (empty($search_params['sort']) && !empty($_REQUEST['sort']))
        list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
    $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance';
    $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc';

    $context['mark'] = array();
    foreach ($searchArray as $word)
        $context['mark'][$word] = '<b class="highlight">' . $word . '</b>';

    // All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below.
    $temp_params = $search_params;
    if (isset($temp_params['brd']))
        $temp_params['brd'] = implode(',', $temp_params['brd']);
    $context['params'] = array();
    foreach ($temp_params as $k => $v)
        $context['params'][] = $k . '|\'|' . addslashes($v);
    $context['params'] = base64_encode(implode('|"|', $context['params']));

    // ... and add the links to the link tree.
    $context['linktree'][] = array(
        'url' => $scripturl . '?action=search;params=' . $context['params'],
        'name' => $txt[182]
    );
    $context['linktree'][] = array(
        'url' => $scripturl . '?action=search2;params=' . $context['params'],
        'name' => $txt['search_results']
    );

    // Determine some values needed to calculate the relevance.
    $minMsg = (int) (1 - $recentPercentage) * $modSettings['maxMsgID'];
    $recentMsg = $modSettings['maxMsgID'] - $minMsg;

    $mainQuery = "
                t.ID_TOPIC,
                $weight[frequency] * IF(m.ID_MSG IS NOT NULL, COUNT(m.ID_MSG) / (t.numReplies + 1), 0) +
                $weight[age] * IF(m.ID_MSG IS NULL OR MAX(m.ID_MSG) < $minMsg, 0, (MAX(m.ID_MSG) - $minMsg) / $recentMsg) +
                $weight[length] * IF(t.numReplies < $humungousTopicPosts, t.numReplies / $humungousTopicPosts, 1) +
                $weight[subject] * t.is_subject +
                $weight[first_message] * IF(MIN(m.ID_MSG) = t.ID_FIRST_MSG, 1, 0) AS relevance,
                IF(COUNT(m.ID_MSG) = 0, t.ID_FIRST_MSG, MAX(m.ID_MSG)) AS ID_MSG, COUNT(m.ID_MSG) AS num_matches
            FROM {$db_prefix}matches AS t
                LEFT JOIN {$db_prefix}messages AS m ON (m.ID_TOPIC = t.ID_TOPIC AND $searchQuery)" . (empty($userQuery) ? '' : "
            WHERE $userQuery") ."
            GROUP BY t.ID_TOPIC";

    $context['topics'] = array();
    $use_cache = !empty($modSettings['search_cache_size']);

    // Either the results are not cached, or caching is disabled, so we need to create a temporary table.
    if (!$use_cache || empty($_SESSION['search_cache']) || $_SESSION['search_cache']['params'] != $context['params'])
    {
        // Temporary tables are preferrable, but require the right MySQL permissions.
        if (empty($modSettings['disableTemporaryTables']))
        {
            // Get rid of it if it already exists.
            mysql_query("
                DROP TABLE {$db_prefix}matches");

            $result = mysql_query("
                CREATE TEMPORARY TABLE {$db_prefix}matches (
                    ID_TOPIC mediumint(8) unsigned NOT NULL default '0',
                    ID_FIRST_MSG int(10) unsigned NOT NULL default '0',
                    numReplies int(11) NOT NULL default '0',
                    is_subject tinyint(3) unsigned NOT NULL default '0',
                    PRIMARY KEY (ID_TOPIC)
                ) TYPE=HEAP");

            if ($result === false)
            {
                updateSettings(array('disableTemporaryTables' => '1'));
                fatal_lang_error('unable_to_create_temporary');
            }

            if (!$search_params['subject_only'])
            {
                // Let's determine how many results we can expect.
                db_query("
                    INSERT INTO {$db_prefix}matches
                    SELECT DISTINCT t.ID_TOPIC, t.ID_FIRST_MSG, t.numReplies, 0 AS is_subject
                    FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
                    WHERE t.ID_TOPIC = m.ID_TOPIC" . (empty($search_params['brd']) ? '' : "
                        AND m.ID_BOARD IN (" . implode(', ', $search_params['brd']) . ")") . (empty($userQuery) ? '' : "
                        AND $userQuery") . "
                        AND $searchQuery", __FILE__, __LINE__);
                $messageMatches = db_affected_rows();
            }

            // Select all topics that have subjects matching the search query.
            db_query("
                INSERT IGNORE INTO {$db_prefix}matches
                SELECT m.ID_TOPIC AS ID_TOPIC, m.ID_MSG, t.numReplies, 1 AS is_subject
                FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
                WHERE m.ID_MSG = t.ID_FIRST_MSG" . (empty($search_params['brd']) ? '' : "
                    AND m.ID_BOARD IN (" . implode(', ', $search_params['brd']) . ")") . (empty($userQuery) ? '' : "
                    AND $userQuery") . "
                    AND $topicQuery", __FILE__, __LINE__);
            $subjectMatches = db_affected_rows();

            if (!$search_params['subject_only'])
            {
                $request = db_query("
                    SELECT COUNT(ID_TOPIC)
                    FROM {$db_prefix}matches", __FILE__, __LINE__);
                list ($numResults) = mysql_fetch_row($request);
                mysql_free_result($request);
            }
            else
                $numResults = $subjectMatches;

            if (empty($numResults))
                $use_cache = false;
            elseif (!$use_cache || $numResults <= $modSettings['search_results_per_page'])
            {
                $request = db_query("
                    SELECT$mainQuery
                    ORDER BY $search_params[sort] $search_params[sort_dir]
                    LIMIT $_REQUEST[start], $modSettings[search_results_per_page]", __FILE__, __LINE__);
                while ($row = mysql_fetch_assoc($request))
                    $context['topics'][$row['ID_MSG']] = array(
                        'id' => $row['ID_TOPIC'],
                        'relevance' => round(100 * $row['relevance'] / $weight_total, 1) . '%',
                        'num_matches' => $row['num_matches'],
                        'matches' => array(),
                    );
                mysql_free_result($request);

                // We don't need cache, thank you.
                $use_cache = false;
            }
            // Search is not yet cached, let's cache it.
            elseif ($use_cache)
            {
                $modSettings['search_pointer'] = empty($modSettings['search_pointer']) ? 0 : (int) $modSettings['search_pointer'];

                // Increase the pointer.
                updateSettings(array('search_pointer' => $modSettings['search_pointer'] >= 255 ? 0 : $modSettings['search_pointer'] + 1));

                // Make sure this value isn't larger than 255 or the tinyint key field wouldn't be able to handle it.
                $modSettings['search_cache_size'] = empty($modSettings['search_cache_size']) || $modSettings['search_cache_size'] > 255 ? 255 : $modSettings['search_cache_size'];

                // Remove old cached results and (if set) the previous session cached result.
                db_query("
                    DELETE FROM {$db_prefix}log_search
                    WHERE (ID_SEARCH >= $modSettings[search_pointer]" . ($modSettings['search_pointer'] < $modSettings['search_cache_size'] ? '
                        AND ID_SEARCH < ' . (256 + $modSettings['search_pointer'] - $modSettings['search_cache_size']) : '
                        OR ID_SEARCH < ' . ($modSettings['search_pointer'] - $modSettings['search_cache_size'])) . ')' . (isset($_SESSION['search_cache']['ID_SEARCH']) ? "
                        OR ID_SEARCH = " . $_SESSION['search_cache']['ID_SEARCH'] : ''), __FILE__, __LINE__);

                // Insert the new cached results.
                if (!empty($numResults))
                    db_query("
                        INSERT IGNORE INTO {$db_prefix}log_search
                            (ID_SEARCH, ID_TOPIC, relevance, ID_MSG, num_matches)
                        SELECT $modSettings[search_pointer], $mainQuery", __FILE__, __LINE__);
                $numResults = empty($numResults) ? 0 : db_affected_rows();

                // Store it for the session.
                $_SESSION['search_cache'] = array(
                    'ID_SEARCH' => $modSettings['search_pointer'],
                    'num_results' => $numResults,
                    'params' => $context['params'],
                );
            }

            // Get rid of the temporary table.
            $request = db_query("
                DROP TABLE {$db_prefix}matches", __FILE__, __LINE__);
        }
        // Create temporary tables is disabled, we're gonna need to use PHP's memory and sorting.
        else
        {
            $matchingTopics = array();

            if (!$search_params['subject_only'])
            {
                // Get all the topics with a message match.
                $request = db_query("
                    SELECT DISTINCT t.ID_TOPIC, t.ID_FIRST_MSG, t.numReplies, 0 AS is_subject
                    FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
                    WHERE t.ID_TOPIC = m.ID_TOPIC" . (empty($search_params['brd']) ? '' : "
                        AND m.ID_BOARD IN (" . implode(', ', $search_params['brd']) . ")") . (empty($userQuery) ? '' : "
                        AND $userQuery") . "
                        AND $searchQuery", __FILE__, __LINE__);
                while ($row = mysql_fetch_assoc($request))
                    $matchingTopics[$row['ID_TOPIC']] = $row;
                $messageMatches = count($matchingTopics);
            }

            // Get all the topics with a subject match.
            $request = db_query("
                SELECT m.ID_TOPIC AS ID_TOPIC, t.ID_FIRST_MSG, t.numReplies, 1 AS is_subject
                FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
                WHERE m.ID_MSG = t.ID_FIRST_MSG" . (empty($search_params['brd']) ? '' : "
                    AND m.ID_BOARD IN (" . implode(', ', $search_params['brd']) . ")") . (empty($userQuery) ? '' : "
                    AND $userQuery") . "
                    AND $topicQuery", __FILE__, __LINE__);
            while ($row = mysql_fetch_assoc($request))
                $matchingTopics[$row['ID_TOPIC']] = $row;
            $subjectMatches = db_affected_rows();

            $numResults = $search_params['subject_only'] ? $subjectMatches : count($matchingTopics);

            if (empty($numResults))
                $use_cache = false;
            elseif (!$use_cache || $numResults <= $modSettings['search_results_per_page'])
            {
                
Link to comment
https://forums.phpfreaks.com/topic/8579-swfe2-search-script/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.