Version 2.2.2

This commit is contained in:
Neo committed 2025-12-19 00:24:35 -08:00
1 parent 22f1b963ee
commit a3bb603c96
858 files changed
+479463 -188140

No files matched your search

+150 -51
View File
@@ -2,18 +2,26 @@
/*
+--------------------------------------------------------------------------
| Invision Power Board
| Invision Power Board 2.2.2
| =============================================
| by Matthew Mecham
| (c) 2001 - 2006 Invision Power Services, Inc.
| http://www.invisionpower.com
| =============================================
| Web: http://www.invisionboard.com
| http://www.ibresource.ru/products/invisionpowerboard/
| Time: Monday 05th of March 2007 10:10:54 PM
| Release: e3790216629e5a2aaf37070b32237f06
| Licence Info: http://www.invisionboard.com/?license
| http://www.ibresource.ru/license
+---------------------------------------------------------------------------
| > $Date: 2006-09-22 11:28:54 +0100 (Fri, 22 Sep 2006) $
| > $Revision: 567 $
| > $Author: matt $
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
| Ïðàâà íà ïåðåâîä IBResource (http://www.ibresource.ru)
+---------------------------------------------------------------------------
| > $Date: 2006-11-22 12:58:39 -0600 (Wed, 22 Nov 2006) $
| > $Revision: 739 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > MySQL FULL TEXT Search Library
@@ -24,9 +32,9 @@
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_IPB' ) )
if ( ! defined( 'IN_ACP' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
print "<h1>Íåâåðíûé âõîä</h1> Ó Âàñ íåò äîñòóïà ê äèðåêòèâå ýòîãî ôàéëà. Åñëè Âû ïðîâîäèëè îáíîâëåíèÿ, óáåäèòåñü, ÷òî íå çàáûëè îáíîâèòü 'admin.php'.";
exit();
}
@@ -37,6 +45,8 @@ class search_lib extends Search
var $is = "";
var $resultlimit = "";
var $class_attach;
//-----------------------------------------
// Constructor
//-----------------------------------------
@@ -81,7 +91,11 @@ class search_lib extends Search
if (strlen(trim($keywords)) < $this->ipsclass->vars['min_search_word'])
{
$this->ipsclass->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']) );
}
else if ( strlen(trim($keywords)) > 100 )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_long', 'EXTRA' => 100) );
}
//-----------------------------------------
@@ -171,11 +185,12 @@ class search_lib extends Search
//-----------------------------------------
$cache = "SELECT MATCH(post) AGAINST ('$check_keywords' $boolean) as score, t.approved, t.tid, t.posts as topic_posts, t.title as topic_title, t.views, t.forum_id,
p.post, p.author_id, p.author_name, p.post_date, p.queued, p.pid, p.post_htmlstate,m.*, me.*
p.post, p.author_id, p.author_name, p.post_date, p.queued, p.pid, p.post_htmlstate,m.*, me.*,pp.*
FROM ".SQL_PREFIX."posts p
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)
LEFT JOIN ".SQL_PREFIX."profile_portal pp on (pp.pp_member_id=p.author_id)
WHERE t.forum_id IN ($myforums) AND t.title IS NOT NULL {$topics_name} {$approved}
AND MATCH(post) AGAINST ('$check_keywords' $boolean)";
@@ -286,10 +301,11 @@ class search_lib extends Search
'keyword' => $check_keywords,
) );
$attach_pids = array();
while ( $row = $this->ipsclass->DB->fetch_row($outer) )
{
$attach_pids = array();
//-----------------------------------------
// Listen up, this is relevant.
// MySQL's relevance is a bit of a mystery. It's
@@ -310,14 +326,19 @@ class search_lib extends Search
if ( $row['author_id'] )
{
$row['author_name'] = "<a href='{$this->ipsclass->base_url}act=Profile&amp;MID={$row['author_id']}'>{$row['author_name']}</a>";
$row['author_name'] = "<a href='{$this->ipsclass->base_url}showuser={$row['author_id']}'>{$row['author_name']}</a>";
}
if ( $member['id'] )
{
$member['_members_display_name'] = "<a href='{$this->base_url}showuser={$member['id']}'>{$member['members_display_name_short']}</a>";
}
//-----------------------------------------
// Attachments?
//-----------------------------------------
if ( strstr( $row['post'], '[attachmentid=' ) )
if ( strstr( $row['post'], '[attachment=' ) )
{
$attach_pids[] = $row['pid'];
}
@@ -336,37 +357,44 @@ class search_lib extends Search
$row['post'] = $this->topics->parser->pre_display_parse( $row['post'] );
$keywords_array = explode( " ", str_replace( "+", " ", $this->ipsclass->input['highlite'] ) );
if ( count($keywords_array) )
if ( $this->ipsclass->input['highlite'] )
{
foreach( $keywords_array as $keys )
{
if ( $keys == "" )
{
continue;
}
while( preg_match( "/(^|\s|'|\"|>)(".preg_quote($keys, '/').")(\s|'|\"|,|\.|!|<br|$)/is", $row['post'] ) )
{
$row['post'] = preg_replace( "/(^|\s|'|\"|>)(".preg_quote($keys, '/').")(\s|'|\"|,|\.|!|<br|$)/is", "\\1<span class='searchlite'>\\2</span>\\3", $row['post'] );
}
}
$row['post'] = $this->ipsclass->content_search_highlight( $row['post'], $this->ipsclass->input['highlite'] );
}
$row['forum_name'] = $this->ipsclass->forums->forum_by_id[ $row['forum_id'] ]['name'];
$this->output .= $this->ipsclass->compiled_templates['skin_search']->RenderPostRow($row, $member);
}
//-----------------------------------------
// Add in attachments?
// Sucks we have to do this inside the loop
// however we have to check forum view perms
//-----------------------------------------
if ( count( $attach_pids ) )
{
$this->output = $this->topics->parse_attachments( $this->output, $attach_pids );
if ( ! is_object( $this->class_attach ) )
{
//-----------------------------------------
// Grab render attach class
//-----------------------------------------
require_once( ROOT_PATH . 'sources/classes/attach/class_attach.php' );
$this->class_attach = new class_attach();
$this->class_attach->ipsclass =& $this->ipsclass;
}
if ( $this->ipsclass->check_perms($this->ipsclass->forums->forum_by_id[ $row['forum_id'] ]['download_perms']) === FALSE )
{
$this->ipsclass->vars['show_img_upload'] = 0;
}
$this->class_attach->type = 'post';
$this->class_attach->init();
$this->output = $this->class_attach->render_attachments( $this->output, $attach_pids );
}
}
$this->output .= $this->ipsclass->compiled_templates['skin_search']->end_results_table(array( 'SHOW_PAGES' => $this->links ) , 1 );
@@ -379,8 +407,6 @@ class search_lib extends Search
}
//-----------------------------------------
// Main Board Search-e-me-doo-daa
//-----------------------------------------
@@ -491,6 +517,18 @@ class search_lib extends Search
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_short', 'EXTRA' => $this->ipsclass->vars['min_search_word']) );
}
}
else if ( strlen(trim($keywords)) > 100 )
{
if ( $this->is->xml_out )
{
print sprintf( $this->ipsclass->lang['xml_max_char'], 100 );
exit();
}
else
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_word_long', 'EXTRA' => 100) );
}
}
}
//-----------------------------------------
@@ -679,21 +717,63 @@ class search_lib extends Search
$unique_id = md5(uniqid(microtime(),1));
$t_forum_query = $this->ipsclass->member['g_is_supmod'] ? "t.forum_id IN ($forums)" :
( count($my_invisible_forums_t) ? "( (t.forum_id IN ($forums) AND t.approved=1) OR t.forum_id IN(" . implode( ",", $my_invisible_forums_t ) . ") )" :
"t.forum_id IN ($forums)" );
if( $this->ipsclass->member['g_is_supmod'] )
{
$p_forum_query = "t.forum_id IN ($forums)";
}
else if( count($my_invisible_forums_p) AND count($my_invisible_forums_t) )
{
$my_invisible_forums_both = array();
foreach( $my_invisible_forums_p as $p_fid )
{
if( in_array( $p_fid, $my_invisible_forums_t ) )
{
$my_invisible_forums_both[] = $p_fid;
}
}
$p_forum_query = "( (t.forum_id IN ($forums) AND t.approved=1 AND p.queued=0) OR
t.forum_id IN(" . implode( ",", $my_invisible_forums_both ) . ") OR
(t.forum_id IN(" . implode( ",", $my_invisible_forums_p ) . ") AND t.approved=1) OR
(t.forum_id IN(" . implode( ",", $my_invisible_forums_t ) . ") AND p.queued=0) )";
}
else if( count($my_invisible_forums_t) )
{
$p_forum_query = "( (t.forum_id IN ($forums) AND t.approved=1 AND p.queued=0) OR
(t.forum_id IN(" . implode( ",", $my_invisible_forums_t ) . ") AND p.queued=0) )";
}
else if( count($my_invisible_forums_p) )
{
$p_forum_query = "( (t.forum_id IN ($forums) AND t.approved=1 AND p.queued=0) OR
(t.forum_id IN(" . implode( ",", $my_invisible_forums_p ) . ") AND t.approved=1) )";
}
else
{
$p_forum_query = "(t.forum_id IN ($forums) AND t.approved=1 AND p.queued=0)";
}
if ($type != 'nameonly')
{
if ( ! $this->is->topic_search_only )
{
$topics_query = "SELECT t.tid, t.approved, t.forum_id
FROM ".SQL_PREFIX."topics t
WHERE $topics_datecut t.forum_id IN ($forums)
$topics_name AND MATCH(title) AGAINST ('".trim($keywords)."' $boolean)";
WHERE $topics_datecut $t_forum_query
$topics_name AND MATCH(title) AGAINST ('".trim($keywords)."' $boolean)
LIMIT {$this->resultlimit}";
$posts_query = "SELECT p.pid, p.queued, t.approved, t.forum_id
FROM ".SQL_PREFIX."posts p
LEFT JOIN ".SQL_PREFIX."topics t ON ( p.topic_id=t.tid )
WHERE $posts_datecut t.forum_id IN ($forums)
$posts_name AND MATCH(post) AGAINST ('".trim($keywords)."' $boolean)";
WHERE $posts_datecut $p_forum_query
$posts_name AND MATCH(post) AGAINST ('".trim($keywords)."' $boolean)
LIMIT {$this->resultlimit}";
}
else
{
@@ -706,8 +786,9 @@ class search_lib extends Search
LEFT JOIN ".SQL_PREFIX."topics t ON ( p.topic_id=t.tid )
WHERE
p.topic_id={$this->is->topic_id}
AND $posts_datecut t.forum_id IN ($forums)
$posts_name AND MATCH(post) AGAINST ('".trim($keywords)."' $boolean)";
AND $posts_datecut $p_forum_query
$posts_name AND MATCH(post) AGAINST ('".trim($keywords)."' $boolean)
LIMIT {$this->resultlimit}";
}
}
else
@@ -715,14 +796,16 @@ class search_lib extends Search
$topics_query = "SELECT t.tid, t.approved, t.forum_id
FROM ".SQL_PREFIX."topics t
WHERE $topics_datecut t.forum_id IN ($forums)
$topics_name";
WHERE $topics_datecut $t_forum_query
$topics_name
LIMIT {$this->resultlimit}";
$posts_query = "SELECT p.pid, p.queued, t.approved, t.forum_id
FROM ".SQL_PREFIX."posts p
LEFT JOIN ".SQL_PREFIX."topics t ON ( p.topic_id=t.tid )
WHERE $posts_datecut t.forum_id IN ($forums)
$posts_name";
WHERE $posts_datecut $p_forum_query
$posts_name
LIMIT {$this->resultlimit}";
}
//print $topics_query."<br />".$posts_query; exit();
//-----------------------------------------
@@ -748,9 +831,11 @@ class search_lib extends Search
{
$this->ipsclass->DB->query($topics_query);
$total_t = $this->ipsclass->DB->get_num_rows();
while ($row = $this->ipsclass->DB->fetch_row() )
{
if( !$row['approved'] )
/*if( !$row['approved'] )
{
if( !$this->ipsclass->member['g_is_supmod'] )
{
@@ -759,19 +844,25 @@ class search_lib extends Search
continue;
}
}
}
}*/
$topic_tmp[ $row['tid'] ] = $row['tid'];
//$topic_tmp[ $row['tid'] ] = $row['tid'];
$topic_array[ $row['tid'] ] = $row['tid'];
}
$this->ipsclass->DB->free_result();
}
if( $total_t == $this->resultlimit )
{
$more = 1;
}
//-----------------------------------------
// TID Sort 'em
//-----------------------------------------
krsort( $topic_tmp );
/*krsort( $topic_tmp );
foreach( $topic_tmp as $id => $tid )
{
@@ -784,7 +875,7 @@ class search_lib extends Search
}
$topic_array[ $tid ] = $tid;
}
}*/
//-----------------------------------------
// PID: Get 'em
@@ -792,9 +883,11 @@ class search_lib extends Search
$this->ipsclass->DB->query($posts_query);
$total_p = $this->ipsclass->DB->get_num_rows();
while ($row = $this->ipsclass->DB->fetch_row() )
{
if( $row['queued'] )
/*if( $row['queued'] )
{
if( !$this->ipsclass->member['g_is_supmod'] )
{
@@ -814,18 +907,24 @@ class search_lib extends Search
continue;
}
}
}
}*/
$post_tmp[ $row['pid'] ] = $row['pid'];
//$post_tmp[ $row['pid'] ] = $row['pid'];
$post_array[ $row['pid'] ] = $row['pid'];
}
$this->ipsclass->DB->free_result();
if( $total_p == $this->resultlimit )
{
$more = 1;
}
//-----------------------------------------
// PID Sort 'em
//-----------------------------------------
krsort( $post_tmp );
/*krsort( $post_tmp );
foreach( $post_tmp as $id => $pid )
{
@@ -838,7 +937,7 @@ class search_lib extends Search
}
$post_array[ $pid ] = $pid;
}
}*/
//-----------------------------------------