📄 post.php
字号:
<?php
class post
{
var $output = "";
var $base_url = "";
var $html = "";
var $parser = "";
var $moderator = array( );
var $forum = array( );
var $topic = array( );
var $category = array( );
var $mem_groups = array( );
var $mem_titles = array( );
var $obj = array( );
var $email = "";
var $can_upload = 0;
function post( )
{
global $ibforums;
global $DB;
global $std;
global $print;
global $skin_universal;
require( "./sources/lib/post_parser.php" );
$this->parser = new post_parser( 1 );
$ibforums->lang = $std->load_words( $ibforums->lang, "lang_post", $ibforums->lang_id );
$this->html = $std->load_template( "skin_post" );
if ( $ibforums->input['t'] )
{
$ibforums->input['t'] = $std->is_number( $ibforums->input['t'] );
if ( !$ibforums->input['t'] )
{
$std->error( array( 1, "missing_files" ) );
}
}
if ( $ibforums->input['p'] )
{
$ibforums->input['p'] = $std->is_number( $ibforums->input['p'] );
if ( !$ibforums->input['p'] )
{
$std->error( array( 1, "missing_files" ) );
}
}
$ibforums->input['f'] = $std->is_number( $ibforums->input['f'] );
if ( !$ibforums->input['f'] )
{
$std->error( array( 1, "missing_files" ) );
}
$ibforums->input['st'] = $ibforums->input['st'] ? $std->is_number( $ibforums->input['st'] ) : 0;
$this->obj['preview_post'] = $ibforums->input['preview'];
$DB->query( "SELECT f.*, c.id as cat_id, c.name as cat_name from ibf_forums f, ibf_categories c WHERE f.id=".$ibforums->input[f]." and c.id=f.category" );
$this->forum = $DB->fetch_row( );
if ( $this->forum['read_perms'] != "*" && !preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $this->forum['read_perms'] ) )
{
$std->error( array( 1, "no_view_topic" ) );
}
if ( $this->forum['upload_perms'] == "*" )
{
$this->can_upload = 1;
}
else if ( preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $this->forum['upload_perms'] ) )
{
$this->can_upload = 1;
}
if ( !$this->forum['status'] )
{
$std->error( array( 1, "forum_read_only" ) );
}
$pass = 0;
if ( $this->forum['password'] != "" )
{
if ( !( $c_pass = $std->my_getcookie( "iBForum".$this->forum['id'] ) ) )
{
$pass = 0;
}
if ( $c_pass == $this->forum['password'] )
{
$pass = 1;
}
else
{
$pass = 0;
}
}
else
{
$pass = 1;
}
if ( $pass == 0 )
{
$std->error( array( 1, "no_view_topic" ) );
}
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->forum['cat_id'] = $row['id'];
$this->forum['cat_name'] = $row['name'];
}
if ( !$this->forum['id'] )
{
$std->error( array( 1, "missing_files" ) );
}
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->obj['moderate'] = $this->forum['preview_posts'] ? 1 : 0;
if ( $ibforums->member['g_avoid_q'] )
{
$this->obj['moderate'] = 0;
}
if ( $ibforums->member['mod_posts'] == 1 )
{
$this->obj['moderate'] = 1;
}
if ( $ibforums->member['id'] )
{
if ( !$ibforums->member['allow_post'] )
{
$std->error( array( 1, "posting_off" ) );
}
if ( $ibforums->input['CODE'] != "08" && $ibforums->input['CODE'] != "09" && 0 < $ibforums->vars['flood_control'] && $ibforums->member['g_avoid_flood'] != 1 && time( ) - $ibforums->member['last_post'] < $ibforums->vars['flood_control'] )
{
$std->error( array(
"LEVEL" => 1,
"MSG" => "flood_control",
"EXTRA" => $ibforums->vars['flood_control']
) );
}
}
if ( $ibforums->member['id'] != 0 && $ibforums->member['g_is_supmod'] == 0 )
{
$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->obj['action_codes'] = array(
"00" => array( "0", "new_post" ),
"01" => array( "1", "new_post" ),
"02" => array( "0", "reply_post" ),
"03" => array( "1", "reply_post" ),
"06" => array( "0", "q_reply_post" ),
"07" => array( "1", "q_reply_post" ),
"08" => array( "0", "edit_post" ),
"09" => array( "1", "edit_post" ),
"10" => array( "0", "poll" ),
"11" => array( "1", "poll" )
);
if ( !isset( $this->obj['action_codes'][$ibforums->input['CODE']] ) )
{
$std->error( array( 1, "missing_files" ) );
}
require( "./sources/lib/post_".$this->obj['action_codes'][$ibforums->input['CODE']][1].".php" );
$post_functions = new post_functions( &$this );
if ( $this->obj['action_codes'][$ibforums->input['CODE']][0] )
{
if ( !$ibforums->member['id'] )
{
$ibforums->input['UserName'] = trim( $ibforums->input['UserName'] );
$ibforums->input['UserName'] = str_replace( "<br>", "", $ibforums->input['UserName'] );
$ibforums->input['UserName'] = $ibforums->input['UserName'] ? $ibforums->input['UserName'] : "Guest";
if ( $ibforums->input['UserName'] != "Guest" )
{
$DB->query( "SELECT id FROM ibf_members WHERE LOWER(name)='".trim( strtolower( $ibforums->input['UserName'] ) )."'" );
if ( $DB->get_num_rows( ) )
{
$ibforums->input['UserName'] = $ibforums->vars['guest_name_pre'].$ibforums->input['UserName'].$ibforums->vars['guest_name_suf'];
}
}
}
if ( $this->obj['preview_post'] == "" && preg_match( "/Post,.*,(01|03|07|11)\$/", $ibforums->location ) && time( ) - $ibforums->lastclick < 2 )
{
if ( $ibforums->input['CODE'] == "01" || $ibforums->input['CODE'] == "11" )
{
$DB->query( "SELECT tid from ibf_topics WHERE forum_id='".$this->forum['id']."' AND approved=1 "."ORDER BY last_post DESC LIMIT 0,1" );
$topic = $DB->fetch_row( );
$std->boink_it( $ibforums->base_url."&act=ST&f=".$this->forum['id']."&t=".$topic['tid'] );
exit( );
}
else
{
$std->boink_it( $ibforums->base_url."&act=ST&f=".$this->forum['id']."&t=".$ibforums->input['t']."&view=getlastpost" );
exit( );
}
}
$post_functions->process( &$this );
}
else
{
$post_functions->show_form( &$this );
}
}
function topic_tracker( $tid = "", $post = "", $poster = "", $last_post = "" )
{
global $ibforums;
global $DB;
global $std;
require( "./sources/lib/emailer.php" );
$this->email = new emailer( );
if ( $tid == "" )
{
return TRUE;
}
$DB->query( "SELECT tr.trid, tr.topic_id, m.name, m.email, m.id, m.email_full, m.language, m.last_activity, t.title, t.forum_id\n\t\t\t\t FROM ibf_tracker tr, ibf_topics t,ibf_members m\n\t\t\t\t WHERE tr.topic_id='{$tid}'\n\t\t\t\t AND tr.member_id=m.id\n\t\t\t\t AND m.id <> '{$ibforums->member['id']}'\n\t\t\t\t AND t.tid=tr.topic_id\n\t\t\t\t AND m.last_activity > '{$last_post}'" );
if ( $DB->get_num_rows( ) )
{
$trids = array( );
while ( $r = $DB->fetch_row( ) )
{
$r['language'] = $r['language'] ? $r['language'] : "en";
if ( $r['email_full'] == 1 )
{
$this->email->get_template( "subs_with_post", $r['language'] );
$this->email->build_message( array(
"TOPIC_ID" => $r['topic_id'],
"FORUM_ID" => $r['forum_id'],
"TITLE" => $r['title'],
"NAME" => $r['name'],
"POSTER" => $poster,
"POST" => $post
) );
$this->email->subject = $ibforums->lang['tt_subject'];
$this->email->to = $r['email'];
$this->email->send_mail( );
}
else
{
$this->email->get_template( "subs_no_post", $r['language'] );
$this->email->build_message( array(
"TOPIC_ID" => $r['topic_id'],
"FORUM_ID" => $r['forum_id'],
"TITLE" => $r['title'],
"NAME" => $r['name'],
"POSTER" => $poster
) );
$this->email->subject = $ibforums->lang['tt_subject'];
$this->email->to = $r['email'];
$this->email->send_mail( );
}
$trids[] = $r['trid'];
}
}
return TRUE;
}
function forum_tracker( $fid = "", $this_tid = "", $title = "", $forum_name = "" )
{
global $ibforums;
global $DB;
global $std;
require( "./sources/lib/emailer.php" );
$this->email = new emailer( );
if ( $this_tid == "" )
{
return TRUE;
}
if ( $fid == "" )
{
return TRUE;
}
$time_limit = time( ) - 1800;
$allowed_groups = "";
if ( $this->forum['read_perms'] != "*" && strlen( 0 < $this->forum['read_perms'] ) )
{
$allowed_groups = " AND m.mgroup IN (0,".$this->forum['read_perms'].") ";
}
$DB->query( "SELECT tr.frid, m.name, m.email, m.id, m.language, m.last_activity\n\t\t\t\t FROM ibf_forum_tracker tr,ibf_members m\n\t\t\t\t WHERE tr.forum_id='{$fid}'\n\t\t\t\t AND tr.member_id=m.id\n\t\t\t\t AND m.id <> '{$ibforums->member['id']}'\n\t\t\t\t {$allowed_groups}\n\t\t\t\t AND m.last_activity < '{$time_limit}'" );
while ( $DB->get_num_rows( ) && ( $r = $DB->fetch_row( ) ) )
{
$r['language'] = $r['language'] ? $r['language'] : "en";
$this->email->get_template( "subs_new_topic", $r['language'] );
$this->email->build_message( array(
"TOPIC_ID" => $this_tid,
"FORUM_ID" => $fid,
"TITLE" => $title,
"NAME" => $r['name'],
"POSTER" => $ibforums->member['name'],
"FORUM" => $forum_name
) );
$this->email->subject = $ibforums->lang['ft_subject'];
$this->email->to = $r['email'];
$this->email->send_mail( );
}
return TRUE;
}
function compile_post( )
{
global $ibforums;
global $std;
global $REQUEST_METHOD;
global $HTTP_POST_VARS;
$ibforums->vars['max_post_length'] = $ibforums->vars['max_post_length'] ? $ibforums->vars['max_post_length'] : 2140000;
$ibforums->input['enablesig'] = $ibforums->input['enablesig'] == "yes" ? 1 : 0;
$ibforums->input['enableemo'] = $ibforums->input['enableemo'] == "yes" ? 1 : 0;
if ( strlen( trim( $HTTP_POST_VARS['Post'] ) ) < 1 )
{
$std->error( array( 1, "no_post" ) );
}
if ( $ibforums->vars['max_post_length'] * 1024 < strlen( $HTTP_POST_VARS['Post'] ) )
{
$std->error( array( 1, "post_too_long" ) );
}
$post = array(
"author_id" => $ibforums->member['id'] ? $ibforums->member['id'] : 0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -