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

+220 -229
View File
@@ -2,16 +2,15 @@
/*
+--------------------------------------------------------------------------
| 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
+---------------------------------------------------------------------------
|
@@ -20,6 +19,7 @@
| > Date started: 19th February 2002
|
| > Module Version Number: 1.0.0
| > DBA Checked: Fri 21 May 2004
+--------------------------------------------------------------------------
*/
@@ -35,32 +35,40 @@ class post_functions extends Post {
var $moderator = array( 'member_id' => 0, 'member_name' => "", 'edit_post' => 0 );
var $orig_post = array();
var $edit_title = 0;
function post_functions($class) {
var $post_key = "";
var $class = "";
function post_functions($class)
{
global $ibforums, $std, $DB;
//-------------------------------------------------
$this->class = $class;
//-----------------------------------------
// Lets load the topic from the database before we do anything else.
//-------------------------------------------------
//-----------------------------------------
$DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'where' => "tid=".intval($ibforums->input['t']) ) );
$DB->simple_exec();
$DB->query("SELECT * FROM ibf_topics WHERE tid=".intval($ibforums->input['t']));
$this->topic = $DB->fetch_row();
//-------------------------------------------------
//-----------------------------------------
// Is it legitimate?
//-------------------------------------------------
//-----------------------------------------
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------------------
//-----------------------------------------
// Load the old post
//-------------------------------------------------
//-----------------------------------------
$DB->simple_construct( array( 'select' => '*', 'from' => 'posts', 'where' => "pid=".intval($ibforums->input['p']) ) );
$DB->simple_exec();
$DB->query("SELECT * FROM ibf_posts WHERE pid=".intval($ibforums->input['p']));
$this->orig_post = $DB->fetch_row();
if (! $this->orig_post['pid'])
@@ -68,20 +76,47 @@ class post_functions extends Post {
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------------------
//-----------------------------------------
// Generate post key (do we have one?)
//-----------------------------------------
if ( ! $this->orig_post['post_key'] )
{
//-----------------------------------------
// Generate one and save back to post and attachment
// to ensure 1.3 < compatibility
//-----------------------------------------
$this->post_key = md5(microtime());
$DB->do_update( 'posts', array( 'post_key' => $this->post_key ), 'pid='.$this->orig_post['pid'] );
$DB->do_update( 'attachments', array( 'attach_post_key' => $this->post_key ), 'attach_pid='.$this->orig_post['pid'] );
}
else
{
$this->post_key = $this->orig_post['post_key'];
}
//-----------------------------------------
// Load the moderator
//-------------------------------------------------
//-----------------------------------------
if ($ibforums->member['id'])
{
$DB->query("SELECT member_id, member_name, mid, edit_post, edit_topic FROM ibf_moderators WHERE forum_id=".$class->forum['id']." AND (member_id=".$ibforums->member['id']." OR (is_group=1 AND group_id='".$ibforums->member['mgroup']."'))");
$DB->simple_construct( array( 'select' => 'member_id, member_name, mid, edit_post, edit_topic',
'from' => 'moderators',
'where' => "forum_id=".$this->class->forum['id']." AND (member_id='".$ibforums->member['id']."' OR (is_group=1 AND group_id='".$ibforums->member['mgroup']."'))" ) );
$DB->simple_exec();
$this->moderator = $DB->fetch_row();
}
//-------------------------------------------------
//-----------------------------------------
// Lets do some tests to make sure that we are
// allowed to edit this topic
//-------------------------------------------------
//-----------------------------------------
$can_edit = 0;
@@ -115,21 +150,15 @@ class post_functions extends Post {
$std->Error( array( LEVEL => 1, MSG => 'not_op') );
}
//-----------------------------
// Is the topic locked?
//-----------------------------
//-----------------------------------------
// Check access
//-----------------------------------------
if (($this->topic['state'] != 'open') and (!$ibforums->member['g_is_supmod']))
{
if ($ibforums->member['g_post_closed'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
$this->class->check_for_edit($this->topic);
//-----------------------------
//-----------------------------------------
// // Do we have edit topic abilities?
//-----------------------------
//-----------------------------------------
if ( $this->orig_post['new_topic'] == 1 )
{
@@ -150,23 +179,58 @@ class post_functions extends Post {
$this->edit_title = 1;
}
}
}
function process($class) {
/*-------------------------------------------------------------------------*/
// MAIN PROCESS FUNCTION
/*-------------------------------------------------------------------------*/
function process()
{
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
//-----------------------------------------
// Did we remove an attachment?
//-----------------------------------------
if ( $ibforums->input['removeattachid'] )
{
if ( $ibforums->input[ 'removeattach_'. $ibforums->input['removeattachid'] ] )
{
$this->class->pf_remove_attachment( intval($ibforums->input['removeattachid']), $this->post_key );
$this->show_form();
}
}
//-----------------------------------------
// 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.
// overwrites saved post intentionally
//-------------------------------------------------
//-----------------------------------------
$this->post = $class->compile_post();
$this->post = $this->class->compile_post();
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_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
@@ -176,87 +240,19 @@ class post_functions extends Post {
}
/*-------------------------------------------------------------------------*/
// COMPLETE EDIT THINGY
/*-------------------------------------------------------------------------*/
function complete_edit($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_FILES;
function complete_edit($class)
{
global $ibforums, $std, $DB, $print;
$time = $std->get_date( time(), 'LONG' );
//-------------------------------------------------
//-----------------------------------------
// Reset some data
//-------------------------------------------------
// Do we have to adjust the attachments?
if ($this->orig_post['attach_id'])
{
if ( isset($ibforums->input['editupload']) AND ($ibforums->input['editupload'] != 'keep') )
{
// We're either uploading a new attachment, or deleting one, so lets
// remove the old attachment first eh?
if (is_file($ibforums->vars['upload_dir']."/".$this->orig_post['attach_id']))
{
@unlink($ibforums->vars['upload_dir']."/".$this->orig_post['attach_id']);
}
if ($ibforums->input['editupload'] == 'new')
{
// w00t, we're uploading a new ..um.. upload
$new_upload = $class->process_upload();
if ( $class->obj['post_errors'] != "") {
$this->show_form($class);
}
$this->post['attach_id'] = $new_upload['attach_id'];
$this->post['attach_type'] = $new_upload['attach_type'];
$this->post['attach_hits'] = $new_upload['attach_hits'];
$this->post['attach_file'] = $new_upload['attach_file'];
}
else if ($ibforums->input['editupload'] == 'delete')
{
// Simply remove the DB data as we've already removed the file
$this->post['attach_id'] = "";
$this->post['attach_type'] = "";
$this->post['attach_hits'] = "";
$this->post['attach_file'] = "";
}
}
else
{
// We are keeping the old attachment
$this->post['attach_id'] = $this->orig_post['attach_id'];
$this->post['attach_type'] = $this->orig_post['attach_type'];
$this->post['attach_hits'] = $this->orig_post['attach_hits'];
$this->post['attach_file'] = $this->orig_post['attach_file'];
}
}
else
{
// Is there a new attachment?
$new_upload = $class->process_upload();
if ( $class->obj['post_errors'] != "") {
$this->show_form($class);
}
if ( $new_upload['attach_id'] )
{
$this->post['attach_id'] = $new_upload['attach_id'];
$this->post['attach_type'] = $new_upload['attach_type'];
$this->post['attach_hits'] = $new_upload['attach_hits'];
$this->post['attach_file'] = $new_upload['attach_file'];
}
}
//-----------------------------------------
$this->post['ip_address'] = $this->orig_post['ip_address'];
$this->post['topic_id'] = $this->orig_post['topic_id'];
@@ -268,58 +264,48 @@ class post_functions extends Post {
$this->post['edit_time'] = time();
$this->post['edit_name'] = $ibforums->member['name'];
//-------------------------------------------------
//-----------------------------------------
// If the post icon has changed, update the topic post icon
//-------------------------------------------------
//-----------------------------------------
if ($this->orig_post['new_topic'] == 1)
{
if ($this->post['icon_id'] != $this->orig_post['icon_id'])
{
$DB->query("UPDATE ibf_topics SET icon_id='".$this->post['icon_id']."' WHERE tid=".$this->topic['tid']);
$DB->do_update( 'topics', array( 'icon_id' => $this->post['icon_id'] ), 'tid='.$this->topic['tid'] );
}
}
//-------------------------------------------------
//-----------------------------------------
// Update topic title?
//-------------------------------------------------
//-----------------------------------------
if ( $this->edit_title == 1 )
{
if ($ibforums->vars['etfilter_punct'])
{
$ibforums->input['TopicTitle'] = preg_replace( "/\?{1,}/" , "?" , $ibforums->input['TopicTitle'] );
$ibforums->input['TopicTitle'] = preg_replace( "/(&#33;){1,}/" , "&#33;", $ibforums->input['TopicTitle'] );
}
$ibforums->input['TopicTitle'] = $this->class->pf_clean_topic_title( $ibforums->input['TopicTitle'] );
if ($ibforums->vars['etfilter_shout'])
{
$ibforums->input['TopicTitle'] = ucwords(strtolower($ibforums->input['TopicTitle']));
}
$ibforums->input['TopicTitle'] = trim( $class->parser->bad_words( $ibforums->input['TopicTitle'] ) );
$ibforums->input['TopicDesc'] = trim( $class->parser->bad_words( $ibforums->input['TopicDesc'] ) );
$ibforums->input['TopicTitle'] = trim( $this->class->parser->bad_words( $ibforums->input['TopicTitle'] ) );
$ibforums->input['TopicDesc'] = trim( $this->class->parser->bad_words( $ibforums->input['TopicDesc'] ) );
if ( $ibforums->input['TopicTitle'] != "" )
{
if ( ($ibforums->input['TopicTitle'] != $this->topic['title']) or ($ibforums->input['TopicDesc'] != $this->topic['description']) )
{
$dbs = $DB->compile_db_update_string( array(
'title' => $ibforums->input['TopicTitle'],
'description' => $ibforums->input['TopicDesc']
) );
$DB->query("UPDATE ibf_topics SET $dbs WHERE tid=".$this->topic['tid']);
$DB->do_update( 'topics', array( 'title' => $ibforums->input['TopicTitle'],
'description' => $ibforums->input['TopicDesc']
) , "tid=".$this->topic['tid']
);
if ($this->topic['tid'] == $class->forum['last_id'])
if ($this->topic['tid'] == $this->class->forum['last_id'])
{
$DB->query("UPDATE ibf_forums SET last_title='{$ibforums->input['TopicTitle']}' WHERE id='".$class->forum['id']."'");
$DB->do_update( 'forums', array( 'last_title' => $ibforums->input['TopicTitle'] ), 'id='.$this->class->forum['id'] );
$std->update_forum_cache();
}
if ( ($this->moderator['edit_topic'] == 1) OR ( $ibforums->member['g_is_supmod'] == 1 ) )
{
$db_string = $std->compile_db_string( array (
'forum_id' => $class->forum['id'],
$DB->do_insert( 'moderator_logs', array (
'forum_id' => $this->class->forum['id'],
'topic_id' => $this->topic['tid'],
'post_id' => $this->post['pid'],
'member_id' => $ibforums->member['id'],
@@ -330,18 +316,15 @@ class post_functions extends Post {
'topic_title' => $this->topic['title'],
'action' => "Edited topic title or description '{$this->topic['title']}' to '{$ibforums->input['TopicTitle']}' via post form",
'query_string'=> $QUERY_STRING,
)
);
$DB->query("INSERT INTO ibf_moderator_logs (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
) );
}
}
}
}
//-------------------------------------------------
//-----------------------------------------
// Update the database (ib_forum_post)
//-------------------------------------------------
//-----------------------------------------
$this->post['append_edit'] = 1;
@@ -353,111 +336,117 @@ class post_functions extends Post {
}
}
$db_string = $DB->compile_db_update_string( $this->post );
$DB->query("UPDATE ibf_posts SET $db_string WHERE pid='".$this->post['pid']."'");
$DB->do_update( 'posts', $this->post, 'pid='.$this->post['pid'] );
//-------------------------------------------------
//-----------------------------------------
// Make attachments "permanent"
//-----------------------------------------
$this->class->pf_make_attachments_permanent($this->post_key, $this->topic['tid'], $this->post['pid']);
//-----------------------------------------
// Make sure paperclip symbol is OK
//-----------------------------------------
$this->class->pf_recount_topic_attachments($this->topic['tid']);
//-----------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
//-----------------------------------------
$print->redirect_screen( $ibforums->lang['post_edited'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st={$ibforums->input['st']}#entry{$this->post['pid']}");
$print->redirect_screen( $ibforums->lang['post_edited'], "act=ST&f={$this->class->forum['id']}&t={$this->topic['tid']}&st={$ibforums->input['st']}#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;
//-------------------------------------------------
//-----------------------------------------
// Sort out the "raw" textarea input and make it safe incase
// we have a <textarea> tag in the raw post var.
//-------------------------------------------------
//-----------------------------------------
$raw_post = isset($HTTP_POST_VARS['Post']) ? $std->txt_htmlspecialchars($HTTP_POST_VARS['Post']) : $class->parser->unconvert($this->orig_post['post'], $class->forum['use_ibc'], $class->forum['use_html']);
$raw_post = isset($_POST['Post']) ? $std->txt_htmlspecialchars($_POST['Post']) : $this->class->parser->unconvert($this->orig_post['post'], $this->class->forum['use_ibc'], $this->class->forum['use_html']);
if (isset($raw_post))
{
$raw_post = $std->txt_raw2form($raw_post);
}
//-------------------------------------------------
//-----------------------------------------
// Is this the first post in the topic?
//-------------------------------------------------
//-----------------------------------------
if ( $this->edit_title == 1 )
{
$topic_title = isset($HTTP_POST_VARS['TopicTitle']) ? $ibforums->input['TopicTitle'] : $this->topic['title'];
$topic_desc = isset($HTTP_POST_VARS['TopicDesc']) ? $ibforums->input['TopicDesc'] : $this->topic['description'];
$topic_title = isset($_POST['TopicTitle']) ? $ibforums->input['TopicTitle'] : $this->topic['title'];
$topic_desc = isset($_POST['TopicDesc']) ? $ibforums->input['TopicDesc'] : $this->topic['description'];
$topic_title = $class->html->topictitle_fields( array( 'TITLE' => $topic_title, 'DESC' => $topic_desc ) );
$topic_title = $this->class->html->topictitle_fields( array( 'TITLE' => $topic_title, 'DESC' => $topic_desc ) );
}
//-------------------------------------------------
//-----------------------------------------
// 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', '09' ),
2 => array( 't' , $this->topic['tid']),
3 => array( 'p' , $ibforums->input['p'] ),
4 => array( 'st' , $ibforums->input['st'] ),
) );
$this->class->output .= $this->class->html_start_form( array( 1 => array( 'CODE', '09' ),
2 => array( 't' , $this->topic['tid']),
3 => array( 'p' , $ibforums->input['p'] ),
4 => array( 'st' , $ibforums->input['st'] ),
5 => array( 'post_key', $this->post_key )
) );
//---------------------------------------
//-----------------------------------------
// 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_edit']} {$this->topic['title']}");
$start_table = $this->class->html->table_top( "{$ibforums->lang['top_txt_edit']} {$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 );
$end_form = $class->html->EndForm( $ibforums->lang['submit_edit'] );
$end_form = $this->class->html->EndForm( $ibforums->lang['submit_edit'] );
$post_icons = $class->html_post_icons($this->orig_post['icon_id']);
$post_icons = $this->class->html_post_icons($this->orig_post['icon_id']);
if ( $class->obj['can_upload'] )
if ($this->class->can_upload)
{
if ($this->orig_post['attach_id'] != "")
{
$upload_field = $class->html->edit_upload_field( $std->size_format( $ibforums->member['g_attach_max'] * 1024 ), $this->orig_post['attach_file'] );
}
else
{
$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,'edit',$this->orig_post['pid']);
}
if ($ibforums->member['g_append_edit'])
@@ -469,47 +458,49 @@ class post_functions extends Post {
$checked = "checked";
}
$edit_option = $class->html->add_edit_box($checked);
$edit_option = $this->class->html->add_edit_box($checked);
}
//---------------------------------------
//-----------------------------------------
$class->output = str_replace( "<!--START TABLE-->" , $start_table , $class->output );
$class->output = str_replace( "<!--NAME FIELDS-->" , $name_fields , $class->output );
$class->output = str_replace( "<!--POST BOX-->" , $post_box , $class->output );
$class->output = str_replace( "<!--POST ICONS-->" , $post_icons , $class->output );
$class->output = str_replace( "<!--END TABLE-->" , $end_form , $class->output );
$class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $class->output );
$class->output = str_replace( "<!--MOD OPTIONS-->" , $edit_option , $class->output );
$class->output = str_replace( "<!--FORUM RULES-->" , $std->print_forum_rules($class->forum), $class->output );
$class->output = str_replace( "<!--TOPIC TITLE-->" , $topic_title , $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( "<!--END TABLE-->" , $end_form , $this->class->output );
$this->class->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $this->class->output );
$this->class->output = str_replace( "<!--MOD OPTIONS-->" , $edit_option , $this->class->output );
$this->class->output = str_replace( "<!--FORUM RULES-->" , $std->print_forum_rules($this->class->forum), $this->class->output );
$this->class->output = str_replace( "<!--TOPIC TITLE-->" , $topic_title , $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('edit');
$ibforums->input['post_htmlstatus'] = $this->orig_post['post_htmlstate'];
//---------------------------------------
$this->class->html_checkboxes('edit', $this->topic['tid'], $this->class->forum['id']);
$class->html_topic_summary($this->topic['tid']);
//-----------------------------------------
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
$this->class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$this->class->base_url}&act=SC&c={$this->class->forum['cat_id']}'>{$this->class->forum['cat_name']}</a>",
"<a href='{$this->class->base_url}&act=SF&f={$this->class->forum['id']}'>{$this->class->forum['name']}</a>",
"<a href='{$this->class->base_url}&act=ST&f={$this->class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['editing_post'].' '.$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,
) );
}