class_post_edit.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 727 行 · 第 1/2 页

PHP
727
字号
		if ( $this->edit_title == 1 )		{			//-----------------------------------------			// Update poll			//-----------------------------------------						if ( $this->can_add_poll )			{				if ( is_array( $this->poll_questions ) AND count( $this->poll_questions ) )				{					$this->ipsclass->DB->do_update( 'polls', array( 'votes'         => intval($this->poll_total_votes),																	'choices'       => addslashes(serialize( $this->poll_questions )),																	'poll_question' => $this->ipsclass->input['poll_question'],																  ), 'tid='.$this->topic['tid']  );				}				else				{					//-----------------------------------------					// Remove the poll					//-----------------------------------------										$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'polls' , 'where' => "tid=".$this->topic['tid'] ) );					$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'voters', 'where' => "tid=".$this->topic['tid'] ) );					$this->ipsclass->DB->do_update( 'topics', array( 'poll_state' => '', 'last_vote' => '', 'total_votes' => '' ), 'tid='.$this->topic['tid'] );				}			}						//-----------------------------------------			// Update topic title			//-----------------------------------------						$this->ipsclass->input['TopicTitle'] = $this->pf_clean_topic_title( $this->ipsclass->input['TopicTitle'] );			$this->ipsclass->input['TopicTitle'] = trim( $this->parser->bad_words( $this->ipsclass->input['TopicTitle'] ) );			$this->ipsclass->input['TopicDesc']  = trim( $this->parser->bad_words( $this->ipsclass->input['TopicDesc']  ) );						if ( $this->ipsclass->input['TopicTitle'] != "" )			{				if ( ($this->ipsclass->input['TopicTitle'] != $this->topic['title']) or ($this->ipsclass->input['TopicDesc'] != $this->topic['description'])  )				{					$this->ipsclass->DB->do_update( 'topics', array( 'title'       => $this->ipsclass->input['TopicTitle'],																	 'description' => $this->ipsclass->input['TopicDesc']																   ) , "tid=".$this->topic['tid'] );										if ($this->topic['tid'] == $this->forum['last_id'])					{						$this->ipsclass->DB->do_update( 'forums', array( 'last_title' => $this->ipsclass->input['TopicTitle'] ), 'id='.$this->forum['id'] );						$this->ipsclass->update_forum_cache();					}										if ( ($this->moderator['edit_topic'] == 1) OR ( $this->ipsclass->member['g_is_supmod'] == 1 ) )					{						$this->ipsclass->DB->do_insert( 'moderator_logs', array (																				 'forum_id'    => $this->forum['id'],																				 'topic_id'    => $this->topic['tid'],																				 'post_id'     => $this->orig_post['pid'],																				 'member_id'   => $this->ipsclass->member['id'],																				 'member_name' => $this->ipsclass->member['members_display_name'],																				 'ip_address'  => $this->ip_address,																				 'http_referer'=> $_SERVER['HTTP_REFERER'],																				 'ctime'       => time(),																				 'topic_title' => $this->topic['title'],																				 'action'      => "Edited topic title or description '{$this->topic['title']}' to '{$this->ipsclass->input['TopicTitle']}' via post form",																				 'query_string'=> $_SERVER['QUERY_STRING'],																			 )    );					}				}			}		}				//-----------------------------------------		// Update the database (ib_forum_post)		//-----------------------------------------				$this->post['append_edit'] = 1;				if ( $this->ipsclass->member['g_append_edit'] )		{			if ( $this->ipsclass->input['add_edit'] != 1 )			{				$this->post['append_edit'] = 0;			}		}				$this->ipsclass->DB->do_update( 'posts', $this->post, 'pid='.$this->orig_post['pid'] );				//-----------------------------------------		// Make attachments "permanent"		//-----------------------------------------				$this->pf_make_attachments_permanent($this->post_key, $this->topic['tid'], $this->orig_post['pid']);				//-----------------------------------------		// Make sure paperclip symbol is OK		//-----------------------------------------				$this->pf_recount_topic_attachments($this->topic['tid']);				//-----------------------------------------		// Not XML? Redirect them back to the topic		//-----------------------------------------				if ( $this->ipsclass->input['act'] == 'xmlout' )		{			return TRUE;		}		else		{			$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['post_edited'], "act=ST&f={$this->forum['id']}&t={$this->topic['tid']}&st={$this->ipsclass->input['st']}#entry{$this->orig_post['pid']}");		}	}	/*-------------------------------------------------------------------------*/	// SHOW FORM	/*-------------------------------------------------------------------------*/	function show_form()	{		//-----------------------------------------		// INIT		//-----------------------------------------				$raw_post = "";				//-----------------------------------------		// Unconvert the saved post if required		//-----------------------------------------				if ( ! isset($_POST['Post']) )		{			//-----------------------------------------			// If we're using RTE, then just clean up html			//-----------------------------------------						if ( $this->han_editor->method == 'rte' )			{				$raw_post = $this->parser->convert_ipb_html_to_html( $this->orig_post['post'] );			}			else			{				$this->parser->parse_html    = intval($this->orig_post['post_htmlstatus']) AND $this->forum['use_html'] AND $this->ipsclass->member['g_dohtml'] ? 1 : 0;				$this->parser->parse_nl2br   = $this->ipsclass->input['post_htmlstatus'] == 2 ? 1 : 0;				$this->parser->parse_smilies = intval($this->orig_post['use_emo']);				$this->parser->parse_bbcode  = $this->forum['use_ibc'];				$raw_post = $this->parser->pre_edit_parse( $this->orig_post['post'] );			}		}		else		{			$raw_post = $this->ipsclass->txt_stripslashes( $_POST['Post'] );		}				//-----------------------------------------		// Is this the first post in the topic?		//-----------------------------------------				if ( $this->edit_title == 1 )		{			$topic_title = isset($_POST['TopicTitle']) ? $this->ipsclass->input['TopicTitle'] : $this->topic['title'];			$topic_desc  = isset($_POST['TopicDesc'])  ? $this->ipsclass->input['TopicDesc']  : $this->topic['description'];						$topic_title = $this->ipsclass->compiled_templates['skin_post']->topictitle_fields( array( 'TITLE' => $topic_title, 'DESC' => $topic_desc ) );		}				//-----------------------------------------		// Do we have any posting errors?		//-----------------------------------------				if ($this->obj['post_errors'])		{			$this->output .= $this->ipsclass->compiled_templates['skin_post']->errors( $this->ipsclass->lang[ $this->obj['post_errors'] ]);		}				if ( $this->obj['preview_post'] )		{			$this->output .= $this->ipsclass->compiled_templates['skin_post']->preview( $this->show_post_preview( $this->post['post'] ) );		}				$this->output .= $this->html_start_form( array( 1 => array( 'CODE', '09' ),														2 => array( 't'   , $this->topic['tid']),														3 => array( 'p'   , $this->ipsclass->input['p'] ),														4 => array( 'st'  , $this->ipsclass->input['st'] ),														5 => array( 'post_key', $this->post_key )											   )       );																//-----------------------------------------		// START TABLE		//-----------------------------------------				$this->output .= $this->ipsclass->compiled_templates['skin_post']->table_structure();				$start_table = $this->ipsclass->compiled_templates['skin_post']->table_top( "{$this->ipsclass->lang['top_txt_edit']} {$this->topic['title']}");				$name_fields = $this->html_name_field();				$post_box    = $this->html_post_body( $raw_post );				if ( $this->edit_title == 1 )		{			$mod_options = $this->mod_options('edit');		}				$end_form    = $this->ipsclass->compiled_templates['skin_post']->EndForm( $this->ipsclass->lang['submit_edit'] );				$post_icons  = $this->html_post_icons($this->orig_post['icon_id']);				if ( $this->can_upload )		{			$upload_field = $this->html_build_uploads($this->post_key,'edit',$this->orig_post['pid']);		}				//-----------------------------------------		// Still here?		//-----------------------------------------				if ( $this->can_add_poll )		{			//-----------------------------------------			// Did someone hit preview / do we have			// post info?			//-----------------------------------------						$poll_questions = "";			$poll_choices   = "";			$poll_votes     = "";			$show_open      = 0;			$is_mod         = 0;						if ( is_array( $_POST['question'] ) and count( $_POST['question'] ) )			{				foreach( $_POST['question'] as $id => $question )				{					$poll_questions .= "\t{$id} : '".str_replace( "'", '&#39;', $question )."',\n";				}								$poll_question = $this->ipsclass->input['poll_question'];				$show_open     = 1;								if ( is_array( $_POST['choice'] ) and count( $_POST['choice'] ) )				{					foreach( $_POST['choice'] as $id => $choice )					{						$poll_choices .= "\t'{$id}' : '".str_replace( "'", '&#39;', $choice )."',\n";					}				}								if ( is_array( $_POST['votes'] ) and count( $_POST['votes'] ) )				{					foreach( $_POST['votes'] as $id => $vote )					{						$poll_votes .= "\t'{$id}' : '".$vote."',\n";					}				}								$poll_questions = preg_replace( "#,(\n)?$#", "\\1", $poll_questions );				$poll_choices   = preg_replace( "#,(\n)?$#", "\\1", $poll_choices );				$poll_votes     = preg_replace( "#,(\n)?$#", "\\1", $poll_votes );							}			else			{				//-----------------------------------------				// Load the poll from the DB				//-----------------------------------------								$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'polls', 'where' => "tid=".$this->topic['tid'] ) );				$this->ipsclass->DB->simple_exec();		        		$poll_data = $this->ipsclass->DB->fetch_row();        		        		$poll_answers = unserialize(stripslashes($poll_data['choices']));        		        		//-----------------------------------------        		// Lezz go        		//-----------------------------------------        		        		foreach( $poll_answers as $question_id => $data )        		{        			$poll_questions .= "\t{$question_id} : '".str_replace( "'", '&#39;', $data['question'] )."',\n";        			        			foreach( $data['choice'] as $choice_id => $text )					{						$choice = $text;						$votes  = intval($data['votes'][ $choice_id ]);												$poll_choices .= "\t'{$question_id}_{$choice_id}' : '".str_replace( "'", '&#39;', $choice )."',\n";						$poll_votes   .= "\t'{$question_id}_{$choice_id}' : '".$votes."',\n";					}				}								//-----------------------------------------				// Trim off trailing commas (Safari hates it)				//-----------------------------------------								$poll_questions = preg_replace( "#,(\n)?$#", "\\1", $poll_questions );				$poll_choices   = preg_replace( "#,(\n)?$#", "\\1", $poll_choices );				$poll_votes     = preg_replace( "#,(\n)?$#", "\\1", $poll_votes );								$poll_question = $poll_data['poll_question'];				$show_open     = 1;				$is_mod        = 1;			}						//-----------------------------------------			// Print poll box			//-----------------------------------------						$poll_box = $this->ipsclass->compiled_templates['skin_post']->poll_box( $this->max_poll_questions, $this->max_poll_choices_per_question, $poll_questions, $poll_choices, $poll_votes, $show_open, $poll_question, $is_mod );		}				if ($this->ipsclass->member['g_append_edit'])		{			$checked = "";						if ($this->orig_post['append_edit'])			{				$checked = "checked";			}						$edit_option = $this->ipsclass->compiled_templates['skin_post']->add_edit_box($checked);		}				$this->output = str_replace( "<!--START TABLE-->" , $start_table  , $this->output );		$this->output = str_replace( "<!--NAME FIELDS-->" , $name_fields  , $this->output );		$this->output = str_replace( "<!--POST BOX-->"    , $post_box     , $this->output );		$this->output = str_replace( "<!--POLL BOX-->"    , $poll_box     , $this->output );		$this->output = str_replace( "<!--POST ICONS-->"  , $post_icons   , $this->output );		$this->output = str_replace( "<!--END TABLE-->"   , $end_form     , $this->output );		$this->output = str_replace( "<!--UPLOAD FIELD-->", $upload_field , $this->output );		$this->output = str_replace( "<!--MOD OPTIONS-->" , $edit_option . $mod_options , $this->output );		$this->output = str_replace( "<!--FORUM RULES-->" , $this->ipsclass->print_forum_rules($this->forum), $this->output );		$this->output = str_replace( "<!--TOPIC TITLE-->" , $topic_title  , $this->output );				$this->output = $this->html_add_smilie_box( $this->output );				//-----------------------------------------		// Add in siggy buttons and such		//-----------------------------------------				$this->ipsclass->input['post_htmlstatus'] = $this->orig_post['post_htmlstate'];		$this->ipsclass->input['enablesig']		  = $this->orig_post['use_sig'];		$this->ipsclass->input['enableemo']		  = $this->orig_post['use_emo'];				$this->html_checkboxes('edit', $this->topic['tid'], $this->forum['id']);				$this->html_topic_summary($this->topic['tid']);				$this->show_post_navigation();						  		$this->title = $this->ipsclass->lang['editing_post'].' '.$this->topic['title'];				$this->ipsclass->print->add_output( $this->output );		        $this->ipsclass->print->do_output( array( 'TITLE'    => $this->ipsclass->vars['board_name']." -> ".$this->title,        					 	  'JS'       => 1,        					 	  'NAV'      => $this->nav,        					  ) );	}	}?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?