<?php
include "../core.php";
$topicid = intval( $_REQUEST['topicid'] );
if ( empty( $topicid ) ) {
		include SAXUE_WEB_PATH . "/404.php";
}
if ( empty( $_REQUEST['page'] ) || !is_numeric( $_REQUEST['page'] ) ) $GLOBALS['_REQUEST']['page'] = 1;
$page = intval( $_REQUEST['page'] );
include SAXUE_WEB_PATH . "/header.php";
$saxueTset['saxue_page_template']['cache_file'] = SAXUE_THEME_PATH . '/topic/detail.' . $page . '.tpl';
$saxueTset['saxue_page_cacheid'] = $topicid;
if ( SAXUE_USE_CACHE ) {
		$saxueTpl -> setcaching( 1 );
} else {
		$saxueTpl -> setcaching( 0 );
} 
if ( !SAXUE_USE_CACHE || !$saxueTpl -> is_cached( $saxueTset['saxue_page_template']['cache_file'], $saxueTset['saxue_page_cacheid'] ) ) {
		include SAXUE_ROOT_PATH . "/common/packtopic.php";
		$packtopic = new saxuepacktopic( $topicid );
		if ( !$packtopic -> loadtopic() ) {
				include SAXUE_WEB_PATH . "/404.php";
		}
		$packtopic -> showtopic( $page );
		$saxueTset['saxue_page_template']['tpl_file'] = $packtopic -> gettemplate();
}
include SAXUE_ROOT_PATH . "/common/funstat.php";
saxue_visit_stat( $topicid, 'topic', 'views', 'topicid' );
include SAXUE_WEB_PATH . "/footer.php";