📄 topics.php
字号:
<?php
class topics
{
var $output = "";
var $base_url = "";
var $html = "";
var $moderator = array( );
var $forum = array( );
var $topic = array( );
var $category = array( );
var $mem_titles = array( );
var $mod_action = array( );
var $poll_html = "";
var $colspan = 0;
var $parser = "";
var $mimetypes = "";
var $nav_extra = "";
var $read_array = array( );
var $mod_panel_html = "";
function topics( )
{
global $ibforums;
global $DB;
global $std;
global $print;
global $skin_universal;
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_topic", $ibforums->lang_id );
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_rpg", $ibforums->lang_id );
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_post", $ibforums->lang_id );
$this->html = $std->load_template( "skin_topic" );
require( "./sources/lib/post_parser.php" );
$this->parser = new post_parser( );
$ibforums->input['t'] = $std->is_number( $ibforums->input['t'] );
$ibforums->input['f'] = $std->is_number( $ibforums->input['f'] );
if ( $ibforums->input['t'] < 0 || $ibforums->input['f'] < 0 )
{
$std->error( array( 1, "missing_files" ) );
}
$DB->query( "SELECT t.*, f.name as forum_name, f.id as forum_id, f.read_perms, f.reply_perms, f.parent_id, f.start_perms, f.allow_poll, f.password, f.posts as forum_posts, f.topics as forum_topics, f.upload_perms, c.name as cat_name, c.id as cat_id FROM ibf_topics t, ibf_forums f , ibf_categories c where t.tid='".$ibforums->input[t]."' and f.id = t.forum_id and f.category=c.id" );
$this->topic = $DB->fetch_row( );
$this->forum = array(
"id" => $this->topic['forum_id'],
"name" => $this->topic['forum_name'],
"posts" => $this->topic['forum_posts'],
"topics" => $this->topic['forum_topics'],
"read_perms" => $this->topic['read_perms'],
"allow_poll" => $this->topic['allow_poll'],
"upload_perms" => $this->topic['upload_perms'],
"parent_id" => $this->topic['parent_id'],
"password" => $this->topic['password']
);
$this->category = array(
"name" => $this->topic['cat_name'],
"id" => $this->topic['cat_id']
);
if ( !$this->forum['id'] )
{
$std->error( array( 1, "missing_files" ) );
}
if ( !$this->topic['tid'] )
{
$std->error( array( 1, "missing_files" ) );
}
if ( $this->topic['approved'] != 1 )
{
$std->error( array( 1, "missing_files" ) );
}
if ( $this->topic['state'] == "link" )
{
$f_stuff = explode( "&", $this->topic['moved_to'] );
$print->redirect_screen( $ibforums->lang['topic_moved'], "act=ST&f={$f_stuff[1]}&t={$f_stuff[0]}" );
}
if ( $read = $std->my_getcookie( "topicsread" ) )
{
$this->read_array = unserialize( stripslashes( $read ) );
if ( !is_array( $this->read_array ) )
{
$this->read_array = array( );
}
}
if ( isset( $ibforums->input['view'] ) )
{
if ( $ibforums->input['view'] == "new" )
{
$DB->query( "SELECT * from ibf_topics WHERE forum_id='".$this->forum['id']."' AND approved=1 AND state <> 'link' AND last_post > ".$this->topic['last_post']." "."ORDER BY last_post ASC LIMIT 0,1" );
if ( $DB->get_num_rows( ) )
{
$this->topic = $DB->fetch_row( );
$std->boink_it( $ibforums->base_url."&act=ST&f=".$this->topic['forum_id']."&t=".$this->topic['tid'] );
}
else
{
$std->error( array( 1, "no_newer" ) );
}
}
else if ( $ibforums->input['view'] == "old" )
{
$DB->query( "SELECT * from ibf_topics WHERE forum_id='".$this->forum['id']."' AND approved=1 AND state <> 'link' AND last_post < ".$this->topic['last_post']." "."ORDER BY last_post DESC LIMIT 0,1" );
if ( $DB->get_num_rows( ) )
{
$this->topic = $DB->fetch_row( );
$std->boink_it( $ibforums->base_url."&act=ST&f=".$this->topic['forum_id']."&t=".$this->topic['tid'] );
}
else
{
$std->error( array( 1, "no_older" ) );
}
}
else if ( $ibforums->input['view'] == "getlastpost" )
{
$this->return_last_post( );
}
else if ( $ibforums->input['view'] == "getnewpost" )
{
$st = 0;
$pid = "";
$last_time = isset( $this->read_array[$this->topic['tid']] ) ? $this->read_array[$this->topic['tid']] : $ibforums->input['last_visit'];
$DB->query( "SELECT pid, post_date FROM ibf_posts WHERE queued <> 1 AND topic_id='".$this->topic['tid']."' AND post_date > '".$last_time."' ORDER BY post_date LIMIT 1" );
if ( $post = $DB->fetch_row( ) )
{
$pid = "&#entry".$post['pid'];
$DB->query( "SELECT COUNT(pid) as posts FROM ibf_posts WHERE topic_id='".$this->topic['tid']."' AND pid <= '".$post['pid']."'" );
$cposts = $DB->fetch_row( );
if ( $cposts['posts'] % $ibforums->vars['display_max_posts'] == 0 )
{
$pages = $cposts['posts'] / $ibforums->vars['display_max_posts'];
}
else
{
$number = $cposts['posts'] / $ibforums->vars['display_max_posts'];
$pages = ceil( $number );
}
$st = ( $pages - 1 ) * $ibforums->vars['display_max_posts'];
$std->boink_it( $ibforums->base_url."&act=ST&f=".$this->topic['forum_id']."&t=".$this->topic['tid']."&st={$st}".$pid );
exit( );
}
else
{
$this->return_last_post( );
}
}
else if ( $ibforums->input['view'] == "findpost" )
{
$pid = intval( $ibforums->input['p'] );
if ( 0 < $pid )
{
$DB->query( "SELECT COUNT(pid) as posts FROM ibf_posts WHERE topic_id='".$this->topic['tid']."' AND pid <= '".$pid."'" );
$cposts = $DB->fetch_row( );
if ( $cposts['posts'] % $ibforums->vars['display_max_posts'] == 0 )
{
$pages = $cposts['posts'] / $ibforums->vars['display_max_posts'];
}
else
{
$number = $cposts['posts'] / $ibforums->vars['display_max_posts'];
$pages = ceil( $number );
}
$st = ( $pages - 1 ) * $ibforums->vars['display_max_posts'];
$std->boink_it( $ibforums->base_url."&act=ST&f=".$this->topic['forum_id']."&t=".$this->topic['tid']."&st={$st}"."&#entry".$pid );
exit( );
}
else
{
$this->return_last_post( );
}
}
}
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->forum['JUMP'] = $std->build_forum_jump( );
$this->forum['JUMP'] = preg_replace( "!#Forum Jump#!", $ibforums->lang['forum_jump'], $this->forum['JUMP'] );
if ( !$this->topic['pinned'] && !$ibforums->member['g_other_topics'] )
{
$std->error( array( 1, "no_view_topic" ) );
}
$bad_entry = $this->check_access( );
if ( $bad_entry == 1 )
{
$std->error( array( 1, "no_view_topic" ) );
}
$DB->query( "UPDATE ibf_topics SET views=views+1 WHERE tid='".$this->topic['tid']."'" );
if ( $ibforums->member['id'] )
{
$this->read_array[$this->topic['tid']] = time( );
$std->my_setcookie( "topicsread", serialize( $this->read_array ), -1 );
}
if ( 0 < $this->forum['parent_id'] )
{
$DB->query( "SELECT f.id as forum_id, f.name as forum_name, c.id, c.name FROM ibf_forums f, ibf_categories c WHERE f.id='".$this->forum['parent_id']."' AND c.id=f.category" );
$row = $DB->fetch_row( );
$this->category['id'] = $row['id'];
$this->category['name'] = $row['name'];
$this->nav_extra = "<a href='".$this->base_url."&act=SF&f={$row['forum_id']}'>{$row['forum_name']}</a>";
}
$DB->query( "SELECT id, title, pips, posts from ibf_titles ORDER BY posts DESC" );
while ( $i = $DB->fetch_row( ) )
{
$this->mem_titles[$i['id']] = array(
"TITLE" => $i['title'],
"PIPS" => $i['pips'],
"POSTS" => $i['posts']
);
}
if ( $ibforums->member['id'] && $ibforums->member['g_is_supmod'] != 1 )
{
$DB->query( "SELECT * FROM ibf_moderators WHERE forum_id='".$this->forum['id']."' AND (member_id='".$ibforums->member['id']."' OR (is_group=1 AND group_id='".$ibforums->member['mgroup']."'))" );
$this->moderator = $DB->fetch_row( );
}
$this->mod_action = array( "CLOSE_TOPIC" => "00", "OPEN_TOPIC" => "01", "MOVE_TOPIC" => "02", "DELETE_TOPIC" => "03", "EDIT_TOPIC" => "05", "PIN_TOPIC" => "15", "UNPIN_TOPIC" => "16", "UNSUBBIT" => "30", "SPLIT_TOPIC" => "50", "MERGE_TOPIC" => "60", "TOPIC_HISTORY" => "90" );
$this->topic['POLL_BUTTON'] = $this->forum['allow_poll'] ? "<a href='".$this->base_url."&act=Post&CODE=10&f=".$this->forum['id']."'><{A_POLL}></a>" : "";
$this->topic['REPLY_BUTTON'] = $this->reply_button( );
if ( $ibforums->input['hl'] )
{
$hl = "&hl=".$ibforums->input['hl'];
}
$this->topic['SHOW_PAGES'] = $std->build_pagelinks( array(
"TOTAL_POSS" => $this->topic['posts'] + 1,
"PER_PAGE" => $ibforums->vars[display_max_posts],
"CUR_ST_VAL" => $ibforums->input['st'],
"L_SINGLE" => "",
"L_MULTI" => $ibforums->lang['multi_page_topic'],
"BASE_URL" => $this->base_url."&act=ST&f=".$this->forum['id']."&t=".$this->topic['tid'].$hl
) );
if ( $ibforums->vars['display_max_posts'] < $this->topic['posts'] + 1 )
{
$this->topic['go_new'] = $this->html->golastpost_link( $this->forum['id'], $this->topic['tid'] );
}
$this->topic['TOPIC_START_DATE'] = $std->get_date( $this->topic['start_date'], "LONG" );
$off_text = $ibforums->vars['off_status_color'];
$on_text = $ibforums->vars['on_status_color'];
$off_image = $ibforums->vars['off_status_image'];
$on_image = $ibforums->vars['on_status_image'];
$img_dir = $ibforums->vars['img_url'];
$ibforums->lang['M_On_T'] = preg_replace( "/<#ON_COLOR#>/", $on_text, $ibforums->lang['M_On_T'] );
$ibforums->lang['M_Off_T'] = preg_replace( "/<#OFF_COLOR#>/", $off_text, $ibforums->lang['M_Off_T'] );
$ibforums->lang['M_On_I'] = preg_replace( "/<#ON_IMAGE#>/", $img_dir.$on_image, $ibforums->lang['M_On_I'] );
$ibforums->lang['M_Off_I'] = preg_replace( "/<#OFF_IMAGE#>/", $img_dir.$off_image, $ibforums->lang['M_Off_I'] );
$ibforums->lang['topic_stats'] = preg_replace( "/<#START#>/", $this->topic['TOPIC_START_DATE'], $ibforums->lang['topic_stats'] );
$ibforums->lang['topic_stats'] = preg_replace( "/<#POSTS#>/", $this->topic['posts'], $ibforums->lang['topic_stats'] );
if ( $this->topic['description'] )
{
$this->topic['description'] = ", ".$this->topic['description'];
}
$this->output .= $this->html->pagetop( array(
"TOPIC" => $this->topic,
"FORUM" => $this->forum
) );
if ( $this->topic['poll_state'] )
{
$this->output = str_replace( "<!--{IBF.POLL}-->", $this->parse_poll( ), $this->output );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -