Version 2.1.7
This commit is contained in:
1 parent
0eecc172d9
commit
f73f8bff6d
941 files changed
+215301
-103093
No files matched your search
@@ -2,16 +2,28 @@
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
| Invision Power Board v2.0.0
|
||||
| Invision Power Board 2.1.7
|
||||
| =============================================
|
||||
| by Matthew Mecham
|
||||
| (c) 2001 - 2004 Invision Power Services, Inc.
|
||||
| (c) 2001 - 2005 Invision Power Services, Inc.
|
||||
| http://www.invisionpower.com
|
||||
| =============================================
|
||||
| Web: http://www.invisionboard.com
|
||||
| Time: Tue, 21 Sep 2004 16:34:28 GMT
|
||||
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
|
||||
| http://www.ibresource.ru/products/invisionpowerboard/
|
||||
| Time: Tuesday 18th of July 2006 05:56:00 PM
|
||||
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
|
||||
| Licence Info: http://www.invisionboard.com/?license
|
||||
| http://www.ibresource.ru/license
|
||||
+---------------------------------------------------------------------------
|
||||
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
|
||||
+---------------------------------------------------------------------------
|
||||
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
|
||||
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
|
||||
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
|
||||
+---------------------------------------------------------------------------
|
||||
| > $Date: 2006-02-02 17:23:13 +0000 (Thu, 02 Feb 2006) $
|
||||
| > $Revision: 133 $
|
||||
| > $Author: bfarber $
|
||||
+---------------------------------------------------------------------------
|
||||
|
|
||||
| > MySQL FULL TEXT Search Library
|
||||
@@ -28,18 +40,16 @@ class search_lib extends Search
|
||||
|
||||
var $parser = "";
|
||||
var $is = "";
|
||||
var $resultlimit = "";
|
||||
|
||||
//-----------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------
|
||||
|
||||
function search_lib($that)
|
||||
function search_lib(&$that)
|
||||
{
|
||||
global $ibforums, $DB, $std, $print;
|
||||
|
||||
$this->is = &$that; // hahaha!
|
||||
|
||||
|
||||
$this->is = &$that; // hahaha!
|
||||
$this->resultlimit = $this->is->resultlimit;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -48,11 +58,10 @@ class search_lib extends Search
|
||||
|
||||
function do_simple_search()
|
||||
{
|
||||
global $ibforums, $DB, $std, $HTTP_POST_VARS, $print, $forums;
|
||||
|
||||
if ( ! $ibforums->input['sid'] )
|
||||
if ( ! $this->ipsclass->input['sid'] )
|
||||
{
|
||||
$boolean = "";
|
||||
$boolean = "";
|
||||
$topics_name = "";
|
||||
|
||||
//-----------------------------------------
|
||||
// NEW SEARCH.. Check Keywords..
|
||||
@@ -61,23 +70,23 @@ class search_lib extends Search
|
||||
if ( $this->is->mysql_version >= 40010 )
|
||||
{
|
||||
$boolean = 'IN BOOLEAN MODE';
|
||||
$keywords = $this->is->filter_ftext_keywords($ibforums->input['keywords']);
|
||||
$keywords = $this->is->filter_ftext_keywords($this->ipsclass->input['keywords']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['keywords']);
|
||||
$keywords = $this->is->filter_keywords($this->ipsclass->input['keywords']);
|
||||
}
|
||||
|
||||
$check_keywords = trim($keywords);
|
||||
|
||||
if ( (! $check_keywords) or ($check_keywords == "") or (! isset($check_keywords) ) )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
|
||||
}
|
||||
|
||||
if (strlen(trim($keywords)) < $ibforums->vars['min_search_word'])
|
||||
if (strlen(trim($keywords)) < $this->ipsclass->vars['min_search_word'])
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -99,9 +108,9 @@ class search_lib extends Search
|
||||
// Allow abc* but not a***
|
||||
//-----------------------------------------
|
||||
|
||||
if ( strlen( $t ) < 3 )
|
||||
if ( strlen( $t ) < $this->ipsclass->vars['min_search_word'] )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => $this->ipsclass->vars['min_search_word']) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,26 +124,48 @@ class search_lib extends Search
|
||||
|
||||
if ($myforums == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Only allowed to see their own topics?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->ipsclass->member['g_other_topics'] )
|
||||
{
|
||||
$topics_name = " AND t.starter_id=".$this->ipsclass->member['id'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Allowed to see queueueueueuueueueued?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->ipsclass->member['g_is_supmod'] )
|
||||
{
|
||||
$approved = 'and p.queued=0 and t.approved=1';
|
||||
}
|
||||
else
|
||||
{
|
||||
$approved = 'and p.queued IN (0,1)';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// How many results?
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query("SELECT COUNT(*) as dracula
|
||||
FROM ".SQL_PREFIX."posts p
|
||||
LEFT JOIN ".SQL_PREFIX."topics t ON (t.tid=p.topic_id)
|
||||
WHERE t.forum_id IN ($myforums)
|
||||
AND MATCH(p.post) AGAINST ('$check_keywords' $boolean)");
|
||||
$this->ipsclass->DB->query("SELECT COUNT(*) as dracula
|
||||
FROM ".SQL_PREFIX."posts p
|
||||
LEFT JOIN ".SQL_PREFIX."topics t ON (t.tid=p.topic_id)
|
||||
WHERE t.forum_id IN ($myforums) {$topics_name} {$approved}
|
||||
AND MATCH(p.post) AGAINST ('$check_keywords' $boolean)");
|
||||
|
||||
$count = $DB->fetch_row();
|
||||
$count = $this->ipsclass->DB->fetch_row();
|
||||
|
||||
if ( $count['dracula'] < 1 ) // Tee-hee!
|
||||
{
|
||||
$this->output .= $this->is->html->search_error_page($ibforums->input['keywords']);
|
||||
$print->add_output( $this->output );
|
||||
$print->do_output( array( 'TITLE' => $ibforums->lang['g_simple_title'], 'JS' => 0, NAV => array( $ibforums->lang['g_simple_title'] ) ) );
|
||||
$this->output .= $this->ipsclass->compiled_templates['skin_search']->search_error_page($this->ipsclass->input['keywords']);
|
||||
$this->ipsclass->print->add_output( $this->output );
|
||||
$this->ipsclass->print->do_output( array( 'TITLE' => $this->ipsclass->lang['g_simple_title'], 'JS' => 0, NAV => array( $this->ipsclass->lang['g_simple_title'] ) ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -147,34 +178,34 @@ class search_lib extends Search
|
||||
LEFT JOIN ".SQL_PREFIX."topics t on (p.topic_id=t.tid)
|
||||
LEFT JOIN ".SQL_PREFIX."members m on (m.id=p.author_id)
|
||||
LEFT JOIN ".SQL_PREFIX."member_extra me on (me.id=p.author_id)
|
||||
WHERE t.forum_id IN ($myforums) AND t.title IS NOT NULL
|
||||
WHERE t.forum_id IN ($myforums) AND t.title IS NOT NULL {$topics_name} {$approved}
|
||||
AND MATCH(post) AGAINST ('$check_keywords' $boolean)";
|
||||
|
||||
if ( $ibforums->input['sortby'] != "relevant" )
|
||||
if ( $this->ipsclass->input['sortby'] != "relevant" )
|
||||
{
|
||||
$cache .= " ORDER BY p.post_date DESC";
|
||||
}
|
||||
|
||||
$unique_id = md5(uniqid(microtime(),1));
|
||||
|
||||
$str = $DB->compile_db_insert_string( array (
|
||||
$str = $this->ipsclass->DB->compile_db_insert_string( array (
|
||||
'id' => $unique_id,
|
||||
'search_date'=> time(),
|
||||
'topic_id' => '00',
|
||||
'topic_max' => $count['dracula'],
|
||||
'member_id' => $ibforums->member['id'],
|
||||
'ip_address' => $ibforums->input['IP_ADDRESS'],
|
||||
'member_id' => $this->ipsclass->member['id'],
|
||||
'ip_address' => $this->ipsclass->input['IP_ADDRESS'],
|
||||
'post_id' => '00',
|
||||
'query_cache'=> $cache,
|
||||
|
||||
) );
|
||||
|
||||
$DB->query("INSERT INTO ibf_search_results ({$str['FIELD_NAMES']}) VALUES ({$str['FIELD_VALUES']})");
|
||||
$this->ipsclass->DB->query("INSERT INTO ibf_search_results ({$str['FIELD_NAMES']}) VALUES ({$str['FIELD_VALUES']})");
|
||||
|
||||
$hilight = str_replace( '"', '', $ibforums->input['keywords'] );
|
||||
$hilight = str_replace( '"', '', $this->ipsclass->input['keywords'] );
|
||||
$hilight = urlencode(trim(str_replace( '&', '&', $hilight)));
|
||||
|
||||
$print->redirect_screen( $ibforums->lang['search_redirect'] , "act=Search&CODE=simpleresults&sid=$unique_id&highlite=".$hilight );
|
||||
$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['search_redirect'] , "act=Search&CODE=simpleresults&sid=$unique_id&highlite=".$hilight );
|
||||
|
||||
}
|
||||
else
|
||||
@@ -183,45 +214,47 @@ class search_lib extends Search
|
||||
// Load up the topic stuff
|
||||
//-----------------------------------------
|
||||
|
||||
require_once( ROOT_PATH.'sources/topics.php' );
|
||||
require_once( ROOT_PATH.'sources/action_public/topics.php' );
|
||||
$this->topics = new topics();
|
||||
$this->topics->ipsclass =& $this->ipsclass;
|
||||
|
||||
$this->topics->topic_init();
|
||||
|
||||
//-----------------------------------------
|
||||
// Get SQL schtuff
|
||||
//-----------------------------------------
|
||||
|
||||
$this->unique_id = $ibforums->input['sid'];
|
||||
$this->unique_id = $this->ipsclass->input['sid'];
|
||||
|
||||
if ($this->unique_id == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
}
|
||||
|
||||
$DB->query("SELECT * FROM ibf_search_results WHERE id='{$this->unique_id}'");
|
||||
$this->ipsclass->DB->query("SELECT * FROM ibf_search_results WHERE id='{$this->unique_id}'");
|
||||
|
||||
if ( ! $sr = $DB->fetch_row() )
|
||||
if ( ! $sr = $this->ipsclass->DB->fetch_row() )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
|
||||
}
|
||||
|
||||
$query = stripslashes($sr['query_cache']);
|
||||
|
||||
$check_keywords = preg_replace( '/&(lt|gt|quot);/', "&\\1;", trim(urldecode($ibforums->input['highlite'])) );
|
||||
$check_keywords = preg_replace( '/&(lt|gt|quot);/', "&\\1;", trim(urldecode($this->ipsclass->input['highlite'])) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Display
|
||||
//-----------------------------------------
|
||||
|
||||
$this->links = $std->build_pagelinks(
|
||||
$this->links = $this->ipsclass->build_pagelinks(
|
||||
array(
|
||||
'TOTAL_POSS' => $sr['topic_max'],
|
||||
'leave_out' => 10,
|
||||
'PER_PAGE' => 25,
|
||||
'CUR_ST_VAL' => $this->is->first,
|
||||
'L_SINGLE' => $ibforums->lang['sp_single'],
|
||||
'L_SINGLE' => $this->ipsclass->lang['sp_single'],
|
||||
'L_MULTI' => "",
|
||||
'BASE_URL' => $ibforums->base_url."&act=Search&CODE=simpleresults&sid=".$this->unique_id."&highlite=".urlencode(str_replace('"', '', $check_keywords)),
|
||||
'BASE_URL' => $this->ipsclass->base_url."&act=Search&CODE=simpleresults&sid=".$this->unique_id."&highlite=".urlencode(str_replace('"', '', $check_keywords)),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -235,7 +268,7 @@ class search_lib extends Search
|
||||
|
||||
$SQLtime->startTimer();
|
||||
|
||||
$outer = $DB->query($query." LIMIT {$this->is->first},25");
|
||||
$outer = $this->ipsclass->DB->query($query." LIMIT {$this->is->first},25");
|
||||
|
||||
$ex_time = sprintf( "%.4f",$SQLtime->endTimer() );
|
||||
|
||||
@@ -246,18 +279,18 @@ class search_lib extends Search
|
||||
$show_end = $sr['topic_max'];
|
||||
}
|
||||
|
||||
$this->output .= $this->is->html->result_simple_header(array(
|
||||
'links' => $this->links,
|
||||
'start' => $this->is->first,
|
||||
'end' => $show_end + $this->is->first,
|
||||
'matches' => $sr['topic_max'],
|
||||
'ex_time' => $ex_time,
|
||||
'keyword' => $check_keywords,
|
||||
) );
|
||||
$this->output .= $this->ipsclass->compiled_templates['skin_search']->result_simple_header(array(
|
||||
'links' => $this->links,
|
||||
'start' => $this->is->first,
|
||||
'end' => $show_end + $this->is->first,
|
||||
'matches' => $sr['topic_max'],
|
||||
'ex_time' => $ex_time,
|
||||
'keyword' => $check_keywords,
|
||||
) );
|
||||
|
||||
$attach_pids = array();
|
||||
|
||||
while ( $row = $DB->fetch_row($outer) )
|
||||
while ( $row = $this->ipsclass->DB->fetch_row($outer) )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Listen up, this is relevant.
|
||||
@@ -273,13 +306,13 @@ class search_lib extends Search
|
||||
|
||||
$row['relevance'] = sprintf( "%3d", ( $row['score'] > 1.0 ) ? 100 : $row['score'] * 100 );
|
||||
|
||||
$row['post_date'] = $std->get_date( $row['post_date'], 'LONG' );
|
||||
$row['post_date'] = $this->ipsclass->get_date( $row['post_date'], 'LONG' );
|
||||
|
||||
// Link member's name
|
||||
|
||||
if ($row['author_id'])
|
||||
{
|
||||
$row['author_name'] = "<a href='{$ibforums->base_url}act=Profile&MID={$row['author_id']}'>{$row['author_name']}</a>";
|
||||
$row['author_name'] = "<a href='{$this->ipsclass->base_url}act=Profile&MID={$row['author_id']}'>{$row['author_name']}</a>";
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -295,22 +328,14 @@ class search_lib extends Search
|
||||
// Fix up quotes..
|
||||
//-----------------------------------------
|
||||
|
||||
$row['post'] = $this->topics->parser->unconvert( $row['post'] );
|
||||
$this->topics->parser->parse_html = ( $this->ipsclass->forums->forum_by_id[$row['forum_id']]['use_html'] and $this->ipsclass->cache['group_cache'][ $row['mgroup'] ]['g_dohtml'] and $row['post_htmlstate'] ) ? 1 : 0;
|
||||
$this->topics->parser->parse_wordwrap = $this->ipsclass->vars['post_wordwrap'];
|
||||
$this->topics->parser->parse_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
|
||||
|
||||
$row['post'] = $this->topics->parser->convert( array(
|
||||
'TEXT' => $row['post'],
|
||||
'CODE' => $forums->forum_by_id[$row['forum_id']]['use_ibc'],
|
||||
'SMILIES' => 1,
|
||||
'HTML' => 0
|
||||
) );
|
||||
|
||||
$this->topics->parser->pp_do_html = ( $forums->forum_by_id[$row['forum_id']]['use_html'] and $ibforums->cache['group_cache'][ $row['mgroup'] ]['g_dohtml'] and $row['post_htmlstate'] ) ? 1 : 0;
|
||||
$this->topics->parser->pp_wordwrap = $ibforums->vars['post_wordwrap'];
|
||||
$this->topics->parser->pp_nl2br = $row['post_htmlstate'] == 2 ? 1 : 0;
|
||||
$row['post'] = $this->topics->parser->pre_db_parse( $this->topics->parser->pre_edit_parse( $row['post'] ) );
|
||||
$row['post'] = $this->topics->parser->pre_display_parse( $row['post'] );
|
||||
|
||||
$row['post'] = $this->topics->parser->post_db_parse( $row['post'] );
|
||||
|
||||
$keywords_array = explode( " ", str_replace( "+", " ", $ibforums->input['highlite'] ) );
|
||||
$keywords_array = explode( " ", str_replace( "+", " ", $this->ipsclass->input['highlite'] ) );
|
||||
|
||||
if ( count($keywords_array) )
|
||||
{
|
||||
@@ -328,10 +353,10 @@ class search_lib extends Search
|
||||
}
|
||||
}
|
||||
|
||||
$row['forum_name'] = $forums->forum_by_id[ $row['forum_id'] ]['name'];
|
||||
$row['forum_name'] = $this->ipsclass->forums->forum_by_id[ $row['forum_id'] ]['name'];
|
||||
|
||||
|
||||
$this->output .= $this->is->html->RenderPostRow($row, $member);
|
||||
$this->output .= $this->ipsclass->compiled_templates['skin_search']->RenderPostRow($row, $member);
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -343,10 +368,10 @@ class search_lib extends Search
|
||||
$this->output = $this->topics->parse_attachments( $this->output, $attach_pids );
|
||||
}
|
||||
|
||||
$this->output .= $this->is->html->end_results_table(array( 'SHOW_PAGES' => $this->links ) , 1 );
|
||||
$this->output .= $this->ipsclass->compiled_templates['skin_search']->end_results_table(array( 'SHOW_PAGES' => $this->links ) , 1 );
|
||||
|
||||
$print->add_output("$this->output");
|
||||
$print->do_output( array( 'TITLE' => $ibforums->lang['g_simple_title'], 'JS' => 0, NAV => array( $ibforums->lang['g_simple_title'] ) ) );
|
||||
$this->ipsclass->print->add_output("$this->output");
|
||||
$this->ipsclass->print->do_output( array( 'TITLE' => $this->ipsclass->lang['g_simple_title'], 'JS' => 0, NAV => array( $this->ipsclass->lang['g_simple_title'] ) ) );
|
||||
|
||||
}
|
||||
|
||||
@@ -362,8 +387,40 @@ class search_lib extends Search
|
||||
|
||||
function do_main_search()
|
||||
{
|
||||
global $ibforums, $DB, $std, $HTTP_POST_VARS, $print;
|
||||
//-----------------------------------------
|
||||
// Invisible topic-approval permissions?
|
||||
//-----------------------------------------
|
||||
|
||||
$my_invisible_forums_t = array();
|
||||
$my_invisible_forums_p = array();
|
||||
|
||||
if( is_array($this->ipsclass->cache['moderators']) AND count($this->ipsclass->cache['moderators']) )
|
||||
{
|
||||
foreach( $this->ipsclass->cache['moderators'] as $k => $v )
|
||||
{
|
||||
if( $v['member_id'] == $this->ipsclass->member['id'] AND $v['post_q'] )
|
||||
{
|
||||
$my_invisible_forums_p[] = $v['forum_id'];
|
||||
}
|
||||
|
||||
if( $v['member_id'] == $this->ipsclass->member['id'] AND $v['topic_q'] )
|
||||
{
|
||||
$my_invisible_forums_t[] = $v['forum_id'];
|
||||
}
|
||||
|
||||
if( $v['is_group'] && ( $v['group_id'] == $this->ipsclass->member['mgroup']
|
||||
OR in_array( $v['group_id'], explode( ",", $this->ipsclass->clean_perm_string( $this->ipsclass->member['mgroup_others'] ) ) ) ) && $v['post_q'] )
|
||||
{
|
||||
$my_invisible_forums_p[] = $v['forum_id'];
|
||||
}
|
||||
|
||||
if( $v['is_group'] && ( $v['group_id'] == $this->ipsclass->member['mgroup']
|
||||
OR in_array( $v['group_id'], explode( ",", $this->ipsclass->clean_perm_string( $this->ipsclass->member['mgroup_others'] ) ) ) ) && $v['topic_q'] )
|
||||
{
|
||||
$my_invisible_forums_t[] = $v['forum_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
//-----------------------------------------
|
||||
// Do we have any input?
|
||||
//-----------------------------------------
|
||||
@@ -373,31 +430,31 @@ class search_lib extends Search
|
||||
//-----------------------------------------
|
||||
|
||||
|
||||
if ($ibforums->input['namesearch'] != "")
|
||||
if ($this->ipsclass->input['namesearch'] != "")
|
||||
{
|
||||
$name_filter = $this->is->filter_keywords($ibforums->input['namesearch'], 1);
|
||||
$name_filter = $this->is->filter_keywords($this->ipsclass->input['namesearch'], 1);
|
||||
}
|
||||
|
||||
if ($ibforums->input['useridsearch'] != "")
|
||||
if ($this->ipsclass->input['useridsearch'] != "")
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['useridsearch']);
|
||||
$keywords = $this->is->filter_keywords($this->ipsclass->input['useridsearch']);
|
||||
$this->is->search_type = 'userid';
|
||||
}
|
||||
else
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['keywords']);
|
||||
$keywords = $this->is->filter_keywords($this->ipsclass->input['keywords']);
|
||||
$this->is->search_type = 'posts';
|
||||
}
|
||||
|
||||
if ( $name_filter != "" AND $ibforums->input['keywords'] != "" )
|
||||
if ( $name_filter != "" AND $this->ipsclass->input['keywords'] != "" )
|
||||
{
|
||||
$type = 'joined';
|
||||
}
|
||||
else if ( $name_filter == "" AND $ibforums->input['keywords'] != "" )
|
||||
else if ( $name_filter == "" AND $this->ipsclass->input['keywords'] != "" )
|
||||
{
|
||||
$type= 'postonly';
|
||||
}
|
||||
else if ( $name_filter != "" AND $ibforums->input['keywords'] == "" )
|
||||
else if ( $name_filter != "" AND $this->ipsclass->input['keywords'] == "" )
|
||||
{
|
||||
$type='nameonly';
|
||||
}
|
||||
@@ -407,27 +464,35 @@ class search_lib extends Search
|
||||
if ( $this->is->mysql_version >= 40010 )
|
||||
{
|
||||
$boolean = 'IN BOOLEAN MODE';
|
||||
$keywords = $this->is->filter_ftext_keywords($ibforums->input['keywords']);
|
||||
$keywords = $this->is->filter_ftext_keywords($this->ipsclass->input['keywords']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$keywords = $this->is->filter_keywords($ibforums->input['keywords']);
|
||||
$keywords = $this->is->filter_keywords($this->ipsclass->input['keywords']);
|
||||
}
|
||||
|
||||
$check_keywords = trim($keywords);
|
||||
|
||||
if ( (! $check_keywords) or ($check_keywords == "") or (! isset($check_keywords) ) )
|
||||
{
|
||||
if ($ibforums->input['namesearch'] == "")
|
||||
if ($this->ipsclass->input['namesearch'] == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( strlen(trim($keywords)) < $ibforums->vars['min_search_word'] and $type != 'nameonly' )
|
||||
if ( strlen(trim($keywords)) < $this->ipsclass->vars['min_search_word'] and $type != 'nameonly' )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
if ( $this->is->xml_out )
|
||||
{
|
||||
print sprintf( $this->ipsclass->lang['xml_char'], $this->ipsclass->vars['min_search_word'] );
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => $this->ipsclass->vars['min_search_word']) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,15 +515,23 @@ class search_lib extends Search
|
||||
// Allow abc* but not a***
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ( strlen( $t ) < $ibforums->vars['min_search_word'] ) and $type != 'nameonly' )
|
||||
if ( ( strlen( $t ) < $this->ipsclass->vars['min_search_word'] ) and $type != 'nameonly' )
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => 4) );
|
||||
if ( $this->is->xml_out )
|
||||
{
|
||||
print sprintf( $this->ipsclass->lang['xml_char'], $this->ipsclass->vars['min_search_word'] );
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => $this->ipsclass->vars['min_search_word']) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->input['search_in'] == 'titles')
|
||||
if ($this->ipsclass->input['search_in'] == 'titles')
|
||||
{
|
||||
$this->is->search_in = 'titles';
|
||||
}
|
||||
@@ -473,14 +546,14 @@ class search_lib extends Search
|
||||
|
||||
if ($forums == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
foreach( array( 'last_post', 'posts', 'starter_name', 'forum_id' ) as $v )
|
||||
{
|
||||
if ($ibforums->input['sort_key'] == $v)
|
||||
if ( $this->ipsclass->input['sort_key'] == $v )
|
||||
{
|
||||
$this->is->sort_key = $v;
|
||||
}
|
||||
@@ -490,7 +563,7 @@ class search_lib extends Search
|
||||
|
||||
foreach ( array( 1, 7, 30, 60, 90, 180, 365, 0 ) as $v )
|
||||
{
|
||||
if ($ibforums->input['prune'] == $v)
|
||||
if ($this->ipsclass->input['prune'] == $v)
|
||||
{
|
||||
$this->is->prune = $v;
|
||||
}
|
||||
@@ -498,21 +571,21 @@ class search_lib extends Search
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->input['sort_order'] == 'asc')
|
||||
if ($this->ipsclass->input['sort_order'] == 'asc')
|
||||
{
|
||||
$this->is->sort_order = 'asc';
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
if ($ibforums->input['result_type'] == 'posts')
|
||||
if ($this->ipsclass->input['result_type'] == 'posts')
|
||||
{
|
||||
$this->is->result_type = 'posts';
|
||||
}
|
||||
|
||||
if ( $ibforums->vars['min_search_word'] < 1 )
|
||||
if ( $this->ipsclass->vars['min_search_word'] < 1 )
|
||||
{
|
||||
$ibforums->vars['min_search_word'] = 4;
|
||||
$this->ipsclass->vars['min_search_word'] = 4;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -521,8 +594,8 @@ class search_lib extends Search
|
||||
|
||||
if ($this->is->prune > 0)
|
||||
{
|
||||
$gt_lt = $ibforums->input['prune_type'] == 'older' ? "<" : ">";
|
||||
$time = time() - ($ibforums->input['prune'] * 86400);
|
||||
$gt_lt = $this->ipsclass->input['prune_type'] == 'older' ? "<" : ">";
|
||||
$time = time() - ($this->ipsclass->input['prune'] * 86400);
|
||||
|
||||
if ( $this->is->result_type == 'posts' )
|
||||
{
|
||||
@@ -536,33 +609,46 @@ class search_lib extends Search
|
||||
$posts_datecut = "p.post_date $gt_lt $time AND";
|
||||
}
|
||||
|
||||
// Is this a membername search?
|
||||
//-----------------------------------------
|
||||
// Only allowed to see their own topics?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->ipsclass->member['g_other_topics'] )
|
||||
{
|
||||
$name_filter = "";
|
||||
$posts_name = " AND t.starter_id=".$this->ipsclass->member['id'];
|
||||
$topics_name = " AND t.starter_id=".$this->ipsclass->member['id'];
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// Is this a membername search?
|
||||
//-----------------------------------------
|
||||
|
||||
$name_filter = trim( $name_filter );
|
||||
$member_string = "";
|
||||
|
||||
$name_filter = trim( $name_filter );
|
||||
$member_string = "";
|
||||
|
||||
if ( $name_filter != "" )
|
||||
{
|
||||
if ( $name_filter != "" )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get all the possible matches for the supplied name from the DB
|
||||
//-----------------------------------------
|
||||
|
||||
$name_filter = str_replace( '|', "|", $name_filter );
|
||||
|
||||
if ($ibforums->input['exactname'] == 1)
|
||||
if ($this->ipsclass->input['exactname'] == 1)
|
||||
{
|
||||
$sql_query = "SELECT id from ibf_members WHERE lower(name)='".$name_filter."'";
|
||||
$sql_query = "SELECT id from ibf_members WHERE LOWER(members_display_name)='".$name_filter."'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_query = "SELECT id from ibf_members WHERE name like '%".$name_filter."%'";
|
||||
$sql_query = "SELECT id from ibf_members WHERE members_display_name like '%".$name_filter."%'";
|
||||
}
|
||||
|
||||
|
||||
$DB->query( $sql_query );
|
||||
$this->ipsclass->DB->query( $sql_query );
|
||||
|
||||
|
||||
while ($row = $DB->fetch_row())
|
||||
while ($row = $this->ipsclass->DB->fetch_row())
|
||||
{
|
||||
$member_string .= "'".$row['id']."',";
|
||||
}
|
||||
@@ -573,21 +659,19 @@ class search_lib extends Search
|
||||
|
||||
if ($member_string == "")
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_name_search_results') );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_name_search_results') );
|
||||
}
|
||||
|
||||
$posts_name = " AND p.author_id IN ($member_string)";
|
||||
$topics_name = " AND t.starter_id IN ($member_string)";
|
||||
|
||||
}
|
||||
|
||||
if ( $type != 'nameonly' )
|
||||
{
|
||||
if (strlen(trim($keywords)) < $ibforums->vars['min_search_word'])
|
||||
if (strlen(trim($keywords)) < $this->ipsclass->vars['min_search_word'])
|
||||
{
|
||||
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => $ibforums->vars['min_search_word']) );
|
||||
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => $this->ipsclass->vars['min_search_word']) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$unique_id = md5(uniqid(microtime(),1));
|
||||
@@ -596,17 +680,17 @@ class search_lib extends Search
|
||||
{
|
||||
if ( ! $this->is->topic_search_only )
|
||||
{
|
||||
$topics_query = "SELECT t.tid
|
||||
$topics_query = "SELECT t.tid, t.approved, t.forum_id
|
||||
FROM ibf_topics t
|
||||
WHERE $topics_datecut t.forum_id IN ($forums)
|
||||
$topics_name AND t.approved=1 AND MATCH(title) AGAINST ('".trim($keywords)."' $boolean)";
|
||||
|
||||
|
||||
$posts_query = "SELECT p.pid
|
||||
$posts_query = "SELECT p.pid, p.queued, t.approved, t.forum_id
|
||||
FROM ibf_posts p
|
||||
LEFT JOIN ibf_topics t ON ( p.topic_id=t.tid )
|
||||
WHERE $posts_datecut t.forum_id IN ($forums)
|
||||
AND p.queued <> 1
|
||||
AND p.queued=0
|
||||
$posts_name AND MATCH(post) AGAINST ('".trim($keywords)."' $boolean)";
|
||||
}
|
||||
else
|
||||
@@ -615,32 +699,32 @@ class search_lib extends Search
|
||||
// Search in topic only
|
||||
//-----------------------------------------
|
||||
|
||||
$posts_query = "SELECT p.pid
|
||||
$posts_query = "SELECT p.pid, p.queued, t.approved, t.forum_id
|
||||
FROM ibf_posts p
|
||||
LEFT JOIN ibf_topics t ON ( p.topic_id=t.tid )
|
||||
WHERE
|
||||
p.topic_id={$this->is->topic_id}
|
||||
AND $posts_datecut t.forum_id IN ($forums)
|
||||
AND p.queued <> 1
|
||||
AND p.queued=0
|
||||
$posts_name AND MATCH(post) AGAINST ('".trim($keywords)."' $boolean)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$topics_query = "SELECT t.tid
|
||||
$topics_query = "SELECT t.tid, t.approved, t.forum_id
|
||||
FROM ibf_topics t
|
||||
WHERE $topics_datecut t.forum_id IN ($forums)
|
||||
$topics_name";
|
||||
$topics_name AND t.approved=1";
|
||||
|
||||
$posts_query = "SELECT p.pid
|
||||
$posts_query = "SELECT p.pid, p.queued, t.approved, t.forum_id
|
||||
FROM ibf_posts p
|
||||
LEFT JOIN ibf_topics t ON ( p.topic_id=t.tid )
|
||||
WHERE $posts_datecut t.forum_id IN ($forums)
|
||||
AND p.queued <> 1
|
||||
AND p.queued=0
|
||||
$posts_name";
|
||||
}
|
||||
|
||||
//print $topics_query."<br />".$posts_query; exit();
|
||||
//-----------------------------------------
|
||||
// Get the topic ID's to serialize and store into
|
||||
// the database
|
||||
@@ -649,32 +733,112 @@ class search_lib extends Search
|
||||
$topics = "";
|
||||
$posts = "";
|
||||
$topic_array = array();
|
||||
$topic_tmp = array();
|
||||
$post_array = array();
|
||||
$post_tmp = array();
|
||||
$t_cnt = 0;
|
||||
$p_cnt = 0;
|
||||
$more = "";
|
||||
|
||||
//-----------------------------------------
|
||||
// TID: Get 'em
|
||||
//-----------------------------------------
|
||||
|
||||
if ( ! $this->is->topic_search_only )
|
||||
{
|
||||
$DB->query($topics_query);
|
||||
$this->ipsclass->DB->query($topics_query);
|
||||
|
||||
while ($row = $DB->fetch_row() )
|
||||
while ($row = $this->ipsclass->DB->fetch_row() )
|
||||
{
|
||||
$topic_array[ $row['tid'] ] = $row['tid'];
|
||||
if( !$row['approved'] )
|
||||
{
|
||||
if( !$this->ipsclass->member['g_is_supmod'] )
|
||||
{
|
||||
if( !in_array( $row['forum_id'], $my_invisible_forums_t ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$topic_tmp[ $row['tid'] ] = $row['tid'];
|
||||
}
|
||||
|
||||
$DB->free_result();
|
||||
$this->ipsclass->DB->free_result();
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// TID Sort 'em
|
||||
//-----------------------------------------
|
||||
|
||||
$DB->query($posts_query);
|
||||
krsort( $topic_tmp );
|
||||
|
||||
while ($row = $DB->fetch_row() )
|
||||
foreach( $topic_tmp as $id => $tid )
|
||||
{
|
||||
$post_array[ $row['pid'] ] = $row['pid'];
|
||||
$t_cnt++;
|
||||
|
||||
if ( $t_cnt > $this->resultlimit )
|
||||
{
|
||||
$more = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
$topic_array[ $tid ] = $tid;
|
||||
}
|
||||
|
||||
$DB->free_result();
|
||||
//-----------------------------------------
|
||||
// PID: Get 'em
|
||||
//-----------------------------------------
|
||||
|
||||
$this->ipsclass->DB->query($posts_query);
|
||||
|
||||
while ($row = $this->ipsclass->DB->fetch_row() )
|
||||
{
|
||||
if( $row['queued'] )
|
||||
{
|
||||
if( !$this->ipsclass->member['g_is_supmod'] )
|
||||
{
|
||||
if( !in_array( $row['forum_id'], $my_invisible_forums_p ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !$row['approved'] )
|
||||
{
|
||||
if( !$this->ipsclass->member['g_is_supmod'] )
|
||||
{
|
||||
if( !in_array( $row['forum_id'], $my_invisible_forums_t ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$post_tmp[ $row['pid'] ] = $row['pid'];
|
||||
}
|
||||
|
||||
$this->ipsclass->DB->free_result();
|
||||
|
||||
//-----------------------------------------
|
||||
// PID Sort 'em
|
||||
//-----------------------------------------
|
||||
|
||||
krsort( $post_tmp );
|
||||
|
||||
foreach( $post_tmp as $id => $pid )
|
||||
{
|
||||
$p_cnt++;
|
||||
|
||||
if ( $p_cnt > $this->resultlimit )
|
||||
{
|
||||
$more = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
$post_array[ $pid ] = $pid;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
@@ -687,10 +851,17 @@ class search_lib extends Search
|
||||
|
||||
if ($topics == "" and $posts == "")
|
||||
{
|
||||
$this->output .= $this->is->html->search_error_page($ibforums->input['keywords']);
|
||||
$print->add_output( $this->output );
|
||||
$print->do_output( array( 'TITLE' => $ibforums->lang['g_simple_title'], 'JS' => 0, NAV => array( $ibforums->lang['g_simple_title'] ) ) );
|
||||
|
||||
if ( $this->is->xml_out )
|
||||
{
|
||||
print sprintf( $this->ipsclass->lang['xml_nomatches'], str_replace( '"', "", $keywords ) );
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->output .= $this->ipsclass->compiled_templates['skin_search']->search_error_page($this->ipsclass->input['keywords']);
|
||||
$this->ipsclass->print->add_output( $this->output );
|
||||
$this->ipsclass->print->do_output( array( 'TITLE' => $this->ipsclass->lang['g_simple_title'], 'JS' => 0, NAV => array( $this->ipsclass->lang['g_simple_title'] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -700,11 +871,12 @@ class search_lib extends Search
|
||||
//-----------------------------------------
|
||||
|
||||
return array(
|
||||
'topic_id' => $topics,
|
||||
'post_id' => $posts,
|
||||
'topic_max' => intval( count( $topic_array ) ),
|
||||
'post_max' => intval( count( $post_array ) ),
|
||||
'keywords' => str_replace( '"', "", $keywords ),
|
||||
'topic_id' => $topics,
|
||||
'post_id' => $posts,
|
||||
'topic_max' => intval( count( $topic_array ) ),
|
||||
'post_max' => intval( count( $post_array ) ),
|
||||
'keywords' => str_replace( '"', "", $keywords ),
|
||||
'query_cache' => $more,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user