Version 2.1.7

This commit is contained in:
Neo committed 2025-12-19 00:21:15 -08:00
1 parent 0eecc172d9
commit f73f8bff6d
941 files changed
+215301 -103093

No files matched your search

+183 -67
View File
@@ -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 Manual Search Library
@@ -27,16 +39,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;
}
//-----------------------------------------
@@ -46,38 +58,36 @@ class search_lib extends Search
function do_main_search()
{
global $ibforums, $DB, $std, $HTTP_POST_VARS, $print;
//-----------------------------------------
// Do we have any input?
//-----------------------------------------
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';
}
@@ -92,13 +102,13 @@ class search_lib extends Search
{
if ($type != 'nameonly')
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_words') );
}
}
//-----------------------------------------
if ($ibforums->input['search_in'] == 'titles')
if ($this->ipsclass->input['search_in'] == 'titles')
{
$this->is->search_in = 'titles';
}
@@ -113,14 +123,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;
}
@@ -130,7 +140,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;
}
@@ -138,21 +148,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;
}
//-----------------------------------------
@@ -161,40 +171,51 @@ 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);
$topics_datecut = "t.last_post $gt_lt $time AND";
$posts_datecut = "p.post_date $gt_lt $time AND";
}
// Is this a membername search?
$name_filter = trim( $name_filter );
$member_string = "";
if ( $name_filter != "" )
{
//-----------------------------------------
// 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 = "";
if ( $name_filter != "" )
{
//-----------------------------------------
// Get all the possible matches for the supplied name from the DB
//-----------------------------------------
$name_filter = str_replace( '|', "&#124;", $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']."',";
}
@@ -205,7 +226,7 @@ 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)";
@@ -228,9 +249,9 @@ class search_lib extends Search
$boolean = $matches[1][$i];
$word = trim($matches[2][$i]);
if (strlen($word) < $ibforums->vars['min_search_word'])
if (strlen($word) < $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']) );
}
if ($boolean)
@@ -248,10 +269,9 @@ class search_lib extends Search
}
else
{
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']) );
}
$title_like = " LOWER(t.title) LIKE '%".trim($keywords)."%' ";
@@ -265,32 +285,41 @@ class search_lib extends Search
if ($type != 'nameonly')
{
$topics_query = "SELECT t.tid
if( $this->is->topic_search_only == 1 )
{
$topic_filter = " t.tid={$this->is->topic_id} AND ";
}
else
{
$topic_filter = "";
}
$topics_query = "SELECT t.tid, t.approved, t.forum_id
FROM ibf_topics t
WHERE $topics_datecut t.forum_id IN ($forums)
WHERE {$topic_filter}{$topics_datecut} t.forum_id IN ($forums)
$topics_name AND t.approved=1 AND ($title_like)";
$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 (t.tid=p.topic_id)
WHERE $posts_datecut t.forum_id IN ($forums)
AND p.queued <> 1
WHERE {$topic_filter}{$posts_datecut} t.forum_id IN ($forums)
AND p.queued=0
$posts_name AND ($post_like)";
}
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";
$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 (t.tid=p.topic_id)
WHERE $posts_datecut t.forum_id IN ($forums)
AND p.queued <> 1
AND p.queued=0
$posts_name";
}
@@ -301,32 +330,118 @@ class search_lib extends Search
$topics = "";
$posts = "";
$t_cnt = 0;
$p_cnt = 0;
$more = "";
//-----------------------------------------
$DB->query($topics_query);
$topic_max_hits = $DB->get_num_rows();
$my_invisible_forums_t = array();
$my_invisible_forums_p = array();
while ($row = $DB->fetch_row() )
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'];
}
}
}
$this->ipsclass->DB->query($topics_query);
$topic_max_hits = $this->ipsclass->DB->get_num_rows();
while ($row = $this->ipsclass->DB->fetch_row() )
{
if( !$row['approved'] )
{
if( !$this->ipsclass->member['g_is_supmod'] )
{
if( !in_array( $row['forum_id'], $my_invisible_forums_t ) )
{
$topic_max_hits--;
continue;
}
}
}
$t_cnt++;
if ( $t_cnt > $this->resultlimit )
{
$more = 1;
break;
}
$topics .= $row['tid'].",";
}
$DB->free_result();
$this->ipsclass->DB->free_result();
//-----------------------------------------
$DB->query($posts_query);
$this->ipsclass->DB->query($posts_query);
$post_max_hits = $DB->get_num_rows();
while ($row = $DB->fetch_row() )
$post_max_hits = $this->ipsclass->DB->get_num_rows();
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 ) )
{
$post_max_hits--;
continue;
}
}
}
if( !$row['approved'] )
{
if( !$this->ipsclass->member['g_is_supmod'] )
{
if( !in_array( $row['forum_id'], $my_invisible_forums_t ) )
{
$post_max_hits--;
continue;
}
}
}
$p_cnt++;
if ( $p_cnt > $this->resultlimit )
{
$more = 1;
break;
}
$posts .= $row['pid'].",";
}
$DB->free_result();
$this->ipsclass->DB->free_result();
//-----------------------------------------
@@ -339,7 +454,7 @@ class search_lib extends Search
if ($topics == "" and $posts == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
//$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );
}
//-----------------------------------------
@@ -354,6 +469,7 @@ class search_lib extends Search
'topic_max' => $topic_max_hits,
'post_max' => $post_max_hits,
'keywords' => $keywords,
'query_cache' => $more,
);
}