HEX
Server: Apache/2.4.59 (Debian)
System: Linux skycube.cz 4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08) x86_64
User: ilya (534)
PHP: 7.3.31-1~deb10u7
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/ilya/data/www/kamforum.ru/sources/api/api_topic_view.php
<?php

/*
+--------------------------------------------------------------------------
|   Invision Power Board v2.1.5
|   =============================================
|   by Matthew Mecham
|   (c) 2001 - 2005 Invision Power Services, Inc.
|   http://www.invisionpower.com
|   =============================================
|   Web: http://www.invisionboard.com
|   Time: Wed, 04 Jan 2006 19:53:17 GMT
|   Release: 2d174325a5cb8288fdab03b953f0e659
|   Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|   > $Date: 2005-10-10 14:08:54 +0100 (Mon, 10 Oct 2005) $
|   > $Revision: 23 $
|   > $Author: matt $
+---------------------------------------------------------------------------
|
|   > API: Languages
|   > Module written by Matt Mecham
|   > Date started: Wednesday 30th November 2005 (11:40)
|
+--------------------------------------------------------------------------
*/

/**
* API: Forums
*
* EXAMPLE USAGE
* <code>
* To follow
* </code>
*
* @package		InvisionPowerBoard
* @subpackage	APIs
* @author		Matt Mecham
* @copyright	Invision Power Services, Inc.
* @version		2.1
*/

if ( ! defined( 'IPS_API_PATH' ) )
{
	/**
	* Define classes path
	*/
	define( 'IPS_API_PATH', dirname(__FILE__) ? dirname(__FILE__) : '.' );
}

if ( ! class_exists( 'api_core' ) )
{
	require_once( IPS_API_PATH.'/api_core.php' );
}

/**
* API: Languages
*
* This class deals with all available language functions.
*
* @package		InvisionPowerBoard
* @subpackage	APIs
* @author  	 	Matt Mecham
* @version		2.1
* @since		2.1.0
*/
class api_topic_view extends api_core
{
	/**
	* IPS Class Object
	*
	* @var object
	*/
	//var $ipsclass;
	
	/**
	* Topic list config
	*
	* @var array
	*/
	var $topic_list_config = array( 'offset'      => 0,
								    'limit'       => 5,
									'forums'      => 1,
									'order_field' => 'last_post',
									'order_by'    => 'DESC' );
									
	/*-------------------------------------------------------------------------*/
	// Returns an array of topic data
	/*-------------------------------------------------------------------------*/
	/**
	* Returns an array of topic data
	* NOTE: Returns ALL topics regardless of permission as
	* if viewed from the ACP.
	*
	* @return   array	Array of topic data
	*/
	function return_topic_list_data()
	{
		//-----------------------------------------
		// INIT
		//-----------------------------------------
		
		$topics = array();
		
		//-----------------------------------------
		// Load parser
		//-----------------------------------------
		
		require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );
        $parser                      =  new parse_bbcode();
        $parser->ipsclass            =& $this->ipsclass;
        $parser->allow_update_caches = 0;
        $parser->bypass_badwords     = 0;
		
		//-----------------------------------------
		// Set up
		//-----------------------------------------

		$this->topic_list_config['order_field'] = ( $this->topic_list_config['order_field'] == 'started' )  ? 'start_date' : $this->topic_list_config['order_field'];
		$this->topic_list_config['order_field'] = ( $this->topic_list_config['order_field'] == 'lastpost' ) ? 'last_post'  : $this->topic_list_config['order_field'];
		$this->topic_list_config['forums']      = ( is_array( $this->topic_list_config['forums'] ) ) ? implode( ",", $this->topic_list_config['forums'] ) : $this->topic_list_config['forums'];
		
		//-----------------------------------------
		// Get from the DB
		//-----------------------------------------
		
		$this->ipsclass->DB->build_query( array( 'select'   => 't.*',
												 'from'     => array( 'topics' => 't' ),
												 'where'    => 't.approved=1 AND t.forum_id IN (0,'.$this->topic_list_config['forums'].')',
											     'order'    => $this->topic_list_config['order_field'].' '.$this->topic_list_config['order_by'],
												 'limit'    => array( $this->topic_list_config['offset'], $this->topic_list_config['limit'] ),
												 'add_join' => array( 
																	  0 => array( 'select' => 'p.*',
																				  'from'   => array( 'posts' => 'p' ),
																				  'where'  => 't.topic_firstpost=p.pid',
																				  'type'   => 'left' ),
																	  1 => array( 'select' => 'm.id as member_id, m.members_display_name as member_name, m.mgroup, m.email',
																	  			  'from'   => array( 'members' => 'm' ),
																				  'where'  => "m.id=p.author_id",
																				  'type'   => 'left' ),
																	  2 => array( 'select' => 'f.id as forum_id, f.name as forum_name, f.use_html',
																	  			  'from'   => array( 'forums' => 'f' ),
																				  'where'  => "t.forum_id=f.id",
																				  'type'   => 'left' ) )
										)      );
		
		$this->ipsclass->DB->exec_query();
		
		while( $row = $this->ipsclass->DB->fetch_row() )
		{
			//-----------------------------------------
			// Format posts
			//-----------------------------------------

			$parser->parse_html     = ( $row['use_html'] AND $row['post_htmlstate'] ) ? 1 : 0;
			$parser->parse_wordwrap = $this->ipsclass->vars['post_wordwrap'];
			$parser->parse_nl2br    = $row['post_htmlstate'] == 2 ? 1 : 0;
			
			$row['post'] = $parser->pre_display_parse( $row['post'] );
			
			//-----------------------------------------
			// Guest name?
			//-----------------------------------------
			
			$row['member_name']    = $row['member_name'] ? $row['member_name'] : $row['author_name'];
			
			//-----------------------------------------
			// Topic link
			//-----------------------------------------
			
			$row['link-topic'] = $this->ipsclass->base_url.'showtopic='.$row['tid'];
			$row['link-forum'] = $this->ipsclass->base_url.'showforum='.$row['forum_id'];
			
			$topics[] = $row;
		}
	
		//-----------------------------------------
		// Return...
		//-----------------------------------------
		
		return $topics;
	}
	
	
	
	
	
	
	
	
	
}



?>