Version 3.1.4

This commit is contained in:
Neo committed 2025-12-19 00:32:22 -08:00
1 parent 1d4720f3e2
commit ae5c01cc78
2563 files changed
+283048 -240689

No files matched your search

@@ -0,0 +1,35 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Config file
* Last Updated: $Date: 2010-02-19 01:29:54 +0000 (Fri, 19 Feb 2010) $
* </pre>
*
* @author $author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
* @version $Rev: 5855 $
**/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
/* Can search with this app */
$CONFIG['can_search'] = 1;
/* Can view new content with this app */
$CONFIG['can_viewNewContent'] = 1;
/* Can fetch active content with this app */
$CONFIG['can_activeContent'] = 1;
/* Can fetch user generated content */
$CONFIG['can_userContent'] = 1;
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>
@@ -0,0 +1,732 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Basic Forum Search
* Last Updated: $Date: 2010-02-23 12:38:11 +0000 (Tue, 23 Feb 2010) $
* </pre>
*
* @author $Author: matt $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
* @version $Rev: 5861 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class search_engine_forums extends search_engine
{
/**
* Constructor
*
* @return void
*/
public function __construct( ipsRegistry $registry )
{
/* Hard limit */
IPSSearchRegistry::set('set.hardLimit', ( ipsRegistry::$settings['search_hardlimit'] ) ? ipsRegistry::$settings['search_hardlimit'] : 200 );
/* Get class forums, used for displaying forum names on results */
if ( ipsRegistry::isClassLoaded('class_forums') !== TRUE )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums' );
ipsRegistry::setClass( 'class_forums', new $classToLoad( ipsRegistry::instance() ) );
ipsRegistry::getClass('class_forums')->forumsInit();
}
parent::__construct( $registry );
}
/**
* Perform a search.
* Returns an array of a total count (total number of matches)
* and an array of IDs ( 0 => 1203, 1 => 928, 2 => 2938 ).. matching the required number based on pagination. The ids returned would be based on the filters and type of search
*
* So if we had 1000 replies, and we are on page 2 of 25 per page, we'd return 25 items offset by 25
*
* @return array
*/
public function search()
{
$start = intval( IPSSearchRegistry::get('in.start') );
$perPage = IPSSearchRegistry::get('opt.search_per_page');
$sort_by = IPSSearchRegistry::get('in.search_sort_by');
$sort_order = IPSSearchRegistry::get('in.search_sort_order');
$search_term = IPSSearchRegistry::get('in.clean_search_term');
$content_title_only = IPSSearchRegistry::get('opt.searchTitleOnly');
$post_search_only = IPSSearchRegistry::get('opt.onlySearchPosts');
$search_ids = array();
$groupby = false;
$cType = IPSSearchRegistry::get('contextual.type');
$cId = IPSSearchRegistry::get('contextual.id' );
/* Contextual search */
if ( $cType == 'topic' )
{
$content_title_only = false;
$post_search_only = true;
IPSSearchRegistry::set('opt.searchTitleOnly', false);
IPSSearchRegistry::set('opt.onlySearchPosts', true);
IPSSearchRegistry::set('display.onlyTitles', false);
IPSSearchRegistry::set('opt.noPostPreview', false);
}
/* Permissions */
$permissions['TopicSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedTopics( 0 );
$permissions['canQueue'] = $this->registry->getClass('class_forums')->canQueuePosts( 0 );
$permissions['PostSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedPosts( 0 );
$permissions['SoftDeleteReason'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteReason( 0 );
$permissions['SoftDeleteContent'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteContent( 0 );
/* Sorting */
switch( $sort_by )
{
default:
case 'date':
$sortKey = 'last_post';
$sortKeyPost = 'post_date';
break;
case 'title':
$sortKeyPost = $sortKey = 'tordinal';
break;
case 'posts':
$sortKeyPost = $sortKey = 'posts';
break;
case 'views':
$sortKeyPost = $sortKey = 'views';
break;
}
/* Limit Results */
$this->sphinxClient->SetLimits( intval($start), intval($perPage) );
/* Loop through the forums and build a list of forums we're allowed access to */
$forumIdsOk = array();
$forumIdsBad = array();
if ( ! empty( ipsRegistry::$request['search_app_filters']['forums']['forums'] ) AND count( ipsRegistry::$request['search_app_filters']['forums']['forums'] ) )
{
foreach( ipsRegistry::$request['search_app_filters']['forums']['forums'] as $forum_id )
{
if( $forum_id )
{
$data = $this->registry->class_forums->forum_by_id[ $forum_id ];
/* Check for sub forums */
$children = ipsRegistry::getClass( 'class_forums' )->forumsGetChildren( $forum_id );
foreach( $children as $kid )
{
if( ! in_array( $kid, ipsRegistry::$request['search_app_filters']['forums']['forums'] ) )
{
if( ! $this->registry->permissions->check( 'read', $this->registry->class_forums->forum_by_id[ $kid ] ) )
{
$forumIdsBad[] = $kid;
continue;
}
/* Can read, but is it password protected, etc? */
if ( ! $this->registry->class_forums->forumsCheckAccess( $kid, 0, 'forum', array(), true ) )
{
$forumIdsBad[] = $kid;
continue;
}
if ( ! $this->registry->class_forums->forum_by_id[ $kid ]['sub_can_post'] OR ! $this->registry->class_forums->forum_by_id[ $kid ]['can_view_others'] )
{
$forumIdsBad[] = $kid;
continue;
}
$forumIdsOk[] = $kid;
}
}
/* Can we read? */
if ( ! $this->registry->permissions->check( 'view', $data ) )
{
$forumIdsBad[] = $forum_id;
continue;
}
/* Can read, but is it password protected, etc? */
if ( ! $this->registry->class_forums->forumsCheckAccess( $forum_id, 0, 'forum', array(), true ) )
{
$forumIdsBad[] = $forum_id;
continue;
}
if ( ! $data['sub_can_post'] OR ! $data['can_view_others'] AND !$this->memberData['g_access_cp'] )
{
$forumIdsBad[] = $forum_id;
continue;
}
$forumIdsOk[] = $forum_id;
}
}
}
if ( ! count($forumIdsOk) )
{
$allowTrashCan = ( $cType == 'forum' ) ? true : false;
/* Get list of good forum IDs */
$forumIdsOk = $this->registry->class_forums->fetchSearchableForumIds( null, array(), $allowTrashCan );
}
/* Add allowed forums */
$forumIdsOk = ( count( $forumIdsOk ) ) ? $forumIdsOk : array( 0 => 0 );
/* Contextual */
if ( $cType == 'forum' AND $cId AND in_array( $cId, $forumIdsOk ) )
{
$this->sphinxClient->SetFilter( 'forum_id', array( $cId ) );
}
else
{
$this->sphinxClient->SetFilter( 'forum_id', $forumIdsOk );
}
/* Topic contextual */
if ( $cType == 'topic' AND $cId )
{
$this->sphinxClient->SetFilter( 'tid', array( $cId ) );
}
/* Exclude some items */
if ( ! $content_title_only )
{
if ( $permissions['SoftDeleteContent'] AND $permissions['PostSoftDeleteSee'] AND $permissions['canQueue'] )
{
$this->sphinxClient->SetFilter( 'queued', array( 0,1,2 ) );
}
else if ( $permissions['SoftDeleteContent'] AND $permissions['PostSoftDeleteSee'] )
{
$this->sphinxClient->SetFilter( 'queued', array( 0,2 ) );
}
else if ( $permissions['canQueue'] )
{
$this->sphinxClient->SetFilter( 'queued', array( 0,1 ) );
}
else
{
$this->sphinxClient->SetFilter( 'queued', array( 0 ) );
}
}
if ( $permissions['SoftDeleteContent'] AND $permissions['TopicSoftDeleteSee'] AND $permissions['canQueue'] )
{
$this->sphinxClient->SetFilter( 'approved' , array( 0,1 ) );
$this->sphinxClient->SetFilter( 'soft_deleted', array( 0,1 ) );
}
else if ( $permissions['SoftDeleteContent'] AND $permissions['TopicSoftDeleteSee'] )
{
$this->sphinxClient->SetFilter( 'approved', array( 1 ) );
$this->sphinxClient->SetFilter( 'soft_deleted', array( 0,1 ) );
}
else if ( $permissions['canQueue'] )
{
$this->sphinxClient->SetFilter( 'soft_deleted', array( 0 ) );
$this->sphinxClient->SetFilter( 'approved', array( 0,1 ) );
}
else
{
$this->sphinxClient->SetFilter( 'soft_deleted', array( 0 ) );
$this->sphinxClient->SetFilter( 'approved', array( 1 ) );
}
/* Additional filters */
if ( IPSSearchRegistry::get('opt.pCount') )
{
$this->sphinxClient->SetFilterRange( 'posts', intval( IPSSearchRegistry::get('opt.pCount') ), 1500000000 );
}
if ( IPSSearchRegistry::get('opt.pViews') )
{
$this->sphinxClient->SetFilterRange( 'views', intval( IPSSearchRegistry::get('opt.pViews') ), 1500000000 );
}
/* Date limit */
if ( $this->search_begin_timestamp )
{
if ( ! $this->search_end_timestamp )
{
$this->search_end_timestamp = time() + 100;
}
if ( $content_title_only )
{
$this->sphinxClient->SetFilterRange( 'start_date', $this->search_begin_timestamp, $this->search_end_timestamp );
}
else
{
$this->sphinxClient->SetFilterRange( 'post_date', $this->search_begin_timestamp, $this->search_end_timestamp );
}
}
if ( IPSSearchRegistry::get('opt.noPostPreview') OR IPSSearchRegistry::get('display.onlyTitles') )
{
$groupby = true;
}
if ( $content_title_only )
{
if ( $sort_order == 'asc' )
{
$this->sphinxClient->SetSortMode( SPH_SORT_ATTR_ASC, $sortKey );
}
else
{
$this->sphinxClient->SetSortMode( SPH_SORT_ATTR_DESC, $sortKey );
}
if ( $groupby )
{
$this->sphinxClient->SetGroupBy( 'last_post_group', SPH_GROUPBY_ATTR, '@group ' . $sort_order );
}
$_s = ( $search_term ) ? '@title ' . $search_term : '';
$result = $this->sphinxClient->Query( $_s, 'forums_search_posts_main,forums_search_posts_delta' );
$this->logSphinxWarnings();
}
else
{
if ( $groupby )
{
$this->sphinxClient->SetGroupBy( 'last_post_group', SPH_GROUPBY_ATTR, '@group DESC');
}
if ( $sort_order == 'asc' )
{
$this->sphinxClient->SetSortMode( SPH_SORT_ATTR_ASC, $sortKeyPost );
}
else
{
$this->sphinxClient->SetSortMode( SPH_SORT_ATTR_DESC, $sortKeyPost );
}
if ( $post_search_only )
{
$_s = ( $search_term ) ? '@post ' . $search_term : '';
$result = $this->sphinxClient->Query( $_s, 'forums_search_posts_main,forums_search_posts_delta' );
}
else
{
$_s = ( $search_term AND strstr( $search_term, '"' ) ) ? '@post ' . $search_term . ' | @title ' . $search_term : ( $search_term ? '@(post,title) ' . $search_term : '' );
$result = $this->sphinxClient->Query( $_s, 'forums_search_posts_main,forums_search_posts_delta' );
}
$this->logSphinxWarnings();
}
if ( is_array( $result['matches'] ) && count( $result['matches'] ) )
{
foreach( $result['matches'] as $res )
{
$search_ids[] = ( $content_title_only ) ? $res['attrs']['tid'] : $res['attrs']['search_id'];
}
}
/* Return it */
return array( 'count' => intval( $result['total_found'] ) > 1000 ? 1000 : $result['total_found'], 'resultSet' => $search_ids );
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @return array
*/
public function viewUserContent( $member )
{
/* Ensure we limit by date */
$this->settings['search_ucontent_days'] = ( $this->settings['search_ucontent_days'] ) ? $this->settings['search_ucontent_days'] : 365;
/* Bit of init */
$time = time() - ( 86400 * intval( $this->settings['search_ucontent_days'] ) );
switch( IPSSearchRegistry::get('in.userMode') )
{
default:
case 'all':
IPSSearchRegistry::set('opt.searchTitleOnly', false );
IPSSearchRegistry::set('display.onlyTitles' , true );
IPSSearchRegistry::set('opt.noPostPreview' , false );
break;
case 'title':
IPSSearchRegistry::set('opt.searchTitleOnly', true );
IPSSearchRegistry::set('display.onlyTitles' , true );
IPSSearchRegistry::set('opt.noPostPreview' , false );
break;
case 'content':
IPSSearchRegistry::set('opt.searchTitleOnly', false );
IPSSearchRegistry::set('display.onlyTitles' , false );
IPSSearchRegistry::set('opt.noPostPreview' , false );
break;
}
/* Init */
$start = IPSSearchRegistry::get('in.start');
$perPage = IPSSearchRegistry::get('opt.search_per_page');
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
/* Limit Results */
$this->sphinxClient->SetLimits( intval($start), intval($perPage) );
/* Get list of good forum IDs */
$forumIdsOk = $this->registry->class_forums->fetchSearchableForumIds( $this->memberData['member_id'] );
$this->sphinxClient->SetFilter( 'forum_id', $forumIdsOk );
/* what we doing? */
if ( IPSSearchRegistry::get('in.userMode') != 'title' )
{
$this->sphinxClient->SetFilter( 'author_id', array( intval( $member['member_id'] ) ) );
}
else
{
$this->sphinxClient->SetFilter( 'starter_id', array( intval( $member['member_id'] ) ) );
}
if ( $this->settings['search_ucontent_days'] )
{
$this->sphinxClient->SetFilterRange( 'post_date', $time, time() );
}
/* Set up perms */
$permissions['TopicSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedTopics( 0 );
$permissions['canQueue'] = $this->registry->getClass('class_forums')->canQueuePosts( 0 );
$permissions['PostSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedPosts( 0 );
$permissions['SoftDeleteReason'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteReason( 0 );
$permissions['SoftDeleteContent'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteContent( 0 );
/* Exclude some items */
if ( IPSSearchRegistry::get('in.userMode') != 'title' )
{
if ( $permissions['SoftDeleteContent'] AND $permissions['PostSoftDeleteSee'] AND $permissions['canQueue'] )
{
$this->sphinxClient->SetFilter( 'queued', array( 0,1,2 ) );
}
else if ( $permissions['SoftDeleteContent'] AND $permissions['PostSoftDeleteSee'] )
{
$this->sphinxClient->SetFilter( 'queued', array( 0,2 ) );
}
else if ( $permissions['canQueue'] )
{
$this->sphinxClient->SetFilter( 'queued', array( 0,1 ) );
}
else
{
$this->sphinxClient->SetFilter( 'queued', array( 0 ) );
}
}
else
{
if ( $permissions['SoftDeleteContent'] AND $permissions['TopicSoftDeleteSee'] AND $permissions['canQueue'] )
{
$this->sphinxClient->SetFilter( 'approved' , array( 0,1 ) );
$this->sphinxClient->SetFilter( 'soft_deleted', array( 0,1 ) );
}
else if ( $permissions['SoftDeleteContent'] AND $permissions['TopicSoftDeleteSee'] )
{
$this->sphinxClient->SetFilter( 'approved', array( 0 ) );
$this->sphinxClient->SetFilter( 'soft_deleted', array( 0,1 ) );
}
else if ( $permissions['canQueue'] )
{
$this->sphinxClient->SetFilter( 'soft_deleted', array( 0 ) );
$this->sphinxClient->SetFilter( 'approved', array( 0,1 ) );
}
else
{
$this->sphinxClient->SetFilter( 'soft_deleted', array( 0 ) );
$this->sphinxClient->SetFilter( 'approved', array( 1 ) );
}
}
if ( IPSSearchRegistry::get('in.userMode') == 'title' )
{
$this->sphinxClient->SetGroupDistinct ( "tid" );
$this->sphinxClient->SetGroupBy( 'tid', SPH_GROUPBY_ATTR, '@group DESC' );
$this->sphinxClient->SetSortMode( SPH_SORT_ATTR_DESC, 'last_post' );
$result = $this->sphinxClient->Query( '', 'forums_search_posts_main,forums_search_posts_delta' );
$this->logSphinxWarnings();
}
else
{
if ( IPSSearchRegistry::get('in.userMode') == 'content' )
{
$this->sphinxClient->SetSortMode( SPH_SORT_ATTR_DESC, 'post_date' );
}
else
{
$this->sphinxClient->SetSortMode( SPH_SORT_ATTR_DESC, 'post_date' );
$this->sphinxClient->SetGroupBy( 'last_post_group', SPH_GROUPBY_ATTR, '@group desc' );
}
$result = $this->sphinxClient->Query( '', 'forums_search_posts_main,forums_search_posts_delta' );
$this->logSphinxWarnings();
}
if ( is_array( $result['matches'] ) && count( $result['matches'] ) )
{
foreach( $result['matches'] as $res )
{
$search_ids[] = ( IPSSearchRegistry::get('opt.searchTitleOnly') ) ? $res['attrs']['tid'] : $res['attrs']['search_id'];
}
}
return array( 'count' => intval( $result['total_found'] ) > 1000 ? 1000 : $result['total_found'], 'resultSet' => $search_ids );
}
/**
* Perform the viewNewContent search
* Forum Version
* Populates $this->_count and $this->_results
*
* @return array
*/
public function viewNewContent()
{
$tids = $this->registry->getClass('classItemMarking')->fetchCookieData( 'forums', 'items' );
$oldStamp = $this->registry->getClass('classItemMarking')->fetchOldestUnreadTimestamp( array(), 'forums' );
$check = IPS_UNIX_TIME_NOW - ( 86400 * 90 );
$forumIdsOk = array();
/* Loop through the forums and build a list of forums we're allowed access to */
$bvnp = explode( ',', $this->settings['vnp_block_forums'] );
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
IPSSearchRegistry::set('opt.searchTitleOnly' , true );
IPSSearchRegistry::set('display.onlyTitles' , true );
IPSSearchRegistry::set('opt.noPostPreview' , true );
/* Get list of good forum IDs */
$_forumIdsOk = $this->registry->class_forums->fetchSearchableForumIds( $this->memberData['member_id'], $bvnp );
if ( ! $this->memberData['bw_vnc_type'] )
{
$oldStamp = IPSLib::fetchHighestNumber( array( intval( $this->memberData['_cache']['gb_mark__forums'] ), intval( $this->memberData['last_visit'] ) ) );
$tids = array();
$forumIdsOk = $_forumIdsOk;
}
else
{
foreach( $_forumIdsOk as $id )
{
$lMarked = $this->registry->getClass('classItemMarking')->fetchTimeLastMarked( array( 'forumID' => $id ), 'forums' );
$fData = $this->registry->getClass('class_forums')->forumsFetchData( $id );
if ( $fData['last_post'] > $lMarked )
{
/* Add to tids */
$_tids = $this->registry->getClass('classItemMarking')->fetchReadIds( array( 'forumID' => $id ), 'forums', false );
if ( is_array( $_tids ) )
{
foreach( $_tids as $k => $v )
{
$tids[ $k ] = $v;
}
}
$forumIdsOk[ $id ] = $id;
}
}
if ( intval( $this->memberData['_cache']['gb_mark__forums'] ) > 0 )
{
$oldStamp = $this->memberData['_cache']['gb_mark__forums'];
}
/* Finalize times */
if ( ! $oldStamp OR $oldStamp == IPS_UNIX_TIME_NOW )
{
$oldStamp = intval( $this->memberData['last_visit'] );
}
/* Older than 3 months.. then limit */
if ( $oldStamp < $check )
{
$oldStamp = $check;
}
/* If no forums, we're done */
if ( ! count( $forumIdsOk ) )
{
/* Return it */
return array( 'count' => 0, 'resultSet' => array() );
}
}
/* Set the timestamps */
$this->sphinxClient->SetFilterRange( 'last_post', $oldStamp, time() );
$this->setDateRange( 0, 0 );
/* Force it into filter so that search can pick it up */
ipsRegistry::$request['search_app_filters']['forums']['forums'] = $forumIdsOk;
/* Try and limit the TIDS */
if ( is_array( $tids ) AND count( $tids ) )
{
if ( count( $tids ) > 300 )
{
/* Sort by last read date */
arsort( $tids, SORT_NUMERIC );
$tids = array_slice( $tids, 0, 300 );
}
$this->DB->build( array( 'select' => 'tid, last_post',
'from' => 'topics',
'where' => "tid IN (" . implode( ",", array_keys( $tids ) ) . ')' ) );
$this->DB->execute();
while( $row = $this->DB->fetch() )
{
/* Posted in since last read? */
if ( $row['last_post'] > $tids[ $row['tid'] ] )
{
unset( $tids[ $row['tid'] ] );
}
}
if ( count( $tids ) )
{
$tids = array_keys( $tids );
}
}
/* Set read tids */
if ( count( $tids ) )
{
$this->sphinxClient->SetFilter( 'tid', $tids, TRUE );
}
/* Set up some vars */
IPSSearchRegistry::set('set.resultCutToDate', $oldStamp );
return $this->search();
}
/**
* Perform the search
* Populates $this->_count and $this->_results
*
* @return array
*/
public function viewActiveContent()
{
$seconds = IPSSearchRegistry::get('in.period_in_seconds');
/* Loop through the forums and build a list of forums we're allowed access to */
$bvnp = explode( ',', $this->settings['vnp_block_forums'] );
IPSSearchRegistry::set('in.search_sort_by' , 'date' );
IPSSearchRegistry::set('in.search_sort_order', 'desc' );
IPSSearchRegistry::set('opt.searchTitleOnly' , true );
IPSSearchRegistry::set('display.onlyTitles' , true );
IPSSearchRegistry::set('opt.noPostPreview' , true );
/* Get list of good forum IDs */
$forumIdsOk = $this->registry->class_forums->fetchSearchableForumIds( $this->memberData['member_id'], $bvnp );
/* Force it into filter so that search can pick it up */
ipsRegistry::$request['search_app_filters']['forums']['forums'] = $forumIdsOk;
/* Set the timestamps */
$this->sphinxClient->SetFilterRange( 'last_post', intval( time() - $seconds ), time() );
$this->setDateRange( 0, 0 );
return $this->search();
}
/**
* Remap standard columns (Apps can override )
*
* @param string $column sql table column for this condition
* @return string column
* @return void
*/
public function remapColumn( $column )
{
$column = $column == 'member_id' ? ( IPSSearchRegistry::get('opt.searchTitleOnly') ? 'starter_id' : 'author_id' ) : $column;
$column = $column == 'content_title' ? 'title' : $column;
$column = $column == 'type_id' ? 'forum_id' : $column;
return $column;
}
/**
* Returns an array used in the searchplugin's setCondition method
*
* @param array $data Array of forums to view
* @return array Array with column, operator, and value keys, for use in the setCondition call
*/
public function buildFilterSQL( $data )
{
/* INIT */
$return = array();
/* Set up some defaults */
IPSSearchRegistry::set( 'opt.noPostPreview' , true );
IPSSearchRegistry::set( 'opt.onlySearchPosts', false );
if( isset( $data ) && is_array( $data ) && count( $data ) )
{
foreach( $data as $field => $_data )
{
/* CONTENT ONLY */
if ( $field == 'noPreview' AND $_data['noPreview'] == 0 )
{
IPSSearchRegistry::set( 'opt.noPostPreview', false );
}
/* CONTENT ONLY */
if ( $field == 'contentOnly' AND $_data['contentOnly'] == 1 )
{
IPSSearchRegistry::set( 'opt.onlySearchPosts', true );
}
/* POST COUNT */
if ( $field == 'pCount' AND intval( $_data['pCount'] ) > 0 )
{
IPSSearchRegistry::set( 'opt.pCount', intval( $_data['pCount'] ) );
}
/* TOPIC VIEWS */
if ( $field == 'pViews' AND intval( $_data ) > 0 )
{
IPSSearchRegistry::set( 'opt.pViews', intval( $_data['pViews'] ) );
}
}
return $return;
}
else
{
return '';
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,80 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Returns HTML for the form (optional class, not required)
* Last Updated: $Date: 2010-02-19 01:29:54 +0000 (Fri, 19 Feb 2010) $
* </pre>
*
* @author $author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
* @version $Rev: 5855 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class search_form_forums
{
/**
* Construct
*
* @return void
*/
public function __construct()
{
/* Make object */
$this->registry = ipsRegistry::instance();
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->lang = $this->registry->getClass('class_localization');
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
}
/**
* Return sort drop down
*
* @return array
*/
public function fetchSortDropDown()
{
$array = array( 'date' => $this->lang->words['s_search_type_0'],
'title' => $this->lang->words['forum_sort_title'],
'posts' => $this->lang->words['forum_sort_posts'],
'views' => $this->lang->words['forum_sort_views'] );
return $array;
}
/**
* Retuns the html for displaying the forum category filter on the advanced search page
*
* @return string Filter HTML
*/
public function getHtml()
{
/* Make sure class_forums is setup */
if( ipsRegistry::isClassLoaded('class_forums') !== TRUE )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums' );
ipsRegistry::setClass( 'class_forums', new $classToLoad( ipsRegistry::instance() ) );
}
ipsRegistry::getClass('class_forums')->strip_invisible = 1;
ipsRegistry::getClass('class_forums')->forumsInit();
return array( 'title' => ipsRegistry::$applications['forums']['app_public_title'], 'html' => ipsRegistry::getClass( 'output' )->getTemplate( 'search' )->forumAdvancedSearchFilters( ipsRegistry::getClass( 'class_forums' )->buildForumJump( 0, 1 ) ) );
}
}
@@ -0,0 +1,563 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* Formats forum search results
* Last Updated: $Date: 2010-02-19 01:29:54 +0000 (Fri, 19 Feb 2010) $
* </pre>
*
* @author $author$
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
* @version $Rev: 5855 $
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class search_format_forums extends search_format
{
/**
* Constructor
*
* @return void
*/
public function __construct( ipsRegistry $registry )
{
/* Get class forums, used for displaying forum names on results */
if ( ipsRegistry::isClassLoaded('class_forums') !== TRUE )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums' );
ipsRegistry::setClass( 'class_forums', new $classToLoad( ipsRegistry::instance() ) );
ipsRegistry::getClass('class_forums')->forumsInit();
}
parent::__construct( $registry );
/* Set up wrapper */
$this->templates = array( 'group' => 'search', 'template' => 'searchResultsAsForum' );
}
/**
* Parse search results
*
* @param array $r Search result
* @return array $html Blocks of HTML
*/
public function parseAndFetchHtmlBlocks( $rows )
{
/* Forum stuff */
$sub = false;
$isVnc = false;
$search_term = IPSSearchRegistry::get('in.clean_search_term');
$onlyPosts = IPSSearchRegistry::get('opt.onlySearchPosts');
$onlyTitles = IPSSearchRegistry::get('display.onlyTitles');
$noPostPreview = IPSSearchRegistry::get('opt.noPostPreview');
$results = array();
$attachPids = array();
$results = array();
/* loop and process */
foreach( $rows as $id => $data )
{
/* Reset */
$pages = 0;
/* Set up forum */
$forum = $this->registry->getClass('class_forums')->forum_by_id[ $data['forum_id'] ];
$this->last_topic = $data['tid'];
/* Various data */
$data['_last_post'] = $data['last_post'];
$data['_longTitle'] = $data['content_title'];
$data['_shortTitle'] = IPSText::truncate( $data['content_title'], 60 );
$data['last_poster'] = $data['last_poster_id'] ? IPSLib::makeProfileLink( $data['last_poster_name'], $data['last_poster_id'], $data['seo_last_name'] ) : $this->settings['guest_name_pre'] . $data['last_poster_name'] . $this->settings['guest_name_suf'];
$data['starter'] = $data['starter_id'] ? IPSLib::makeProfileLink( $data['starter_name'], $data['starter_id'], $data['seo_first_name'] ) : $this->settings['guest_name_pre'] . $data['starter_name'] . $this->settings['guest_name_suf'];
$data['last_post'] = $this->registry->getClass( 'class_localization')->getDate( $data['last_post'], 'SHORT' );
if ( isset( $data['post_date'] ) )
{
$data['_post_date'] = $data['post_date'];
$data['post_date'] = $this->registry->getClass( 'class_localization')->getDate( $data['post_date'], 'SHORT' );
}
if ( $this->memberData['is_mod'] )
{
$data['posts'] += intval($data['topic_queuedposts']);
}
if ( $data['posts'])
{
if ( (($data['posts'] + 1) % $this->settings['display_max_posts']) == 0 )
{
$pages = ($data['posts'] + 1) / $this->settings['display_max_posts'];
}
else
{
$number = ( ($data['posts'] + 1) / $this->settings['display_max_posts'] );
$pages = ceil( $number);
}
}
if ( $pages > 1 )
{
for ( $i = 0 ; $i < $pages ; ++$i )
{
$real_no = $i * $this->settings['display_max_posts'];
$page_no = $i + 1;
if ( $page_no == 4 and $pages > 4 )
{
$data['pages'][] = array( 'last' => 1,
'st' => ($pages - 1) * $this->settings['display_max_posts'],
'page' => $pages );
break;
}
else
{
$data['pages'][] = array( 'last' => 0,
'st' => $real_no,
'page' => $page_no );
}
}
}
/* For-matt some stuffs */
if ( ! $data['cache_content'] )
{
IPSText::getTextClass( 'bbcode' )->parse_smilies = $data['use_emo'];
IPSText::getTextClass( 'bbcode' )->parse_html = ( $forum['use_html'] and $this->caches['group_cache'][ $data['member_group_id'] ]['g_dohtml'] and $data['post_htmlstate'] ) ? 1 : 0;
IPSText::getTextClass( 'bbcode' )->parse_nl2br = $data['post_htmlstate'] == 2 ? 1 : 0;
IPSText::getTextClass( 'bbcode' )->parse_bbcode = $forum['use_ibc'];
IPSText::getTextClass( 'bbcode' )->parsing_section = 'topics';
IPSText::getTextClass( 'bbcode' )->parsing_mgroup = $data['member_group_id'];
IPSText::getTextClass( 'bbcode' )->parsing_mgroup_others = $data['mgroup_others'];
}
else
{
$data['post'] = '<!--cached-' . gmdate( 'r', $data['cache_updated'] ) . '-->' . $data['cache_content'];
}
$data['post'] = IPSText::searchHighlight( IPSText::getTextClass( 'bbcode' )->preDisplayParse( $data['post'] ), $search_term );
/* Has attachments */
if ( $data['topic_hasattach'] )
{
$attachPids[ $data['pid'] ] = $data['post'];
}
$rows[ $id ] = $data;
}
/* Attachments */
if ( count( $attachPids ) )
{
/* Load attachments class */
if ( ! is_object( $this->class_attach ) )
{
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
$this->class_attach = new $classToLoad( $this->registry );
$this->class_attach->type = 'post';
$this->class_attach->init();
}
$attachHTML = $this->class_attach->renderAttachments( array( $data['pid'] => $data['post'] ), array_keys( $attachPids ) );
/* Now parse back in the rendered posts */
if( is_array($attachHTML) AND count($attachHTML) )
{
foreach( $attachHTML as $id => $_data )
{
/* Get rid of any lingering attachment tags */
if ( stristr( $_data['html'], "[attachment=" ) )
{
$_data['html'] = IPSText::stripAttachTag( $_data['html'] );
}
$rows[ $id ]['post'] = $_data['html'];
$rows[ $id ]['attachmentHtml'] = $_data['attachmentHtml'];
}
}
}
/* Go through and build HTML */
foreach( $rows as $id => $data )
{
/* Format content */
list( $html, $sub ) = $this->formatContent( $data );
$results[ $id ] = array( 'html' => $html, 'app' => $data['app'], 'type' => $data['type'], 'sub' => $sub );
}
return $results;
}
/**
* Formats the forum search result for display
*
* @param array $search_row Array of data
* @return mixed Formatted content, ready for display, or array containing a $sub section flag, and content
*/
public function formatContent( $data )
{
$onlyPosts = IPSSearchRegistry::get('opt.onlySearchPosts');
$onlyTitles = IPSSearchRegistry::get('display.onlyTitles');
$noPostPreview = IPSSearchRegistry::get('opt.noPostPreview');
/* Forum Breadcrum */
$data['_forum_trail'] = $this->registry->getClass( 'class_forums' )->forumsBreadcrumbNav( $data['forum_id'] );
/* Is it read? We don't support last_vote in search. */
$is_read = $this->registry->getClass( 'classItemMarking' )->isRead( array( 'forumID' => $data['forum_id'], 'itemID' => $data['tid'], 'itemLastUpdate' => $data['lastupdate'] ? $data['lastupdate'] : $data['updated'] ), 'forums' );
/* Has posted dot */
$show_dots = ( $this->settings['show_user_posted'] AND $this->memberData['member_id'] AND $data['_hasPosted'] ) ? 1 : 0;
/* Icon */
$data['_icon'] = $this->registry->getClass( 'class_forums' )->fetchTopicFolderIcon( $data, $show_dots, $is_read );
$data['_isRead'] = $is_read;
/* Display type */
return array( $this->registry->getClass( 'output' )->getTemplate( 'search' )->topicPostSearchResultAsForum( $data, ( $onlyTitles || $noPostPreview ) ? 1 : 0 ), 0 );
}
/**
* Formats / grabs extra data for results
* Takes an array of IDS (can be IDs from anything) and returns an array of expanded data.
*
* @return array
*/
public function processResults( $ids )
{
/* INIT */
$sort_by = IPSSearchRegistry::get('in.search_sort_by');
$sort_order = IPSSearchRegistry::get('in.search_sort_order');
$search_term = IPSSearchRegistry::get('in.clean_search_term');
$content_title_only = IPSSearchRegistry::get('opt.searchTitleOnly');
$onlyPosts = IPSSearchRegistry::get('opt.onlySearchPosts');
$order_dir = ( $sort_order == 'asc' ) ? 'asc' : 'desc';
$_post_joins = array();
$members = array();
$results = array();
$topicIds = array();
$dots = array();
$sortKey = '';
$sortType = '';
$_sdTids = array();
$_sdPids = array();
/* Set up some basic permissions */
$permissions['PostSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedPosts( 0 );
$permissions['TopicSoftDeleteSee'] = $this->registry->getClass('class_forums')->canSeeSoftDeletedTopics( 0 );
$permissions['canQueue'] = $this->registry->getClass('class_forums')->canQueuePosts( 0 );
$permissions['SoftDeleteReason'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteReason( 0 );
$permissions['SoftDeleteContent'] = $this->registry->getClass('class_forums')->canSeeSoftDeleteContent( 0 );
$permissions['PostSoftDeleteRestore'] = $this->registry->getClass('class_forums')->can_Un_SoftDeletePosts( 0 );
$permissions['TopicSoftDeleteRestore'] = $this->registry->getClass('class_forums')->can_Un_SoftDeleteTopics( 0 );
/* Got some? */
if ( count( $ids ) )
{
/* Cache? */
if ( IPSContentCache::isEnabled() )
{
if ( IPSContentCache::fetchSettingValue('post') )
{
$_post_joins[] = IPSContentCache::join( 'post', 'p.pid' );
}
if ( IPSContentCache::fetchSettingValue('sig') )
{
$_post_joins[] = IPSContentCache::join( 'sig' , 'p.author_id', 'ccb', 'left', 'ccb.cache_content as cache_content_sig, ccb.cache_updated as cache_updated_sig' );
}
}
/* Sorting */
switch( $sort_by )
{
default:
case 'date':
$sortKey = ( $content_title_only ) ? 'last_post' : 'post_date';
$sortType = 'numerical';
break;
case 'title':
$sortKey = 'title';
$sortType = 'string';
break;
case 'posts':
$sortKey = 'posts';
$sortType = 'numerical';
break;
case 'views':
$sortKey = 'views';
$sortType = 'numerical';
break;
}
/* Set vars */
IPSSearch::$ask = $sortKey;
IPSSearch::$aso = strtolower( $order_dir );
IPSSearch::$ast = $sortType;
/* If we are search in titles only, then the ID array will be TIDs */
if( $content_title_only )
{
$k = 'tid';
$this->DB->build( array(
'select' => "t.*",
'from' => array( 'topics' => 't' ),
'where' => 't.tid IN( ' . implode( ',', $ids ) . ')',
'add_join' => array_merge( array( array( 'select' => 'p.*',
'from' => array( 'posts' => 'p' ),
'where' => 'p.pid=t.topic_firstpost',
'type' => 'left' ),
array( 'select' => 'm.member_id, m.members_display_name, m.members_seo_name',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=p.author_id',
'type' => 'left' ) ), $_post_joins ) ) );
}
/* Otherwise, it's PIDs */
else
{
$k = 'pid';
$this->DB->build( array(
'select' => "p.*",
'from' => array( 'posts' => 'p' ),
'where' => 'p.pid IN( ' . implode( ',', $ids ) . ')',
'add_join' => array_merge( array( array( 'select' => 't.*',
'from' => array( 'topics' => 't' ),
'where' => 't.tid=p.topic_id',
'type' => 'left' ),
array( 'select' => 'm.member_id, m.members_display_name, m.members_seo_name',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=p.author_id',
'type' => 'left' ) ), $_post_joins ) ) );
}
/* Grab data */
$this->DB->execute();
/* Grab the results */
while( $row = $this->DB->fetch() )
{
$_rows[ $row[ $k ] ] = $row;
}
/* Sort */
if ( count( $_rows ) )
{
usort( $_rows, array("IPSSearch", "usort") );
foreach( $_rows as $id => $row )
{
/* Prevent member from stepping on it */
$row['topic_title'] = $row['title'];
/* Got author but no member data? */
if ( ! empty( $row['author_id'] ) )
{
$members[ $row['author_id'] ] = $row['author_id'];
}
/* Topic ids? */
if ( ! empty( $row['topic_id'] ) )
{
$topicIds[ $row['topic_id'] ] = $row['topic_id'];
}
/* If we're using sphinx, check forum permissions again as the 15 minute delta rebuild could expose a moved topic before deltas rebuild.
We don't need to do this for SQL search as the results are delivered live and lets face it, we can do without the load */
if ( $this->settings['search_method'] != 'traditional' )
{
/* Can we read? */
if ( ! $this->registry->permissions->check( 'view', $this->registry->class_forums->forum_by_id[ $row['forum_id'] ] ) )
{
continue;
}
/* Can read, but is it password protected, etc? */
if ( ! $this->registry->class_forums->forumsCheckAccess( $row['forum_id'], 0, 'forum', array(), true ) )
{
continue;
}
}
$row['cleanSearchTerm'] = urlencode($search_term);
$row['topicPrefix'] = $row['pinned'] ? $this->registry->getClass('output')->getTemplate('forum')->topicPrefixWrap( $this->settings['pre_pinned'] ) : '';
$row['_isVisible'] = ( $this->registry->getClass('class_forums')->fetchHiddenTopicType( $row ) == 'visible' ) ? true : false;
$row['_isHidden'] = ( $this->registry->getClass('class_forums')->fetchHiddenTopicType( $row ) == 'hidden' ) ? true : false;
$row['_isDeleted'] = ( $this->registry->getClass('class_forums')->fetchHiddenTopicType( $row ) == 'sdelete' ) ? true : false;
$row['_p_isVisible'] = ( $this->registry->getClass('class_forums')->fetchHiddenType( $row ) == 'visible' ) ? true : false;
$row['_p_isHidden'] = ( $this->registry->getClass('class_forums')->fetchHiddenType( $row ) == 'hidden' ) ? true : false;
$row['_p_isDeleted'] = ( $this->registry->getClass('class_forums')->fetchHiddenType( $row ) == 'sdelete' ) ? true : false;
/* Hidden and we do not have permission? */
if ( $row['_isHidden'] AND ! $permissions['canQueue'] )
{
continue;
}
/* Is the topic deleted? If so, then the first post will appear as such */
if ( $row['_isDeleted'] AND $permissions['TopicSoftDeleteSee'] )
{
$row['_p_isDeleted'] = true;
$_sdPids[ $row['pid'] ] = $row['pid'];
}
/* Collect TIDS of soft deleted topics */
if ( $row['_isDeleted'] )
{
if ( $permissions['TopicSoftDeleteSee'] )
{
$_sdTids[ $row['tid'] ] = $row['tid'];
}
else
{
continue;
}
}
/* Collect TIDS of soft deleted topics */
if ( $row['_p_isDeleted'] )
{
if ( $permissions['PostSoftDeleteSee'] )
{
$_sdPids[ $row['pid'] ] = $row['pid'];
}
else
{
continue;
}
}
$results[ $row['pid'] ] = $this->genericizeResults( $row );
}
}
/* Need to load members? */
if ( count( $members ) )
{
$mems = IPSMember::load( $members, 'all' );
foreach( $results as $id => $r )
{
if ( ! empty( $r['author_id'] ) AND isset( $mems[ $r['author_id'] ] ) )
{
$mems[ $r['author_id'] ]['m_posts'] = $mems[ $r['author_id'] ]['posts'];
//unset( $mems[ $r['author_id'] ]['posts'] );
unset( $mems[ $r['author_id'] ]['last_post'] );
if ( isset( $r['cache_content_sig'] ) )
{
$mems[ $r['author_id'] ]['cache_content'] = $r['cache_content_sig'];
$mems[ $r['author_id'] ]['cache_updated'] = $r['cache_updated_sig'];
}
$_mem = IPSMember::buildDisplayData( $mems[ $r['author_id'] ], array( 'signature' => 1 ) );
unset( $_mem['cache_content'], $_mem['cache_updated'] );
$results[ $id ]['_realPosts'] = $results[ $id ]['posts'];
$results[ $id ] = array_merge( $results[ $id ], $_mem );
$results[ $id ]['posts'] = $results[ $id ]['_realPosts'];
}
}
}
/* Generate 'dot' folder icon */
if ( $this->settings['show_user_posted'] AND count( $topicIds ) )
{
$this->DB->build( array( 'select' => 'author_id, topic_id',
'from' => 'posts',
'where' => 'queued=0 AND author_id=' . $this->memberData['member_id'] . ' AND topic_id IN(' . implode( ',', $topicIds ) . ')' ) );
$this->DB->execute();
while( $p = $this->DB->fetch() )
{
$dots[ $p['topic_id'] ] = 1;
}
/* Merge into results */
foreach( $results as $id => $r )
{
if ( isset( $dots[ $r['topic_id'] ] ) )
{
$results[ $id ]['_hasPosted'] = 1;
}
}
}
/* Got any deleted items */
if ( count( $_sdTids ) )
{
$sData = IPSDeleteLog::fetchEntries( $_sdTids, 'topic', false );
if ( count( $sData ) )
{
foreach( $results as $id => $data )
{
if ( isset( $_sdTids[ $data['tid'] ] ) )
{
$results[ $id ]['sData'] = $sData[ $data['tid'] ];
$results[ $id ]['permissions'] = $permissions;
}
}
}
}
/* Got any deleted items */
if ( count( $_sdPids ) )
{
$sData = IPSDeleteLog::fetchEntries( $_sdPids, 'post', false );
if ( count( $sData ) )
{
foreach( $results as $id => $data )
{
if ( isset( $_sdPids[ $data['pid'] ] ) AND ! isset( $results[ $id ]['sData']) )
{
$results[ $id ]['sData'] = $sData[ $data['pid'] ];
$results[ $id ]['permissions'] = $permissions;
}
}
}
}
}
return $results;
}
/**
* Reassigns fields in a generic way for results output
*
* @param array $r
* @return array
*/
public function genericizeResults( $r )
{
$r['app'] = 'forums';
$r['content'] = $r['post'];
$r['content_title'] = $r['title'];
$r['updated'] = $r['post_date'];
$r['lastupdate'] = $r['last_post'];
$r['type_2'] = 'topic';
$r['type_id_2'] = $r['tid'];
$r['misc'] = $r['pid'];
return $r;
}
}
@@ -0,0 +1,10 @@
<html>
<head><title>IP.Board - Bulletin Board System</title></head>
<body>
<h1>403: IP.Board -&gt; Forbidden</h1>
<hr>
You have reached this page in error, please use your back button to return to the forum.
<hr>
<a href="http://www.invisionboard.com/">IP.Board</a>
</body>
</html>