Version 2.0.0

This commit is contained in:
Neo committed 2025-12-19 00:19:56 -08:00
1 parent 5699abfc0e
commit 0eecc172d9
696 files changed
+120723 -77160

No files matched your search

+265 -269
View File
@@ -2,21 +2,21 @@
/*
+--------------------------------------------------------------------------
| Invision Power Board v1.3.1 Final
| ========================================
| Invision Power Board v2.0.0
| =============================================
| by Matthew Mecham
| (c) 2001 - 2003 Invision Power Services
| (c) 2001 - 2004 Invision Power Services, Inc.
| http://www.invisionpower.com
| ========================================
| =============================================
| Web: http://www.invisionboard.com
| Time: Thu, 23 Sep 2004 23:05:01 GMT
| Release: 3cb325c445e1909182084806ae7f8226
| Email: matt@invisionpower.com
| Time: Tue, 21 Sep 2004 16:34:28 GMT
| Release: 150aa7a702c3c8b6f6eb90ad49305d2f
| Licence Info: http://www.invisionboard.com/?license
+---------------------------------------------------------------------------
|
| > Reply post module
| > Module written by Matt Mecham
| > DBA Checked: Fri 21 May 2004
|
+--------------------------------------------------------------------------
*/
@@ -24,92 +24,102 @@
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $class = "";
var $m_group = "";
var $post_key = "";
var $quote_pids = array();
var $quote_posts = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
function post_functions($class)
{
global $ibforums, $std, $DB, $forums;
$this->class = $class;
$this->post_key = $ibforums->input['post_key'] ? $ibforums->input['post_key'] : md5(microtime());
//-----------------------------------------
// Lets load the topic from the database before we do anything else.
//-----------------------------------------
$DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => "forum_id=".intval($this->class->forum['id'])." AND tid=".intval($ibforums->input['t']) ) );
$DB->simple_exec();
$DB->query("SELECT * FROM ibf_topics WHERE forum_id='".$class->forum['id']."' AND tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
//-----------------------------------------
// Check permissions, etc
//-----------------------------------------
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------------------
//-----------------------------------------
// Lets do some tests to make sure that we are
// allowed to reply to this topic
//-------------------------------------------------
//-----------------------------------------
if ($this->topic['poll_state'] == 'closed' and $ibforums->member['g_is_supadmin'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
$this->class->check_for_reply($this->topic);
if ($this->topic['starter_id'] == $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
if ($this->topic['starter_id'] != $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_other_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
if ( $std->check_perms($class->forum['reply_perms']) == FALSE )
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
// Is the topic locked?
if ($this->topic['state'] != 'open')
{
if ($ibforums->member['g_post_closed'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
}
function process($class) {
/*-------------------------------------------------------------------------*/
// MAIN PROCESS FUNCTION
/*-------------------------------------------------------------------------*/
function process()
{
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
//-----------------------------------------
// Did we remove an attachment?
//-----------------------------------------
$this->post = $class->compile_post();
if ($class->obj['post_errors'] == "")
if ( $ibforums->input['removeattachid'] )
{
$this->upload = $class->process_upload();
if ( $ibforums->input[ 'removeattach_'. $ibforums->input['removeattachid'] ] )
{
$this->class->pf_remove_attachment( intval($ibforums->input['removeattachid']), $this->post_key );
$this->show_form();
}
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
//-----------------------------------------
// Did we add an attachment?
//-----------------------------------------
if ( $ibforums->input['attachgo'] )
{
$this->class->obj['post_errors'] = "";
$this->upload_id = $this->class->process_upload();
$this->show_form();
}
//-----------------------------------------
// Parse the post, and check for any errors.
//-----------------------------------------
$this->post = $this->class->compile_post();
if ($this->class->obj['post_errors'] == "")
{
$this->upload = $this->class->process_upload();
}
if ( ($this->class->obj['post_errors'] != "") or ($this->class->obj['preview_post'] != "") )
{
//-----------------------------------------
// Show the form again
//-----------------------------------------
$this->show_form($class);
}
else
@@ -119,32 +129,34 @@ class post_functions extends Post {
}
/*-------------------------------------------------------------------------*/
// ADD THE REPLY
/*-------------------------------------------------------------------------*/
function add_reply($class) {
function add_reply()
{
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Update the post info with the upload array info
//-------------------------------------------------
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
//-------------------------------------------------
//-----------------------------------------
// Insert the post into the database to get the
// last inserted value of the auto_increment field
//-------------------------------------------------
//-----------------------------------------
$this->post['topic_id'] = $this->topic['tid'];
//-------------------------------------------------
//-----------------------------------------
// Get the last post time of this topic not counting
// this new reply
//-----------------------------------------
$this->last_post = $this->topic['last_post'];
//die( $this->last_post .' - '.$ibforums->member['last_activity'] . ' l');
//-----------------------------------------
// Are we a mod, and can we change the topic state?
//-------------------------------------------------
//-----------------------------------------
$return_to_move = 0;
@@ -152,50 +164,134 @@ class post_functions extends Post {
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['pin_topic'] == 1)
{
$this->topic['pinned'] = 1;
$class->moderate_log('Pinned topic from post form', $this->topic['title']);
$this->class->moderate_log('Pinned topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['close_topic'] == 1)
{
$this->topic['state'] = 'closed';
$class->moderate_log('Closed topic from post form', $this->topic['title']);
$this->class->moderate_log('Closed topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'move')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['move_topic'] == 1)
if ($ibforums->member['g_is_supmod'] == 1 or $this->class->moderator['move_topic'] == 1)
{
$return_to_move = 1;
}
}
else if ($ibforums->input['mod_options'] == 'pinclose')
{
if ($ibforums->member['g_is_supmod'] == 1 or ( $class->moderator['pin_topic'] == 1 AND $class->moderator['close_topic'] == 1 ) )
if ($ibforums->member['g_is_supmod'] == 1 or ( $this->class->moderator['pin_topic'] == 1 AND $this->class->moderator['close_topic'] == 1 ) )
{
$this->topic['pinned'] = 1;
$this->topic['state'] = 'closed';
$class->moderate_log('Pinned & closed topic from post form', $this->topic['title']);
$this->class->moderate_log('Pinned & closed topic from post form', $this->topic['title']);
}
}
}
$db_string = $DB->compile_db_insert_string( $this->post );
//-----------------------------------------
// Add post to DB
//-----------------------------------------
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['post_key'] = $this->post_key;
$this->post['post_parent'] = intval($ibforums->input['parent_id']);
//-----------------------------------------
// Typecast
//-----------------------------------------
$DB->force_data_type = array( 'pid' => 'int',
'post' => 'string' );
$DB->do_insert( 'posts', $this->post );
$this->post['pid'] = $DB->get_insert_id();
if ( $class->obj['moderate'] == 1 or $class->obj['moderate'] == 3 )
//-----------------------------------------
// If we are still here, lets update the
// board/forum/topic stats
//-----------------------------------------
$this->class->pf_update_forum_and_stats($this->topic['tid'], $this->topic['title'], 'reply');
//-----------------------------------------
// Get the correct number of replies
//-----------------------------------------
$DB->simple_construct( array( 'select' => 'COUNT(*) as posts', 'from' => 'posts', 'where' => "topic_id={$this->topic['tid']} and queued != 1" ) );
$DB->simple_exec();
$posts = $DB->fetch_row();
$pcount = intval( $posts['posts'] - 1 );
//-----------------------------------------
// Get the correct number of queued replies
//-----------------------------------------
$DB->simple_construct( array( 'select' => 'COUNT(*) as posts', 'from' => 'posts', 'where' => "topic_id={$this->topic['tid']} and queued=1" ) );
$DB->simple_exec();
$qposts = $DB->fetch_row();
$qpcount = intval( $qposts['posts'] );
//-----------------------------------------
// UPDATE TOPIC
//-----------------------------------------
$poster_name = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$update_array = array(
'posts' => $pcount,
'topic_queuedposts'=> $qpcount
);
if ( $this->class->obj['moderate'] != 1 and $this->class->obj['moderate'] != 3 )
{
$update_array['last_poster_id'] = $ibforums->member['id'];
$update_array['last_poster_name'] = $poster_name;
$update_array['last_post'] = time();
$update_array['pinned'] = $this->topic['pinned'];
$update_array['state'] = $this->topic['state'];
}
$DB->do_update( 'topics', $update_array, "tid={$this->topic['tid']}" );
//-----------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-----------------------------------------
$this->class->pf_increment_user_post_count();
//-----------------------------------------
// Make attachments "permanent"
//-----------------------------------------
$this->class->pf_make_attachments_permanent($this->post_key, $this->topic['tid'], $this->post['pid']);
//-----------------------------------------
// Moderating?
//-----------------------------------------
if ( $this->class->obj['moderate'] == 1 or $this->class->obj['moderate'] == 3 )
{
$DB->query("UPDATE ibf_forums SET has_mod_posts=1 WHERE id=".$class->forum['id']);
//-----------------------------------------
// Boing!!!
//-----------------------------------------
$this->class->notify_new_topic_approval( $this->topic['tid'], $this->topic['title'], $this->topic['starter_name'], $this->post['pid'], 'reply' );
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
$page = $page * $ibforums->vars['display_max_posts'];
@@ -203,250 +299,150 @@ class post_functions extends Post {
$print->redirect_screen( $ibforums->lang['moderate_post'], "showtopic={$this->topic['tid']}&st=$page" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum/topic stats
//-------------------------------------------------
$class->forum['last_title'] = str_replace( "'", "'", $this->topic['title'] );
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['posts']++;
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"posts='" .$class->forum['posts'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
//-------------------------------------------------
// Get the correct number of replies the topic has
//-------------------------------------------------
$DB->query("SELECT COUNT(pid) as posts FROM ibf_posts WHERE topic_id={$this->topic['tid']} and queued != 1");
$posts = $DB->fetch_row();
$pcount = intval( $posts['posts'] - 1 );
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_topics SET last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"last_poster_name='" .$class->forum['last_poster_name'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"pinned='" .$this->topic['pinned'] ."', ".
"state='" .$this->topic['state'] ."', ".
"posts=$pcount ".
"WHERE tid='" .$this->topic['tid'] ."'");
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+1");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
$mgroup = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
// Are we checking for auto promotion?
if ($ibforums->member['g_promotion'] != '-1&-1')
{
list($gid, $gposts) = explode( '&', $ibforums->member['g_promotion'] );
if ( $gid > 0 and $gposts > 0 )
{
if ( $ibforums->member['posts'] + 1 >= $gposts )
{
$mgroup = "mgroup='$gid', ";
if ( USE_MODULES == 1 )
{
$class->modules->register_class(&$class);
$class->modules->on_group_change($ibforums->member['id'], $gid);
}
}
}
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.$mgroup.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
//-----------------------------------------
// Are we tracking topics we reply in 'auto_track'?
//-------------------------------------------------
//-----------------------------------------
if ( $ibforums->member['id'] AND $ibforums->input['enabletrack'] == 1 )
{
$DB->query("SELECT trid FROM ibf_tracker WHERE topic_id='".$this->topic['tid']."' AND member_id='".$ibforums->member['id']."'");
if ( ! $DB->get_num_rows() )
{
$db_string = $DB->compile_db_insert_string( array (
'member_id' => $ibforums->member['id'],
'topic_id' => $this->topic['tid'],
'start_date' => time(),
) );
$DB->query("INSERT INTO ibf_tracker ({$db_string['FIELD_NAMES']}) VALUES ({$db_string['FIELD_VALUES']})");
}
}
$this->class->pf_add_tracked_topic($this->topic['tid'], 1);
//-------------------------------------------------
//-----------------------------------------
// Check for subscribed topics
// Pass on the previous last post time of the topic
// to see if we need to send emails out
//-------------------------------------------------
//-----------------------------------------
$class->topic_tracker( $this->topic['tid'], $this->post['post'], $class->forum['last_poster_name'], $this->topic['last_post'] );
$this->class->topic_tracker( $this->topic['tid'], $this->post['post'], $poster_name, $this->last_post );
//-------------------------------------------------
//-----------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
//-----------------------------------------
if ($return_to_move == 1)
{
$std->boink_it($class->base_url."act=Mod&CODE=02&f={$class->forum['id']}&t={$this->topic['tid']}");
$std->boink_it($this->class->base_url."act=Mod&CODE=02&f={$this->class->forum['id']}&t={$this->topic['tid']}");
}
else
{
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
$page = $page * $ibforums->vars['display_max_posts'];
$std->boink_it($class->base_url."showtopic={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
$std->boink_it($ibforums->base_url."showtopic={$this->topic['tid']}&st=$page&p={$this->post['pid']}&#entry{$this->post['pid']}");
}
}
/*-------------------------------------------------------------------------*/
// SHOW FORM
/*-------------------------------------------------------------------------*/
function show_form($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
function show_form()
{
global $ibforums, $std, $DB, $print, $forums;
// Sort out the "raw" textarea input and make it safe incase
// we have a <textarea> tag in the raw post var.
//-----------------------------------------
// Are we quoting posts?
//-----------------------------------------
$raw_post = isset($HTTP_POST_VARS['Post']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['Post']) : "";
if (isset($raw_post))
{
$raw_post = $std->txt_raw2form($raw_post);
}
$raw_post = $this->class->check_multi_quote();
//-----------------------------------------
// Do we have any posting errors?
//-----------------------------------------
if ($class->obj['post_errors'])
if ($this->class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
$this->class->output .= $this->class->html->errors( $ibforums->lang[ $this->class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
if ($this->class->obj['preview_post'])
{
$this->post['post'] = $class->parser->post_db_parse(
$class->parser->convert( array(
$this->class->parser->pp_do_html = intval($ibforums->input['post_htmlstatus']) AND $this->class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0;
$this->class->parser->pp_nl2br = $ibforums->input['post_htmlstatus'] == 2 ? 1 : 0;
$this->post['post'] = $this->class->parser->post_db_parse(
$this->class->parser->convert( array(
'TEXT' => $this->post['post'],
'CODE' => $class->forum['use_ibc'],
'CODE' => $this->class->forum['use_ibc'],
'SMILIES' => $ibforums->input['enableemo'],
'HTML' => $class->forum['use_html']
) ) ,
$class->forum['use_html'] AND $ibforums->member['g_dohtml'] ? 1 : 0);
$class->output .= $class->html->preview( $this->post['post'] );
'HTML' => $this->class->forum['use_html']
) )
);
$this->class->output .= $this->class->html->preview( $this->post['post'] );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '03' ),
2 => array( 't' , $this->topic['tid'])
) );
$this->class->output .= $this->class->html_start_form( array( 1 => array( 'CODE' , '03' ),
2 => array( 't' , $this->topic['tid'] ),
3 => array( 'post_key' , $this->post_key ),
4 => array( 'parent_id', $ibforums->input['parent_id'] ),
) );
//---------------------------------------
//-----------------------------------------
// START TABLE
//---------------------------------------
//-----------------------------------------
$class->output .= $class->html->table_structure();
$this->class->output .= $this->class->html->table_structure();
//---------------------------------------
//-----------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
$start_table = $this->class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
$name_fields = $this->class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$post_box = $this->class->html_post_body( $raw_post );
$mod_options = $class->mod_options(1);
$mod_options = $this->class->mod_options(1);
$end_form = $class->html->EndForm( $ibforums->lang['submit_reply'] );
$end_form = $this->class->html->EndForm( $ibforums->lang['submit_reply'] );
$post_icons = $class->html_post_icons();
$post_icons = $this->class->html_post_icons();
if ($class->obj['can_upload'])
if ($this->class->can_upload)
{
$upload_field = $class->html->Upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ) );
$upload_field = $this->class->html_build_uploads($this->post_key,'reply');
}
//---------------------------------------
//-----------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
$class->output = str_replace("<!--FORUM RULES-->", $std->print_forum_rules($class->forum), $class->output );
$this->class->output = str_replace( "<!--START TABLE-->" , $start_table , $this->class->output );
$this->class->output = str_replace( "<!--NAME FIELDS-->" , $name_fields , $this->class->output );
$this->class->output = str_replace( "<!--POST BOX-->" , $post_box , $this->class->output );
$this->class->output = str_replace( "<!--POST ICONS-->" , $post_icons , $this->class->output );
$this->class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $this->class->output );
$this->class->output = str_replace( "<!--MOD OPTIONS-->" , $mod_options , $this->class->output );
$this->class->output = str_replace( "<!--END TABLE-->" , $end_form , $this->class->output );
$this->class->output = str_replace( "<!--FORUM RULES-->" , $std->print_forum_rules($this->class->forum), $this->class->output );
//---------------------------------------
//-----------------------------------------
$class->html_add_smilie_box();
$this->class->output = $this->class->html_add_smilie_box( $this->class->output );
//---------------------------------------
//-----------------------------------------
// Add in siggy buttons and such
//---------------------------------------
//-----------------------------------------
$class->html_checkboxes('reply', $this->topic['tid']);
$this->class->html_checkboxes('reply', $this->topic['tid'], $this->class->forum['id']);
//---------------------------------------
//-----------------------------------------
$class->html_topic_summary($this->topic['tid']);
$this->class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}act=SC&amp;c={$class->forum[cat_id]}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}showforum={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}showtopic={$this->topic['tid']}'>{$this->topic['title']}</a>",
$this->nav = array( "<a href='{$this->class->base_url}act=SC&amp;c={$this->class->forum[cat_id]}'>{$this->class->forum['cat_name']}</a>",
"<a href='{$this->class->base_url}showforum={$this->class->forum['id']}'>{$this->class->forum['name']}</a>",
"<a href='{$this->class->base_url}showtopic={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['replying_in'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->add_output( $this->class->output );
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
'NAV' => $this->class->nav,
) );
}