📄 post_edit_post.php
字号:
<?php
class post_functions extends post
{
var $nav = array( );
var $title = "";
var $post = array( );
var $topic = array( );
var $upload = array( );
var $moderator = array
(
"member_id" => 0,
"member_name" => "",
"edit_post" => 0
);
var $orig_post = array( );
function post_functions( $class )
{
global $ibforums;
global $std;
global $DB;
$DB->query( "SELECT * FROM ibf_topics WHERE tid='".$ibforums->input['t']."'" );
$this->topic = $DB->fetch_row( );
if ( !$this->topic['tid'] )
{
$std->error( array( 1, "missing_files" ) );
}
$DB->query( "SELECT * FROM ibf_posts WHERE pid='".$ibforums->input['p']."'" );
$this->orig_post = $DB->fetch_row( );
if ( !$this->orig_post['pid'] )
{
$std->error( array( 1, "missing_files" ) );
}
if ( $ibforums->member['id'] )
{
$DB->query( "SELECT member_id, member_name, mid, edit_post 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']."'))" );
$this->moderator = $DB->fetch_row( );
}
$can_edit = 0;
if ( $ibforums->member['g_is_supmod'] )
{
$can_edit = 1;
}
if ( $this->moderator['edit_post'] )
{
$can_edit = 1;
}
if ( $this->orig_post['author_id'] == $ibforums->member['id'] && $ibforums->member['g_edit_posts'] )
{
if ( 0 < $ibforums->member['g_edit_cutoff'] )
{
if ( time( ) - intval( $ibforums->member['g_edit_cutoff'] ) * 60 < $this->orig_post['post_date'] )
{
$can_edit = 1;
}
}
else
{
$can_edit = 1;
}
}
if ( $can_edit != 1 )
{
$std->error( array( 1, "not_op" ) );
}
if ( $this->topic['state'] != "open" && !$ibforums->member['g_is_supmod'] )
{
$std->error( array( 1, "locked_topic" ) );
}
}
function process( $class )
{
global $ibforums;
global $std;
global $DB;
global $print;
$this->post = $class->compile_post( );
if ( $class->obj['post_errors'] != "" || $class->obj['preview_post'] != "" )
{
$this->show_form( $class );
}
else
{
$this->complete_edit( $class );
}
}
function complete_edit( $class )
{
global $ibforums;
global $std;
global $DB;
global $print;
global $HTTP_POST_FILES;
$time = $std->get_date( time( ), "LONG" );
if ( $this->orig_post['attach_id'] )
{
if ( $ibforums->input['editupload'] != "keep" )
{
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" )
{
$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" )
{
$this->post['attach_id'] = "";
$this->post['attach_type'] = "";
$this->post['attach_hits'] = "";
$this->post['attach_file'] = "";
$DB->query( "UPDATE ibf_topics SET attached=attached-1 WHERE tid='".$this->topic['tid']."'" );
}
}
else
{
$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'];
}
}
$this->post['ip_address'] = $this->orig_post['ip_address'];
$this->post['topic_id'] = $this->orig_post['topic_id'];
$this->post['author_id'] = $this->orig_post['author_id'];
$this->post['pid'] = $this->orig_post['pid'];
$this->post['post_date'] = $this->orig_post['post_date'];
$this->post['author_name'] = $this->orig_post['author_name'];
$this->post['queued'] = $this->orig_post['queued'];
$this->post['edit_time'] = time( );
$this->post['edit_name'] = $ibforums->member['name'];
if ( $this->orig_post['new_topic'] == 1 && $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']."'" );
}
$this->post['append_edit'] = 1;
if ( $ibforums->member['g_append_edit'] && $ibforums->input['add_edit'] != 1 )
{
$this->post['append_edit'] = 0;
}
$db_string = $DB->compile_db_update_string( $this->post );
$DB->query( "UPDATE ibf_posts SET {$db_string} WHERE pid='".$this->post['pid']."'" );
$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']}" );
}
function show_form( $class )
{
global $ibforums;
global $std;
global $DB;
global $print;
global $HTTP_POST_VARS;
$raw_post = isset( $HTTP_POST_VARS['Post'] ) ? htmlspecialchars( $HTTP_POST_VARS['Post'] ) : $class->parser->unconvert( $this->orig_post['post'], $class->forum['use_ibc'], $class->forum['use_html'] );
if ( isset( $raw_post ) )
{
$raw_post = str_replace( "\$", "$", $raw_post );
$raw_post = stripslashes( $raw_post );
}
if ( $class->obj['post_errors'] )
{
$class->output .= $class->html->errors( $ibforums->lang[$class->obj['post_errors']] );
}
if ( $class->obj['preview_post'] )
{
$class->output .= $class->html->preview( $class->parser->convert( array(
"TEXT" => $this->post['post'],
"CODE" => $class->forum['use_ibc'],
"SMILIES" => $ibforums->input['enableemo'],
"HTML" => $class->forum['use_html']
) ) );
}
$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']
)
) );
$class->output .= $class->html->table_structure( );
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_edit']} {$this->topic['title']}" );
$name_fields = $class->html_name_field( );
$post_box = $class->html_post_body( $raw_post );
$end_form = $class->html->endform( $ibforums->lang['submit_edit'] );
$post_icons = $class->html_post_icons( $this->orig_post['icon_id'] );
if ( $class->obj['can_upload'] && $this->orig_post['attach_id'] != "" )
{
$upload_field = $class->html->edit_upload_field( $ibforums->member['g_attach_max'] * 1024, $this->orig_post['attach_file'] );
}
if ( $ibforums->member['g_append_edit'] )
{
$checked = "";
if ( $this->orig_post['append_edit'] )
{
$checked = "checked";
}
$edit_option = $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->html_add_smilie_box( );
$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->title = $ibforums->lang['editing_post']." ".$this->topic['title'];
$print->add_output( "{$class->output}" );
$print->do_output( array(
"TITLE" => $ibforums->vars['board_name']." -> ".$this->title,
"JS" => 1,
"NAV" => $this->nav
) );
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -