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

+123 -353
View File
@@ -2,13 +2,15 @@
/*
+--------------------------------------------------------------------------
| Invision Power Board
| Invision Power Board v<{%dyn.down.var.human.version%}>
| ========================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services
| (c) 2001 - 2009 Invision Power Services
| http://www.invisionpower.com
| ========================================
| Web: http://www.invisionboard.com
| Time: <{%dyn.down.var.time%}>
| Release: <{%dyn.down.var.md5%}>
| Email: matt@invisionpower.com
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
@@ -18,6 +20,7 @@
| > Date started: 29th April 2002
| > UPDATED for 2.0: 1st July 2004
| > UPDATED for 2.1: 13th Sept 2005
| > UPDATED for 3.0: 26th Feb 2009
|
+--------------------------------------------------------------------------
@@ -28,25 +31,17 @@
Simply call this script via PHP includes, or SSI .shtml tags to generate content
on the fly, streamed into your own webpage.
+--------------------------------------------------------------------------
| To show the last 10 topics and posts in the news forums...
+--------------------------------------------------------------------------
include("http://domain.com/forums/ssi.php?a=news&show=10");
You can adjust the "show" attribute to display a different amount of topics.
+--------------------------------------------------------------------------
| To show the board statistics
+--------------------------------------------------------------------------
include("http://domain.com/forums/ssi.php?a=stats");
include("http://domain.com/forums/ssi.php?a=stats");/*noLibHook*//*TERANOTE: remove additional /*
+--------------------------------------------------------------------------
| To show the active users stats (x Members, X Guests, etc)
+--------------------------------------------------------------------------
include("http://domain.com/forums/ssi.php?a=active");
include("http://domain.com/forums/ssi.php?a=active");/*noLibHook*//*TERANOTE: remove additional /*
+--------------------------------------------------------------------------
| RSS / XML Syndication..
@@ -66,29 +61,25 @@ all the forums in the comma separated list
*
* Set-up and load module to run
*
* @package InvisionPowerBoard
* @package IP.Board
* @author Matt Mecham
* @version 2.1
* @version 3.0
*/
/**
* Script type
*
*/
define( 'CCS_GATEWAY_CALLED', TRUE ); // Prevents redirect checks in ipsRegistry
define( 'IPS_ENFORCE_ACCESS', TRUE ); // Prevents force login setting from returning a login page
define( 'IPB_THIS_SCRIPT', 'public' );
define( 'IPB_LOAD_SQL' , 'queries' );
require_once( './init.php' );
require_once( './initdata.php' );/*noLibHook*/
//--------------------------------
// Other set up
//--------------------------------
require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );/*noLibHook*/
require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );/*noLibHook*/
/**
* Path to SSI templates directory
*
*/
define( 'SSI_TEMPLATES_DIR', ROOT_PATH."ssi_templates" );
define( 'SSI_TEMPLATES_DIR', DOC_IPS_ROOT_PATH."ssi_templates" );
/**
* Maximum number of topics to show
*
@@ -101,158 +92,44 @@ define( 'SSI_MAX_SHOW' , 100 );
*/
define( 'SSI_ALLOW_SYND' , 1 );
//===========================================================================
// MAIN PROGRAM
//===========================================================================
/* Go... */
$reg = ipsRegistry::instance();
$reg->init();
$INFO = array();
$ssi = new ssi( $reg );
//--------------------------------
// Load our classes
//--------------------------------
require_once ROOT_PATH . "sources/ipsclass.php";
require_once ROOT_PATH . "sources/classes/class_forums.php";
require_once ROOT_PATH . "sources/classes/class_session.php";
require_once KERNEL_PATH . "class_converge.php";
require_once ROOT_PATH . "conf_global.php";
# Initiate super-class
$ipsclass = new ipsclass();
$ipsclass->vars = $INFO;
//--------------------------------
// The clocks a' tickin'
//--------------------------------
$Debug = new Debug;
$Debug->startTimer();
//--------------------------------
// Load the DB driver and such
//--------------------------------
$ipsclass->init_db_connection();
//--------------------------------
// INIT other classes
//--------------------------------
$ipsclass->sess = new session();
$ipsclass->sess->ipsclass =& $ipsclass;
$ipsclass->forums = new forum_functions();
$ipsclass->forums->ipsclass =& $ipsclass;
//--------------------------------
// Set up our vars
//--------------------------------
$ipsclass->parse_incoming();
//--------------------------------
// Set converge
//--------------------------------
$ipsclass->converge = new class_converge( $ipsclass->DB );
//--------------------------------
// Start off the cache array
//--------------------------------
$ipsclass->cache_array = array_merge( array('attachtypes','bbcode', 'multimod','ranks','profilefields'), array('rss_calendar', 'rss_export','components','banfilters', 'settings', 'group_cache', 'systemvars', 'skin_id_cache', 'forum_cache', 'moderators', 'stats', 'languages') );
//===========================================================================
// Get cache...
//===========================================================================
$ipsclass->init_cache_setup();
$ipsclass->init_load_cache( $ipsclass->cache_array );
//--------------------------------
// Set debug mode
//--------------------------------
$ipsclass->DB->set_debug_mode( $ipsclass->vars['sql_debug'] == 1 ? intval($_GET['debug']) : 0 );
//--------------------------------
// Initialize the FUNC
//--------------------------------
$ipsclass->initiate_ipsclass();
//--------------------------------
// Initialize the member info
//--------------------------------
$ipsclass->member = $ipsclass->sess->authorise();
//-----------------------------------------
// Cache md5 check
//-----------------------------------------
$ipsclass->md5_check = $ipsclass->return_md5_check();
//--------------------------------
// Initialize the forums
//--------------------------------
$ipsclass->forums->strip_invisible = 1;
$ipsclass->forums->forums_init();
//--------------------------------
// Load the skin
//--------------------------------
$ipsclass->load_skin();
//--------------------------------
// Set the base URL
//--------------------------------
$ipsclass->base_url = $ipsclass->vars['board_url'].'/index.'.$ipsclass->vars['php_ext'];
//--------------------------------
// INIT class and pass...
//--------------------------------
$runme = new ssi_autorun();
$runme->ipsclass =& $ipsclass;
$runme->auto_run();
/**
* Auto run class
*/
class ssi_autorun
class ssi
{
/**
* Auto run function
*/
function auto_run()
function __construct( ipsRegistry $registry )
{
//--------------------------------
// What to do?
//--------------------------------
$this->registry = $registry;
$this->DB = $this->registry->DB();
$this->settings =& $this->registry->fetchSettings();
$this->request =& $this->registry->fetchRequest();
$this->cache = $this->registry->cache();
$this->caches =& $this->registry->cache()->fetchCaches();
$this->member = $this->registry->member();
$this->memberData =& $this->registry->member()->fetchMemberData();
switch ($this->ipsclass->input['a'])
/* Load forums class */
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('forums') . '/sources/classes/forums/class_forums.php', 'class_forums', 'forums' );
$this->registry->setClass( 'class_forums', new $classToLoad( $registry ) );
$this->registry->class_forums->forumsInit();
switch ($this->request['a'])
{
case 'news':
$this->do_news();
break;
case 'active':
$this->do_active();
$this->_doActive();
break;
case 'stats':
$this->do_stats();
$this->_doStats();
break;
case 'out':
if ( SSI_ALLOW_SYND == 1 )
{
$this->do_syndication();
$this->_doSyndication();
}
else
{
@@ -261,18 +138,20 @@ class ssi_autorun
break;
default:
echo("An error occured whilst processing this directive");
echo("An error occurred whilst processing this directive");
exit();
break;
}
}
/**
* Do Syndication
*
* Export topics / titles from selected forums
*
* @access protected
*/
function do_syndication()
protected function _doSyndication()
{
//----------------------------------------
// Sort out the forum ids
@@ -281,9 +160,9 @@ class ssi_autorun
$tmp_forums = array();
$forums = array();
if ( $this->ipsclass->input['f'] )
if ( $this->request['f'] )
{
$tmp_forums = explode( ",", $this->ipsclass->input['f'] );
$tmp_forums = explode( ",", $this->request['f'] );
}
else
{
@@ -319,7 +198,7 @@ class ssi_autorun
// Number of topics to return?
//----------------------------------------
$perpage = intval($this->ipsclass->input['show']) ? intval($this->ipsclass->input['show']) : 10;
$perpage = intval($this->request['show']) ? intval($this->request['show']) : 10;
$perpage = ( $perpage > SSI_MAX_SHOW ) ? SSI_MAX_SHOW : $perpage;
@@ -327,13 +206,13 @@ class ssi_autorun
// Load the template...
//----------------------------------------
if ( $this->ipsclass->input['type'] == 'xml' )
if ( $this->request['type'] == 'xml' )
{
$template = $this->load_template("syndicate_xml.html");
$template = $this->_loadTemplate("syndicate_xml.html");
}
else
{
$template = $this->load_template("syndicate_rss.html");
$template = $this->_loadTemplate("syndicate_rss.html");
}
//----------------------------------------
@@ -361,71 +240,65 @@ class ssi_autorun
// Header parse...
//----------------------------------------
@header("Content-Type: text/xml;charset={$this->ipsclass->vars['gb_char_set']}");
@header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
@header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
@header('Pragma: public');
//@header("Content-Type: text/xml;charset={$this->settings['gb_char_set']}");
//@header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
//@header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
//@header('Pragma: public');
$to_echo .= $this->parse_template( $top, array (
'board_url' => $this->ipsclass->base_url ,
'board_name' => $this->ipsclass->vars['board_name'],
) );
$to_echo .= $this->_parseTemplate( $top, array ( 'board_url' => $this->settings['base_url'] ,
'board_name' => $this->settings['board_name'] ) );
//----------------------------------------
// Fix up
//----------------------------------------
$group = $this->ipsclass->cache['group_cache'][ $this->ipsclass->vars['guest_group'] ];
$this->ipsclass->perm_id_array = explode( ",", $group['g_perm_id'] );
$group = $this->caches['group_cache'][ $this->settings['guest_group'] ];
//----------------------------------------
// Get the topics, member info and other stuff
//----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
$this->DB->build( array( 'select' => '*',
'from' => 'topics',
'where' => "forum_id IN ($sql_fields) AND approved=1",
'where' => "forum_id IN ($sql_fields) AND " . $this->registry->getClass('class_forums')->fetchTopicHiddenQuery( array( 'visible' ), '' ),
'order' => 'last_post DESC',
'limit' => array( 0, $perpage ) ) );
$this->ipsclass->DB->simple_exec();
$this->DB->execute();
if ( ! $this->ipsclass->DB->get_num_rows() )
if ( ! $this->DB->getTotalRows() )
{
fatal_error("Could not get the information from the database");
}
while ( $i = $this->ipsclass->DB->fetch_row() )
while ( $i = $this->DB->fetch() )
{
$forum = $this->ipsclass->forums->forum_by_id[ $i['forum_id'] ];
$forum = $this->registry->class_forums->forum_by_id[ $i['forum_id'] ];
if ( $this->ipsclass->check_perms( $forum['read_perms'] ) != TRUE )
if ( $this->registry->permissions->check( 'read', $forum ) != TRUE )
{
continue;
}
if ( $forum['password'] != "" )
{
continue;
}
if ($forum['password'] != "" )
{
continue;
}
$to_echo .= $this->parse_template( $row, array (
'topic_title' => str_replace( '&#', '&amp;#', $i['title'] ),
$to_echo .= $this->_parseTemplate( $row, array ( 'topic_title' => str_replace( '&#', '&amp;#', $i['title'] ),
'topic_id' => $i['tid'],
'topic_link' => $this->ipsclass->base_url."?showtopic=".$i['tid'],
'topic_link' => $this->settings['base_url']."showtopic=".$i['tid'],
'forum_title' => htmlspecialchars($forum['name']),
'forum_id' => $i['forum_id'],
'last_poster_id' => $i['last_poster_id'],
'last_post_name' => $i['last_poster_name'],
'last_post_time' => $this->ipsclass->get_date( $i['last_post'] , 'LONG', 1 ),
'last_post_time' => $this->registry->getClass('class_localization')->getDate( $i['last_post'] , 'LONG', 1 ),
'timestamp' => $i['last_post'],
'starter_id' => $i['starter_id'],
'starter_name' => $i['starter_name'],
'board_url' => $this->ipsclass->base_url ,
'board_name' => $this->ipsclass->vars['board_name'],
'rfc_date' => date( 'r', $i['last_post'] ),
) ) . "\r\n";
'board_url' => $this->settings['board_url'] ,
'board_name' => $this->settings['board_name'],
'rfc_date' => date( 'r', $i['last_post'] ) ) ) . "\r\n";
}
//----------------------------------------
@@ -443,13 +316,13 @@ class ssi_autorun
*
* Show totals
*/
function do_stats()
function _doStats()
{
//----------------------------------------
// Load the template...
//----------------------------------------
$template = $this->load_template("stats.html");
$template = $this->_loadTemplate("stats.html");
//----------------------------------------
// INIT
@@ -458,140 +331,29 @@ class ssi_autorun
$to_echo = "";
$time = time() - 900;
//----------------------------------------
// Make sure we've got something
//----------------------------------------
if ( ! is_array( $this->ipsclass->cache['stats'] ) )
{
$this->ipsclass->cache['stats'] = array();
$this->ipsclass->update_cache( array( 'name' => 'stats', 'array' => 1, 'deletefirst' => 1 ) );
}
$stats = $this->ipsclass->cache['stats'];
$total_posts = $stats['total_replies']+$stats['total_topics'];
$to_echo = $this->parse_template( $template,
array (
'total_posts' => $total_posts,
$stats = $this->caches['stats'];
$total_posts = $stats['total_replies'] + $stats['total_topics'];
$to_echo = $this->_parseTemplate( $template, array( 'total_posts' => $total_posts,
'topics' => $stats['total_topics'],
'replies' => $stats['total_replies'],
'members' => $stats['mem_count']
)
);
'members' => $stats['mem_count'] ) );
echo $to_echo;
exit();
}
/**
* Do News
*
* Show news text
*/
function do_news()
{
//----------------------------------------
// Check
//----------------------------------------
if ( (! $this->ipsclass->vars['news_forum_id']) or ($this->ipsclass->vars['news_forum_id'] == "" ) )
{
fatal_error("No news forum assigned");
}
//----------------------------------------
// INIT
//----------------------------------------
$perpage = intval($this->ipsclass->input['show']) > 0 ? intval($this->ipsclass->input['show']) : 10;
$perpage = ( $perpage > SSI_MAX_SHOW ) ? SSI_MAX_SHOW : $perpage;
$to_echo = "";
//-----------------------------------------
// Load the template...
//-----------------------------------------
$template = $this->load_template("news.html");
//-----------------------------------------
// Get the topics, member info and other stuff
//-----------------------------------------
$this->ipsclass->DB->build_query( array( 'select' => 't.*',
'from' => array( 'topics' => 't' ),
'where' => "t.forum_id={$this->ipsclass->vars['news_forum_id']} AND t.approved=1",
'order' => 't.tid DESC',
'limit' => array( 0, $perpage ),
'add_join' => array( 0 => array( 'select' => 'm.members_display_name as member_name, m.mgroup, m.id as member_id,m.title as member_title',
'from' => array( 'members' => 'm' ),
'where' => "m.id=t.starter_id",
'type' => 'left' ),
1 => array( 'select' => 'p.*',
'from' => array( 'posts' => 'p' ),
'where' => "t.topic_firstpost=p.pid",
'type' => 'left' ) )
) );
$this->ipsclass->DB->exec_query();
while ( $row = $this->ipsclass->DB->fetch_row() )
{
$row['member_name'] = $row['member_name'] ? $row['member_name'] : $row['author_name'];
$to_echo .= $this->parse_template( $template,
array (
'profile_link' => $this->ipsclass->base_url."?showuser=".intval($row['member_id']),
'member_name' => $row['member_name'],
'post_date' => $this->ipsclass->get_date( $row['post_date'], 'LONG', 1 ),
'topic_title' => $row['title'],
'post' => $row['post'],
'comments' => $row['posts'],
'view_all_link' => $this->ipsclass->base_url."?showtopic={$row['tid']}"
)
);
}
//-----------------------------------------
// Get the macros and replace them
//-----------------------------------------
if ( is_array( $this->ipsclass->skin['_macros'] ) )
{
foreach( $this->ipsclass->skin['_macros'] as $row )
{
if ( $row['macro_value'] != "" )
{
$to_echo = str_replace( "<{".$row['macro_value']."}>", $row['macro_replace'], $to_echo );
}
}
}
$to_echo = preg_replace( "#([^/])style_images/(<\#IMG_DIR\#>|".preg_quote($this->ipsclass->skin['_imagedir'], '/').")#is", "\\1".$this->ipsclass->vars['board_url']."/style_images/\\2", $to_echo );
$to_echo = preg_replace( "#([^/])style_emoticons#is", "\\1".$this->ipsclass->vars['board_url']."/style_emoticons", $to_echo );
$to_echo = preg_replace( "#([^/])style_avatars#is" , "\\1".$this->ipsclass->vars['board_url']."/style_avatars", $to_echo );
$to_echo = preg_replace( "#([^/])jscripts#is" , "\\1".$this->ipsclass->vars['board_url']."/jscripts", $to_echo );
$to_echo = str_replace( "<#IMG_DIR#>", $this->ipsclass->skin['_imagedir'], $to_echo );
$to_echo = str_replace( "<#EMO_DIR#>", $this->ipsclass->skin['_emodir'] , $to_echo );
echo $to_echo;
exit();
}
/**
* Do Active
*
* Show active users
*/
function do_active()
function _doActive()
{
//--------------------------------
// Load the template...
//--------------------------------
$template = $this->load_template("active.html");
$template = $this->_loadTemplate("active.html");
//--------------------------------
// INIT
@@ -603,43 +365,42 @@ class ssi_autorun
// Make sure we have a cut off...
//--------------------------------
if ($this->ipsclass->vars['au_cutoff'] == "")
if ($this->settings['au_cutoff'] == "")
{
$this->ipsclass->vars['au_cutoff'] = 15;
$this->settings['au_cutoff'] = 15;
}
//-----------------------------------------
// Get the users from the DB
//-----------------------------------------
$cut_off = $this->ipsclass->vars['au_cutoff'] * 60;
$cut_off = $this->settings['au_cutoff'] * 60;
$time = time() - $cut_off;
$rows = array();
$ar_time = time();
if ( $this->ipsclass->member['id'] )
if ( $this->memberData['member_id'] )
{
$rows = array( $ar_time => array( 'login_type' => substr($this->ipsclass->member['login_anonymous'],0, 1),
$rows = array( $ar_time => array( 'login_type' => IPSMember::isLoggedInAnon( $this->memberData ),
'running_time' => $ar_time,
'member_id' => $this->ipsclass->member['id'],
'member_name' => $this->ipsclass->member['members_display_name'],
'member_group' => $this->ipsclass->member['mgroup'] ) );
'member_id' => $this->memberData['member_id'],
'member_name' => $this->memberData['members_display_name'],
'member_group' => $this->memberData['member_group_id'] ) );
}
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, member_id, member_name, login_type, running_time, member_group',
'from' => 'sessions',
'where' => "running_time > $time",
//'order' => "running_time DESC" // Sort in PHP to avoid filesort in SQL
) );
$this->DB->build( array( 'select' => 'id, member_id, member_name, login_type, running_time, member_group',
'from' => 'sessions',
'where' => "running_time > $time",
) );
$this->ipsclass->DB->simple_exec();
$this->DB->execute();
//-----------------------------------------
// FETCH...
//-----------------------------------------
while ( $r = $this->ipsclass->DB->fetch_row() )
while ( $r = $this->DB->fetch() )
{
$rows[ $r['running_time'].'.'.$r['id'] ] = $r;
}
@@ -656,8 +417,6 @@ class ssi_autorun
foreach( $rows as $result )
{
$last_date = $this->ipsclass->get_time( $result['running_time'] );
//-----------------------------------------
// Bot?
//-----------------------------------------
@@ -703,7 +462,10 @@ class ssi_autorun
{
$cached[ $result['member_id'] ] = 1;
if ($result['login_type'])
/* Reset login type in case the board/group setting got changed */
$result['login_type'] = IPSMember::isLoggedInAnon( array( 'login_anonymous' => $result['login_type'] ), $result['member_group'] );
if ( $result['login_type'] )
{
$active['ANON']++;
}
@@ -717,15 +479,10 @@ class ssi_autorun
$active['TOTAL'] = $active['MEMBERS'] + $active['GUESTS'] + $active['ANON'];
$to_echo = $this->parse_template( $template,
array (
'total' => $active['TOTAL'] ? $active['TOTAL'] : 0 ,
$to_echo = $this->_parseTemplate( $template, array ( 'total' => $active['TOTAL'] ? $active['TOTAL'] : 0 ,
'members' => $active['MEMBERS'] ? $active['MEMBERS'] : 0,
'guests' => $active['GUESTS'] ? $active['GUESTS'] : 0,
'anon' => $active['ANON'] ? $active['ANON'] : 0,
)
);
'anon' => $active['ANON'] ? $active['ANON'] : 0 ) );
echo $to_echo;
@@ -738,27 +495,36 @@ class ssi_autorun
* Parse template
*
* Parses the template. Duh.
*
* @access protected
* @param string Template data
* @param array Array of data
*/
function parse_template( $template, $assigned=array() )
protected function _parseTemplate( $template, $assigned=array() )
{
foreach( $assigned as $word => $replace)
{
$template = preg_replace( "/\{$word\}/i", "$replace", $template );
}
return $template;
$template = str_replace( '/ssi.php', '/index.php', $template );
return $this->registry->output->replaceMacros( $template );
}
/**
* Load template
*
* Loads the template
*
* @access protected
* @param string Template to load
*/
function load_template($template="")
protected function _loadTemplate($template="")
{
$filename = SSI_TEMPLATES_DIR."/".$template;
if ( file_exists($filename) )
if ( is_file($filename) )
{
if ( $FH = fopen($filename, 'r') )
{
@@ -777,6 +543,10 @@ class ssi_autorun
return $template;
}
}
?>
function fatal_error( $error )
{
print $error;
exit();
}