Version 3.0.5

This commit is contained in:
Neo committed 2025-12-19 00:31:03 -08:00
1 parent 19b38c7c74
commit 1d4720f3e2
3755 files changed
+508378 -664541

No files matched your search

@@ -0,0 +1,500 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Moderator actions
* Last Updated: $Date: 2009-10-01 10:02:08 -0400 (Thu, 01 Oct 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Forums
* @link http://www.iinvisionpower.com
* @version $Revision: 5190 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly.";
exit();
}
class digestLibrary
{
/**
* Digest time
*
* @access public
* @var string daily|weekly
*/
public $digest_time = 'daily';
/**
* Digest type
*
* @access public
* @var string topic|forum
*/
public $digest_type = 'topic';
/**
* Midnight time
*
* @access public
* @var integer Timestamp
*/
public $midnight = 0;
/**
* Last week timestamp
*
* @access public
* @var integer Timestamp
*/
public $last_week = 0;
/**
* Yesterday timestamp
*
* @access public
* @var integer Timestamp
*/
public $last_day = 0;
/**
* Last time timestamp
*
* @access public
* @var integer Timestamp
*/
public $last_time = 0;
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Constructor
*
* @access public
* @param object Registry reference
* @return void
*/
public function __construct( ipsRegistry $registry )
{
/* Make objects */
$this->registry = $registry;
$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();
/* Check for class_forums */
if( ! $this->registry->isClassLoaded( 'class_forums' ) )
{
require_once( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php" );
$this->registry->setClass( 'class_forums', new class_forums( $registry ) );
$this->registry->strip_invisible = 0;
$this->registry->class_forums->forumsInit();
}
//-----------------------------------------
// Get midnight (GMT - roughly)
//-----------------------------------------
$this->midnight = mktime( 0, 0 );
//-----------------------------------------
// Midnight today minus a weeks worth of secs
//-----------------------------------------
$this->last_week = $this->midnight - 604800;
//-----------------------------------------
// Midnight today minus a day worth of secs
//-----------------------------------------
$this->last_day = $this->midnight - 86400;
//-----------------------------------------
// Get some lang bits
//-----------------------------------------
ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'public_emails' ), 'core' );
}
/**
* Run the digest
*
* @access public
* @return void
*/
public function runDigest()
{
$this->last_time = $this->digest_time == 'daily' ? $this->last_day : $this->last_week;
if ( $this->digest_type == 'topic' )
{
$this->_sendTopicDigest();
}
else
{
$this->_sendForumDigest();
}
}
/**
* Run the digest
*
* @access private
* @return void
*/
private function _sendTopicDigest()
{
//-----------------------------------------
// Get all posts / topics
//-----------------------------------------
$this->DB->build( array( 'select' => 'tr.trid, tr.topic_id, tr.member_id as trmid',
'from' => array( 'tracker' => 'tr' ),
'where' => "tr.topic_track_type='{$this->digest_time}' AND t.approved=1 AND t.last_post > {$this->last_time}",
'add_join' => array(
array( 'select' => 'm.member_group_id, m.mgroup_others, m.org_perm_id, m.members_display_name, m.email, m.posts, m.member_id, m.email_full, m.language, m.last_activity',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=tr.member_id',
'type' => 'left'
),
array( 'select' => 't.*',
'from' => array( 'topics' => 't' ),
'where' => 't.tid=tr.topic_id',
'type' => 'left'
),
) ) );
$topic_query = $this->DB->execute();
//-----------------------------------------
// Now, loop print and send to subscribers
//-----------------------------------------
$main_output = "";
$count = 0;
$cached = array();
$subject = $this->digest_time == 'daily' ? 'digest_topic_daily' : 'digest_topic_weekly';
$trids = array();
while( $t = $this->DB->fetch( $topic_query ) )
{
//-----------------------------------------
// Can access forum/topic?
//-----------------------------------------
if( !$this->registry->getClass('class_forums')->checkEmailAccess($t) )
{
continue;
}
//-----------------------------------------
// Topic approved or is a mod?
//-----------------------------------------
if( !$this->registry->getClass('class_forums')->checkEmailApproved($t) )
{
continue;
}
//-----------------------------------------
// Build email
//-----------------------------------------
$main_output = "";
$others_posted = 0;
if ( ! $cached[ $t['tid'] ] )
{
$topic_title = $t['title'];
$forum_name = ipsRegistry::getClass('class_forums')->allForums[ $t['forum_id'] ]['name'];
//-----------------------------------------
// Get posts...
//-----------------------------------------
$this->DB->build( array( 'select' => '*',
'from' => 'posts',
'where' => "topic_id={$t['tid']} AND queued=0 AND post_date > {$this->last_time}",
'order' => 'post_date' ) );
$post_query = $this->DB->execute();
$post_output = "";
while( $p = $this->DB->fetch( $post_query ) )
{
//-----------------------------------------
// Do we have other posters?
//-----------------------------------------
if ( $t['trmid'] != $p['author_id'] )
{
$others_posted = 1;
}
$post_author = $p['author_name'];
$post_date = ipsRegistry::getClass( 'class_localization')->getDate( $p['post_date'], 'SHORT' );
$post_content = $p['post'];
$post_output .= "<br />-------------------------------------------<br />"
. "{$post_author} -- {$post_date}<br />{$post_content}<br /><br />";
}
//-----------------------------------------
// Skip if there is no content...
//-----------------------------------------
if( !$post_output )
{
continue;
}
//-----------------------------------------
// Process
//-----------------------------------------
$main_output .= $this->lang->words['topic_langbit'] . ": {$topic_title} (" . $this->lang->words['forum_langbit'] . ": {$forum_name})<br />"
. $this->registry->getClass('output')->buildSEOUrl( $this->settings['board_url'] . '/index.php?showtopic=' . $t['tid'], 'none', $t['title_seo'], 'showtopic' ) . "<br />"
. "=====================================<br />"
. $post_output
. "<br />=====================================<br />";
$cached[ $t['tid'] ] = $main_output;
}
else
{
$others_posted = 1;
$main_output = $cached[ $t['tid'] ];
}
if ( $others_posted )
{
$count++;
$trids[ $t['trid'] ] = intval( $t['trid'] );
//-----------------------------------------
// Send email...
//-----------------------------------------
IPSText::getTextClass( 'email' )->getTemplate( $subject, $t['language'] );
IPSText::getTextClass( 'email' )->buildMessage( array(
'TOPIC_ID' => $t['tid'],
'FORUM_ID' => $t['forum_id'],
'TITLE' => $topic_title,
'NAME' => $t['members_display_name'],
'CONTENT' => $main_output,
) );
$this->DB->insert( 'mail_queue', array( 'mail_to' => $t['email'],
'mail_date' => time(),
'mail_from' => '',
'mail_subject' => IPSText::getTextClass( 'email' )->subject,
'mail_content' => IPSText::getTextClass( 'email' )->message ) );
}
}
/* Update sent time */
if ( count( $trids ) )
{
$this->DB->update( 'tracker', array( 'last_sent' => time() ), 'trid IN (' . implode( ',', $trids ) . ')' );
}
$cache = ipsRegistry::cache()->getCache('systemvars');
$cache['mail_queue'] += $count;
//-----------------------------------------
// Update cache with remaning email count
//-----------------------------------------
ipsRegistry::cache()->setCache( 'systemvars', $cache, array( 'array' => 1, 'donow' => 1 ) );
}
/**
* Run the digest
*
* @access private
* @return void
*/
private function _sendForumDigest()
{
//-----------------------------------------
// Get all posts / topics
//-----------------------------------------
$this->DB->build( array( 'select' => 'ft.*',
'from' => array( 'forum_tracker' => 'ft' ),
'where' => "ft.forum_track_type='{$this->digest_time}'",
'add_join' => array(
array( 'select' => 'm.members_display_name, m.member_group_id, m.mgroup_others, m.org_perm_id, m.member_id, m.email, m.language, m.posts',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=ft.member_id',
'type' => 'left'
)
) ) );
$forum_query = $this->DB->execute();
//-----------------------------------------
// Now, loop print and send to subscribers
//-----------------------------------------
$main_output = "";
$count = 0;
$cached = array();
$subject = $this->digest_time == 'daily' ? 'digest_forum_daily' : 'digest_forum_weekly';
$frids = array();
while( $t = $this->DB->fetch( $forum_query ) )
{
$main_output = "";
$others_posted = 0;
$forum_name = ipsRegistry::getClass('class_forums')->allForums[ $t['forum_id'] ]['name'];
//-----------------------------------------
// Get topics...
//-----------------------------------------
$this->DB->build( array( 'select' => '*',
'from' => 'topics',
'where' => "forum_id={$t['forum_id']} AND last_post > {$this->last_time}",
) );
$topic_query = $this->DB->execute();
$post_output = "";
while( $p = $this->DB->fetch( $topic_query ) )
{
//-----------------------------------------
// Check access
//-----------------------------------------
if( !$this->registry->getClass('class_forums')->checkEmailAccess( array_merge($t,$p) ) )
{
continue;
}
//-----------------------------------------
// Topic approved or is a mod?
//-----------------------------------------
if( !$this->registry->getClass('class_forums')->checkEmailApproved( array_merge($t,$p) ) )
{
continue;
}
$post = $this->DB->buildAndFetch( array( 'select' => '*',
'from' => 'posts',
'where' => 'topic_id=' . $p['tid'],
'order' => 'post_date DESC',
'limit' => array( 1 )
) );
//-----------------------------------------
// Do we have other posters?
//-----------------------------------------
if ( $t['member_id'] != $post['author_id'] )
{
$others_posted = 1;
}
$post_author = $post['author_name'];
$post_date = ipsRegistry::getClass('class_localization')->getDate( $post['post_date'], 'SHORT' );
$post_content = $post['post'];
$topic_title = $p['title'];
$post_output .= "<br />-------------------------------------------<br />"
. $this->lang->words['topic_langbit'] . ": {$topic_title} ({$post_author} -- {$post_date})<br />"
. $this->registry->getClass('output')->buildSEOUrl( $this->settings['board_url'] . '/index.php?showtopic=' . $p['tid'], 'none', $p['title_seo'], 'showtopic' )
. "<br />............................................<br />"
. "{$post_content}<br /><br />";
}
//-----------------------------------------
// Skip if there is no content...
//-----------------------------------------
if( $post_output == '' )
{
continue;
}
//-----------------------------------------
// Process
//-----------------------------------------
$main_output = $this->lang->words['forum_langbit'] . ": {$forum_name}<br />"
. "=====================================<br />"
. $post_output
. "<br />=====================================<br />";
if ( $others_posted )
{
$count++;
$frids[ $t['frid'] ] = intval( $t['frid'] );
//-----------------------------------------
// Send email...
//-----------------------------------------
IPSText::getTextClass( 'email' )->getTemplate( $subject, $t['language'] );
IPSText::getTextClass( 'email' )->buildMessage( array(
'FORUM_ID' => $t['forum_id'],
'FORUM_NAME' => $forum_name,
'NAME' => $t['members_display_name'],
'CONTENT' => $main_output,
) );
$this->DB->insert( 'mail_queue', array( 'mail_to' => $t['email'],
'mail_date' => time(),
'mail_from' => '',
'mail_subject' => IPSText::getTextClass( 'email' )->subject,
'mail_content' => IPSText::getTextClass( 'email' )->message ) );
}
}
/* Update sent time */
if ( count( $frids ) )
{
$this->DB->update( 'forum_tracker', array( 'last_sent' => time() ), 'frid IN (' . implode( ',', $frids ) . ')' );
}
$cache = ipsRegistry::cache()->getCache('systemvars');
$cache['mail_queue'] += $count;
//-----------------------------------------
// Update cache with remaning email count
//-----------------------------------------
ipsRegistry::cache()->setCache( 'systemvars', $cache, array( 'array' => 1, 'donow' => 1 ) );
}
}
@@ -0,0 +1,543 @@
<?php
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'.";
exit();
}
/**
* Invision Power Services
* IP.Board v3.0.5
* Admin forum functions library
* Last Updated: $Date: 2009-09-29 17:59:02 -0400 (Tue, 29 Sep 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Forums
* @link http://www.iinvisionpower.com
* @since 26th January 2004
* @version $Rev: 5178 $
*
*/
class admin_forum_functions extends class_forums
{
/**
* HTML object
*
* @access public
* @var object
*/
public $html;
/**
* Type
*
* @access public
* @var string
*/
public $type = "";
/**
* How many printed
*
* @access public
* @var integer
*/
public $printed = 0;
/**
* Whether to show all or not
*
* @access public
* @var boolean
*/
public $show_all = false;
/**
* Cached skin id -> names
*
* @access public
* @var array
*/
public $skins = array();
/**
* Need descriptions
*
* @access public
* @var array
*/
public $need_desc = array();
/**
* Build forum children
*
* @access public
* @param integer $root_id
* @param string $temp_html
* @param string $depth_guide
* @return string
**/
public function forumBuildChildren( $root_id, $temp_html="", $depth_guide="" )
{
if ( isset( $this->forum_cache[ $root_id ] ) AND is_array( $this->forum_cache[ $root_id ] ) )
{
foreach( $this->forum_cache[ $root_id ] as $forum_data )
{
if ( $this->settings['forum_cache_minimum'] AND $this->settings['forum_cache_minimum'] )
{
$forum_data['description'] = "<!--DESCRIPTION:{$forum_data['id']}-->";
$this->need_desc[] = $forum_data['id'];
}
$temp_html .= $this->renderForum( $forum_data, $depth_guide );
$temp_html = $this->forumBuildChildren( $forum_data['id'], $temp_html, $depth_guide . $this->depth_guide );
}
}
return $temp_html;
}
/**
* Build forum
*
* @access public
* @param integer $r
* @param string $depth_guide
* @return string
**/
public function renderForum( $r, $depth_guide="" )
{
//-----------------------------------------
// INIT
//-----------------------------------------
$desc = "";
$mod_string = "";
$r['skin_id'] = isset( $r['skin_id'] ) ? $r['skin_id'] : '';
//-----------------------------------------
// Manage forums?
//-----------------------------------------
if ( $this->type == 'manage' )
{
//-----------------------------------------
// Show main forums...
//-----------------------------------------
if ( ! $this->show_all )
{
$children = $this->forumsGetChildren( $r['id'] );
$sub = array();
$subforums = "";
$count = 0;
//-----------------------------------------
// Build sub-forums link
//-----------------------------------------
if ( count($children) )
{
$r['name'] = "<a href='{$this->settings['base_url']}f={$r['id']}'>" . $r['name'] . "</a>";
foreach ( $children as $cid )
{
$count++;
$cfid = $cid;
if ( $count == count( $children ) )
{
//-----------------------------------------
// Last subforum, link to parent
// forum...
//-----------------------------------------
if ( !isset($children[ $count - 2 ]) OR ! $cfid = $children[ $count - 2 ] )
{
$cfid = $r['id'];
}
}
$sub[] = "<a href='{$this->settings['base_url']}f={$this->forum_by_id[$cid]['parent_id']}'>".$this->forum_by_id[$cid]['name']."</a>";
}
}
if ( count( $sub ) )
{
$subforums = '<fieldset style="margin-top:4px"><legend>' . $this->lang->words['acp_subforum_legend'] . '</legend>' . implode( ", ", $sub ) . '</fieldset>';
}
//$desc = "{$r['description']}{$subforums}";
}
$desc = "{$r['description']}{$subforums}";
//-----------------------------------------
// Moderators
//-----------------------------------------
$r['_modstring'] = "";
foreach( $this->moderators as $data )
{
$forum_ids = explode( ',', IPSText::cleanPermString( $data['forum_id'] ) );
foreach( $forum_ids as $forum_id )
{
if ( $forum_id == $r['id'] )
{
if ($data['is_group'] == 1)
{
$data['_fullname'] = $this->lang->words['fc_group_prefix'] . $data['group_name'];
}
else
{
$data['_fullname'] = $data['members_display_name'];
}
$data['randId'] = substr( str_replace( array( ' ', '.' ), '', uniqid( microtime(), true ) ), 0, 10 );
$r['_modstring'] .= $this->html->renderModeratorEntry( $data, $forum_id );
}
}
}
//-----------------------------------------
// Print
//-----------------------------------------
$this->skins[$r['skin_id']] = ( isset($this->skins[ $r['skin_id'] ] ) AND $this->skins[ $r['skin_id'] ] ) ? $this->skins[ $r['skin_id'] ] : '';
return $this->html->renderForumRow( $desc, $r, $depth_guide, $this->skins[ $r['skin_id'] ] );
}
}
/**
* Show Category
*
* @access public
* @param string $content
* @param array $r
* @param bool $show_buttons
* @return void
**/
public function forumShowCat( $content, $r, $show_buttons=1 )
{
$this->printed++;
$no_root = count( $this->forum_cache['root'] );
$this->registry->output->html .= $this->html->forumWrapper( $content, $r, $show_buttons );
}
/**
* End Category
*
* @access public
* @param array $r
* @return void
**/
public function forum_end_cat($r=array())
{
// NO LONGER USED?
if ( $this->type == 'manage' )
{
$this->registry->output->html .= $this->registry->output->end_table();
}
}
/**
* List all forums
*
* @access public
* @return void
**/
public function forumsListForums()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$this->show_all = intval( $this->request['showall'] );
if ( ! $this->html )
{
$this->html = $this->registry->output->loadTemplate( 'cp_skin_forums' );
}
//-----------------------------------------
// Manage forums
//-----------------------------------------
if ( $this->type == 'manage' )
{
foreach( $this->caches['skinsets'] as $id => $data )
{
$this->skins[ $id ] = $data['set_name'];
}
}
$temp_html = "";
$fid = intval( $this->request['f'] );
//-----------------------------------------
// Show all forums
//-----------------------------------------
if ( $this->show_all )
{
foreach( $this->forum_cache['root'] as $forum_data )
{
$cat_data = $forum_data;
$depth_guide = "";
$temp_html = "";
if ( isset($this->forum_cache[ $forum_data['id'] ]) AND is_array( $this->forum_cache[ $forum_data['id'] ] ) )
{
foreach( $this->forum_cache[ $forum_data['id'] ] as $forum_data )
{
if ( $this->settings['forum_cache_minimum'] AND $this->settings['forum_cache_minimum'] )
{
$forum_data['description'] = "<!--DESCRIPTION:{$forum_data['id']}-->";
$this->need_desc[] = $forum_data['id'];
}
$temp_html .= $this->renderForum( $forum_data, $depth_guide );
$temp_html = $this->forumBuildChildren( $forum_data['id'], $temp_html, '<span style="color:gray">&#0124;</span>'.$depth_guide . $this->depth_guide );
}
}
if( !$temp_html )
{
$temp_html = $this->html->renderNoForums( $cat_data['id'] );
}
$this->registry->output->html .= $this->forumShowCat( $temp_html, $cat_data );
unset($temp_html);
}
}
//-----------------------------------------
// Show root forums
//-----------------------------------------
else if ( ! $fid )
{
$seen_count = 0;
$total_items = 0;
if( is_array($this->forum_cache[ 'root' ]) AND count($this->forum_cache[ 'root' ]) )
{
foreach( $this->forum_cache[ 'root' ] as $forum_data )
{
$cat_data = $forum_data;
$depth_guide = "";
$temp_html = "";
if ( isset($this->forum_cache[ $forum_data['id'] ]) AND is_array( $this->forum_cache[ $forum_data['id'] ] ) )
{
foreach( $this->forum_cache[ $forum_data['id'] ] as $forum_data )
{
if ( $this->settings['forum_cache_minimum'] AND $this->settings['forum_cache_minimum'] )
{
$forum_data['description'] = "<!--DESCRIPTION:{$forum_data['id']}-->";
$this->need_desc[] = $forum_data['id'];
}
$temp_html .= $this->renderForum( $forum_data, $depth_guide );
}
}
if( !$temp_html )
{
$temp_html = $this->html->renderNoForums( $cat_data['id'] );
}
$this->registry->output->html .= $this->forumShowCat( $temp_html, $cat_data );
unset($temp_html);
}
}
}
//-----------------------------------------
// Show per ID forums
//-----------------------------------------
else
{
$cat_data = array();
$depth_guide = "";
if ( is_array( $this->forum_cache[ $fid ] ) )
{
$cat_data = $this->forum_by_id[ $fid ];
$depth_guide = "";
foreach( $this->forum_cache[ $fid ] as $forum_data )
{
if ( $this->settings['forum_cache_minimum'] AND $this->settings['forum_cache_minimum'] )
{
$forum_data['description'] = "<!--DESCRIPTION:{$forum_data['id']}-->";
$this->need_desc[] = $forum_data['id'];
}
$temp_html .= $this->renderForum( $forum_data, $depth_guide );
}
}
if( !$temp_html )
{
$temp_html = $this->html->renderNoForums( $cat_data['id'] );
}
$this->registry->output->html .= $this->forumShowCat( $temp_html, $this->forum_by_id[ $fid ] );
unset( $temp_html );
}
//-----------------------------------------
// Get descriptions?
//-----------------------------------------
if ( $this->settings['forum_cache_minimum'] AND $this->settings['forum_cache_minimum'] and count( $this->need_desc ) )
{
$this->DB->build( array( 'select' => 'id,description', 'from' => 'forums', 'where' => 'id IN('.implode( ',', $this->need_desc ) .')' ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
{
$this->registry->output->html = str_replace( "<!--DESCRIPTION:{$r['id']}-->", $r['description'], $this->registry->output->html );
}
}
}
/**
* Build Forum Jump
*
* @access public
* @param bool $restrict
* @return array
**/
public function adForumsForumList( $restrict=0 )
{
if ( $restrict != 1 )
{
//$jump_array[] = array( '-1', 'Make Root (Category)' );
}
else
{
$jump_array = array();
}
foreach( $this->forum_cache['root'] as $forum_data )
{
$jump_array[] = array( $forum_data['id'], $forum_data['name'] );
$depth_guide = $this->depth_guide;
if ( isset($this->forum_cache[ $forum_data['id'] ]) AND is_array( $this->forum_cache[ $forum_data['id'] ] ) )
{
foreach( $this->forum_cache[ $forum_data['id'] ] as $forum_data )
{
$jump_array[] = array( $forum_data['id'], $depth_guide.$forum_data['name'] );
$jump_array = $this->forumsForumListInternal( $forum_data['id'], $jump_array, $depth_guide . $this->depth_guide );
}
}
}
return $jump_array;
}
/**
* Build Forum List Helper
*
* @access private
* @param integer $root_id
* @param array $jump_array
* @param string $depth_guide
* @return array
**/
private function forumsForumListInternal( $root_id, $jump_array=array(), $depth_guide="" )
{
if( isset($this->forum_cache[ $root_id ] ) AND is_array( $this->forum_cache[ $root_id ] ) )
{
foreach( $this->forum_cache[ $root_id ] as $forum_data )
{
$jump_array[] = array( $forum_data['id'], $depth_guide.$forum_data['name'] );
$jump_array = $this->forumsForumListInternal( $forum_data['id'], $jump_array, $depth_guide . $this->depth_guide );
}
}
return $jump_array;
}
/**
* Build Forum Data
*
* @access public
* @return array
**/
public function adForumsForumData()
{
foreach( $this->forum_cache['root'] as $forum_data )
{
$forum_data['depthed_name'] = $forum_data['name'];
$forum_data['root_forum'] = 1;
$jump_array[ $forum_data['id'] ] = $forum_data;
$depth_guide = $this->depth_guide;
if ( isset($this->forum_cache[ $forum_data['id'] ]) AND is_array( $this->forum_cache[ $forum_data['id'] ] ) )
{
foreach( $this->forum_cache[ $forum_data['id'] ] as $forum_data )
{
$forum_data['depthed_name'] = $depth_guide.$forum_data['name'];
$jump_array[ $forum_data['id'] ] = $forum_data;
$jump_array = $this->forumsForumDataInternal( $forum_data['id'], $jump_array, $depth_guide . $this->depth_guide );
}
}
}
return $jump_array;
}
/**
* Build Forum Data Helper
*
* @access public
* @param integer $root_id
* @param array $jump_array
* @param string $depth_guide
* @return array
**/
public function forumsForumDataInternal( $root_id, $jump_array=array(), $depth_guide="" )
{
if ( isset( $this->forum_cache[ $root_id ]) AND is_array( $this->forum_cache[ $root_id ] ) )
{
foreach( $this->forum_cache[ $root_id ] as $forum_data )
{
$forum_data['depthed_name'] = $depth_guide.$forum_data['name'];
$jump_array[ $forum_data['id'] ] = $forum_data;
$jump_array = $this->forumsForumDataInternal( $forum_data['id'], $jump_array, $depth_guide . $this->depth_guide );
}
}
return $jump_array;
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> 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 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> 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>␍
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1 @@
<html>␍<head><title>IP.Board - Bulletin Board System</title></head>␍<body>␍<h1>403: IP.Board -> 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,612 @@
<?php
/**
* Invision Power Services
* IP.Board v3.0.5
* Threaded mode functions
* Last Updated: $Date: 2009-03-30 11:13:39 -0400 (Mon, 30 Mar 2009) $
*
* @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Board
* @subpackage Forums
* @link http://www.iinvisionpower.com
* @version $Revision: 4354 $
*
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly.";
exit();
}
class threadedModeLibrary
{
/**
* Topics library
*
* @access public
* @var object
*/
public $topics;
/**
* Structured post ids
*
* @access public
* @var array
*/
public $structured_pids = array();
/**
* Post cache
*
* @access public
* @var array
*/
public $post_cache = array();
/**
* Used post ids
*
* @access public
* @var array
*/
public $used_post_ids = array();
/**
* Threaded posts
*
* @access public
* @var array
*/
public $_threaded_posts = array();
/**
* Last id we've seen
*
* @access public
* @var int
*/
public $last_id = 0;
/**#@+
* Registry Object Shortcuts
*
* @access protected
* @var object
*/
protected $registry;
protected $DB;
protected $settings;
protected $request;
protected $lang;
protected $member;
protected $cache;
/**#@-*/
/**
* Constructor
*
* @access public
* @param object Registry reference
* @param object Reference to topics lib
* @return void
*/
public function __construct( ipsRegistry $registry, $topics )
{
/* Make objects */
$this->registry = $registry;
$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();
$this->topics =& $topics;
}
/**
* Get Threaded Topic Data
*
* @access public
* @return array
**/
public function _getTopicDataThreaded()
{
//-----------------------------------------
// Grab the posts we'll need
//-----------------------------------------
$pc_join = array();
$first = intval( $this->request['start'] );
$last = $this->settings['threaded_per_page'] ? $this->settings['threaded_per_page'] : 250;
//-----------------------------------------
// GET meh pids
//-----------------------------------------
if ( $first > 0 )
{
// we're on a page, make sure init val is there
$this->topics->pids[0] = $this->topics->topic['topic_firstpost'];
$this->structured_pids[ 0 ][] = $this->topics->topic['topic_firstpost'];
}
$this->DB->build( array(
'select' => 'pid, post_parent',
'from' => 'posts',
'where' => 'topic_id=' . $this->topics->topic['tid'] . ' and queued != 1',
'order' => 'pid',
'limit' => array( $first, $last )
) );
$this->DB->execute();
while( $p = $this->DB->fetch() )
{
$this->topics->pids[] = $p['pid'];
// Force to be children of 'root' post
if ( ! $p['post_parent'] and $p['pid'] != $this->topics->topic['topic_firstpost'] )
{
$p['post_parent'] = $this->topics->topic['topic_firstpost'];
}
$this->structured_pids[ $p['post_parent'] ][] = $p['pid'];
}
/* Ignored Users */
$ignored_users = array();
foreach( $this->member->ignored_users as $_i )
{
if( $_i['ignore_topics'] )
{
$ignored_users[] = $_i['ignore_ignore_id'];
}
}
//-----------------------------------------
// Get post bodah
//-----------------------------------------
if ( count( $this->topics->pids ) )
{
$this->DB->build( array(
'select' => 'pid, post, author_id, author_name, post_date, post_title, post_parent, topic_id, icon_id',
'from' => 'posts',
'where' => 'pid IN(' . implode( ',', $this->topics->pids ) . ')',
'order' => 'pid',
) );
$this->DB->execute();
while( $p = $this->DB->fetch() )
{
if ( ! $p['post_parent'] and $p['pid'] != $this->topics->topic['topic_firstpost'] )
{
$p['post_parent'] = $this->topics->topic['topic_firstpost'];
}
$this->post_cache[ $p['pid'] ] = $p;
$this->last_id = $p['pid'];
}
}
//-----------------------------------------
// Force root in cache
//-----------------------------------------
$this->post_cache[0] = array( 'id' => 1 );
$this->post_cache[ $this->topics->topic['topic_firstpost'] ]['post_title'] = $this->topics->topic['title'];
//-----------------------------------------
// Are we viewing Posts?
//-----------------------------------------
$post_id = intval( $this->request['pid'] );
if ( $post_id && ! in_array( $post_id, $this->topics->pids ) )
{
$this->registry->output->showError( 'topics_post_not_in_topic', 10358, true );
}
$postid_array = array( 1 => $post_id );
if ( $post_id and $post_id != $this->topics->topic['topic_firstpost'] )
{
$parents = $this->_threadedPostGetParents( $post_id );
if ( count($parents) )
{
foreach( $parents as $pid )
{
if ( $pid != $this->topics->topic['topic_firstpost'] )
{
$postid_array[] = $pid;
}
}
}
}
/* Join Queries */
$_post_joins = array(
array(
'select' => 'm.member_id as mid,m.name,m.member_group_id,m.email,m.joined,m.posts, m.last_visit, m.last_activity,m.login_anonymous,m.title,m.hide_email, m.warn_level, m.warn_lastwarn, m.members_display_name, m.members_seo_name, m.has_gallery, m.has_blog, m.members_bitoptions',
'from' => array( 'members' => 'm' ),
'where' => 'm.member_id=p.author_id',
'type' => 'left'
),
array(
'select' => 'pp.*',
'from' => array( 'profile_portal' => 'pp' ),
'where' => 'm.member_id=pp.pp_member_id',
'type' => 'left'
)
);
/* Reputation system enabled? */
if( $this->settings['reputation_enabled'] )
{
/* Add the join to figure out if the user has already rated the post */
$_post_joins[] = $this->registry->repCache->getUserHasRatedJoin( 'pid', 'p.pid', 'forums' );
/* Add the join to figure out the total ratings for each post */
if( $this->settings['reputation_show_content'] )
{
$_post_joins[] = $this->registry->repCache->getTotalRatingJoin( 'pid', 'p.pid', 'forums' );
}
}
/* Cache? */
if ( IPSContentCache::isEnabled() )
{
if ( IPSContentCache::fetchSettingValue('post') )
{
$_post_joins[] = IPSContentCache::join( 'post', 'p.pid' );
}
if ( IPSContentCache::fetchSettingValue('sig') )
{
$_post_joins[] = IPSContentCache::join( 'sig' , 'm.member_id', 'ccb', 'left', 'ccb.cache_content as cache_content_sig, ccb.cache_updated as cache_updated_sig' );
}
}
if( $this->settings['custom_profile_topic'] == 1 )
{
$_post_joins[] = array(
'select' => 'pc.*',
'from' => array( 'pfields_content' => 'pc' ),
'where' => 'pc.member_id=p.author_id',
'type' => 'left'
);
}
if( count( $postid_array ) )
{
//-----------------------------------------
// Get root post and children of clicked
//-----------------------------------------
$this->used_post_ids = ',' . implode( ",", $postid_array ) . ',';
$postid_array[0] = $this->topics->topic['topic_firstpost'];
$this->DB->build( array(
'select' => 'p.*',
'from' => array( 'posts' => 'p' ),
'where' => "p.pid IN(" . implode( ',', $postid_array ) . ")",
'order' => 'pid asc',
'add_join' => $_post_joins
) );
}
else
{
//-----------------------------------------
// Just get root
//-----------------------------------------
$this->DB->build( array(
'select' => 'p.*',
'from' => array( 'posts' => 'p' ),
'where' => "p.pid=" . $this->topics->topic['topic_firstpost'],
'order' => 'pid asc',
'add_join' => $_post_joins
) );
}
//-----------------------------------------
// Attachment PIDS
//-----------------------------------------
$this->topics->attach_pids = $postid_array;
//-----------------------------------------
// Render the original post
//-----------------------------------------
$outer = $this->DB->execute();
//-----------------------------------------
// Format and print out the topic list
//-----------------------------------------
$post_data = array();
$num_rows = $this->DB->getTotalRows( $outer );
while ( $row = $this->DB->fetch( $outer ) )
{
$return = $this->topics->parsePostRow( $row );
$poster = $return['poster'];
$row = $return['row'];
/* Reputation */
if( $this->settings['reputation_enabled'] )
{
$row['pp_reputation_points'] = $row['pp_reputation_points'] ? $row['pp_reputation_points'] : 0;
$row['has_given_rep'] = $row['has_given_rep'] ? $row['has_given_rep'] : 0;
$row['rep_points'] = $row['rep_points'] ? $row['rep_points'] : 0;
}
$post_data[ $row['pid'] ] = array( 'post' => $row, 'author' => $poster );
//-----------------------------------------
// Are we giving this bloke a good ignoring?
//-----------------------------------------
if( isset( $ignored_users ) && is_array( $ignored_users ) && count( $ignored_users ) )
{
if( in_array( $poster['member_id'], $ignored_users ) )
{
if ( ! strstr( $this->settings['cannot_ignore_groups'], ','.$poster['member_group_id'].',' ) )
{
$post_data[ $row['pid'] ]['post']['_ignored'] = 1;
continue;
}
}
}
if ( ! $this->printed and $num_rows > 1 )
{
$post_data[ $row['pid'] ]['post']['_end_first_post'] = 1;
$this->printed = 1;
}
}
//-----------------------------------------
// Sort out pagination
//-----------------------------------------
$total_replies = $this->topics->topic['posts'];
$show_replies = count( $this->structured_pids ) - 1;
$this->topics->topic['SHOW_PAGES'] = '';
$this->topics->topic['threaded_pages'] = $this->registry->output->generatePagination( array(
'totalItems' => $total_replies,
'itemsPerPage' => $last,
'currentStartValue' => $this->request['start'],
'baseUrl' => "showtopic=" . $this->topics->topic['tid'],
'startValueKey' => 'start'
) );
//-----------------------------------------
// START GETTING THE OUTLINE LIST
//-----------------------------------------
$this->_threaded_posts[ 0 ]['child'] = $this->_threadedLoopGetChildren();
$this->topics->topic['_threaded_posts'] = $this->_buildThreadedOutput( $this->_threaded_posts[ 0 ] );
return $post_data;
}
/**
* Actually builds the HTML for threaded view
*
* @access public
* @param array $root The root we're iterating
* @param string $html The current HTML in this loop
* @return string HTML
*/
public function _buildThreadedOutput( $root, $html='' )
{
$child = '';
if( is_array( $root['child'] ) )
{
if( count( $root['child'] ) )
{
foreach( $root['child'] as $pid => $post )
{
$child .= $this->_buildThreadedOutput( $post );
}
}
}
$html .= $this->registry->output->getTemplate('topic')->build_threaded( $root, $child );
return $html;
}
/**
* Render kiddies
*
* @access public
* @param integer $root_id
* @param array $posts
* @param integer $dguide
* @return array
**/
public function _threadedLoopGetChildren($root_id=0, $posts=array() ,$dguide=-1)
{
$dguide++;
if ( isset( $this->structured_pids[ $root_id ] ) && is_array( $this->structured_pids[ $root_id ] ) )
{
if ( count( $this->structured_pids[ $root_id ] ) )
{
foreach( $this->structured_pids[ $root_id ] as $pid )
{
$posts[ $pid ] = $this->_threadedRenderListRow( $this->post_cache[ $pid ], $dguide );
$posts[$pid]['child'] = $this->_threadedLoopGetChildren( $pid, isset( $posts[ $root_id ] ) ? $posts[ $root_id ] : array(), $dguide );
}
}
}
return $posts;
}
/**
* Builds an array of output for used in threaded view
*
* @access public
* @param array $post
* @param integer $depth
* @return array
**/
public function _threadedRenderListRow( $post, $depth )
{
$post['depthguide'] = "";
$this->settings[ 'post_showtext_notitle'] = 1 ;
for( $i = 1 ; $i < $depth; $i++ )
{
$post['depthguide'] .= $this->depth_guide[ $i ];
}
// Last child?
if ( $depth > 0 )
{
$last_id = count($this->structured_pids[ $post['post_parent'] ]) - 1;
if ( $this->structured_pids[ $post['post_parent'] ][$last_id] == $post['pid'] )
{
$this->depth_guide[ $depth ] = '<img src="'.$this->settings['img_url'].'/spacer.gif" alt="" width="20" height="16">';
$post['depthguide'] .= "<img src='".$this->settings['img_url']."/to_post_no_children.gif' alt='-' />";
}
else
{
$this->depth_guide[ $depth ] = '<img src="'.$this->settings['img_url'].'/to_down_pipe.gif" alt="|" />';
$post['depthguide'] .= "<img src='".$this->settings['img_url']."/to_post_with_children.gif' alt='-' />";
}
}
if ( ! $post['post_title'] )
{
if ( $this->settings['post_showtext_notitle'] )
{
$post_text = IPSText::getTextClass( 'bbcode' )->stripAllTags( strip_tags( IPSText::br2nl( $post['post'] ) ) );
if ( IPSText::mbstrlen($post_text) > 50 )
{
$post['post_title'] = IPSText::truncate( $post_text, 50 ).'...';
}
else
{
$post['post_title'] = $post_text;
}
if ( ! trim($post['post_title']) )
{
$post['post_title'] = $this->lang->words['post_title_re'] . $this->topics->topic['title'];
}
}
else
{
$post['post_title'] = $this->lang->words['post_title_re'] . $this->topics->topic['title'];
}
}
$post['linked_name'] = IPSLib::makeProfileLink( $post['author_name'], $post['author_id'] );
$post['formatted_date'] = $this->registry->class_localization->getDate( $post['post_date'], 'LONG' );
$post['new_post'] = 't_threaded_read';
if ( $post['post_date'] > $this->topics->last_read_tid )
{
$post['new_post'] = 't_threaded_read';
}
if ( strstr( $this->used_post_ids, ','.$post['pid'].',' ) )
{
$post['_show_highlight'] = 1;
}
return $post;
}
/**
* Get parents
*
* @access private
* @param integer $root_id
* @param array $ids
* @return array
**/
private function _threadedPostGetParents($root_id, $ids=array())
{
if( in_array( $root_id, $ids ) )
{
$cnt = 0;
foreach( $ids as $id )
{
if( $id == $root_id )
{
$cnt++;
if( $cnt > 1 )
{
return $ids;
}
}
}
}
if ( $this->post_cache[ $root_id ]['post_parent'] )
{
$ids[] = $this->post_cache[ $root_id ]['post_parent'];
$ids = $this->_threadedPostGetParents( $this->post_cache[ $root_id ]['post_parent'], $ids );
}
return $ids;
}
/**
* Get children
*
* @access private
* @param integer $root_id
* @param array $ids
* @return array
**/
private function _threadedPostGetChildren($root_id, $ids=array())
{
if ( is_array($this->structured_pids[ $root_id ]) )
{
foreach( $this->structured_pids[ $root_id ] as $pid )
{
$ids[] = $pid;
$ids = $this->_threadedPostGetChildren( $pdaid, $ids );
}
}
return $ids;
}
}