class_post_new.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 509 行 · 第 1/2 页
PHP
509 行
<?php/*+--------------------------------------------------------------------------| Invision Power Board v2.1.5| =============================================| by Matthew Mecham| (c) 2001 - 2005 Invision Power Services, Inc.| | =============================================| Web: | Time: Wed, 01 Mar 2006 19:11:28 GMT| Release: | Licence Info: +---------------------------------------------------------------------------| > $Date: 2005-12-22 15:20:25 +0000 (Thu, 22 Dec 2005) $| > $Revision: 105 $| > $Author: bfarber $+---------------------------------------------------------------------------|| > Post Sub-Class| > Module written by Matt Mecham| > Date started: Wednesday 9th March 2005 (15:23)|+--------------------------------------------------------------------------*/class post_functions extends class_post{ var $nav = array(); var $title = ""; var $post = array(); var $upload = array(); var $mod_topic = array(); var $class = ""; var $m_group = ""; var $post_key = ""; var $has_poll = 0; var $poll_questions = array(); /*-------------------------------------------------------------------------*/ // Sub class init /*-------------------------------------------------------------------------*/ function main_init() { //----------------------------------------- // Load classes //----------------------------------------- $this->load_classes(); $this->build_permissions(); //----------------------------------------- // Check permissions //----------------------------------------- $this->post_key = $this->ipsclass->input['post_key'] ? $this->ipsclass->input['post_key'] : md5(microtime()); $this->check_for_new_topic(); } /*-------------------------------------------------------------------------*/ // MAIN PROCESS FUNCTION /*-------------------------------------------------------------------------*/ function process_post() { //----------------------------------------- // Convert times... //----------------------------------------- $this->convert_open_close_times(); //----------------------------------------- // Did we remove an attachment? //----------------------------------------- if ( $this->ipsclass->input['removeattachid'] ) { if ( $this->ipsclass->input[ 'removeattach_'. $this->ipsclass->input['removeattachid'] ] ) { $this->pf_remove_attachment( intval($this->ipsclass->input['removeattachid']), $this->post_key ); $this->show_form(); } } //----------------------------------------- // Did we add an attachment? //----------------------------------------- if ( $this->ipsclass->input['attachgo'] ) { $this->obj['post_errors'] = ""; $this->upload_id = $this->process_upload(); $this->show_form(); } //----------------------------------------- // Parse the post, and check for any errors. //----------------------------------------- $this->post = $this->compile_post(); //----------------------------------------- // check to make sure we have a valid topic title //----------------------------------------- $this->ipsclass->input['TopicTitle'] = str_replace( "<br />", "", $this->ipsclass->input['TopicTitle'] ); $this->ipsclass->input['TopicTitle'] = trim($this->ipsclass->input['TopicTitle']); //----------------------------------------- // More unicode.. //----------------------------------------- $temp = $this->ipsclass->txt_stripslashes($_POST['TopicTitle']); if ( $this->ipsclass->txt_mb_strlen($_POST['TopicTitle']) > $this->ipsclass->vars['topic_title_max_len'] ) { $this->obj['post_errors'] = 'topic_title_long'; } if ( (strlen($temp) < 2) or (!$this->ipsclass->input['TopicTitle']) ) { $this->obj['post_errors'] = 'no_topic_title'; } //----------------------------------------- // Compile the poll //----------------------------------------- $this->poll_questions = $this->compile_poll(); //----------------------------------------- // If we don't have any errors yet, parse the upload //----------------------------------------- if ($this->obj['post_errors'] == "") { $this->upload = $this->process_upload(); } if ( ($this->obj['post_errors'] != "") or ( $this->obj['preview_post'] != "" ) ) { //----------------------------------------- // Show the form again //----------------------------------------- $this->show_form(); } else { $this->save_post(); } } /*-------------------------------------------------------------------------*/ // ADD TOPIC FUNCTION /*-------------------------------------------------------------------------*/ function save_post() { //----------------------------------------- // Fix up the topic title //----------------------------------------- $this->ipsclass->input['TopicTitle'] = $this->pf_clean_topic_title( $this->ipsclass->input['TopicTitle'] ); $this->ipsclass->input['TopicTitle'] = $this->parser->bad_words( $this->ipsclass->input['TopicTitle'] ); $this->ipsclass->input['TopicDesc'] = $this->parser->bad_words( $this->ipsclass->input['TopicDesc'] ); $pinned = 0; $state = 'open'; if ( ($this->ipsclass->input['mod_options'] != "") or ($this->ipsclass->input['mod_options'] != 'nowt') ) { if ($this->ipsclass->input['mod_options'] == 'pin') { if ($this->ipsclass->member['g_is_supmod'] == 1 or $this->moderator['pin_topic'] == 1) { $pinned = 1; $this->moderate_log('Pinned topic from post form', $this->ipsclass->input['TopicTitle']); } } else if ($this->ipsclass->input['mod_options'] == 'close') { if ($this->ipsclass->member['g_is_supmod'] == 1 or $this->moderator['close_topic'] == 1) { $state = 'closed'; $this->moderate_log('Closed topic from post form', $this->ipsclass->input['TopicTitle']); } } else if ($this->ipsclass->input['mod_options'] == 'pinclose') { if ($this->ipsclass->member['g_is_supmod'] == 1 or ( $this->moderator['pin_topic'] == 1 AND $this->moderator['close_topic'] == 1 ) ) { $pinned = 1; $state = 'closed'; $this->moderate_log('Pinned & closed topic from post form', $this->ipsclass->input['TopicTitle']); } } } //----------------------------------------- // Check close times... //----------------------------------------- if ( $state == 'open' AND ( $this->times['open'] OR $this->times['close'] ) AND ( $this->times['close'] <= time() OR ( $this->times['open'] > time() AND !$this->times['close'] ) ) ) { $state = 'closed'; } //----------------------------------------- // Build the master array //----------------------------------------- $this->topic = array( 'title' => $this->ipsclass->input['TopicTitle'], 'description' => $this->ipsclass->input['TopicDesc'] , 'state' => $state, 'posts' => 0, 'starter_id' => $this->ipsclass->member['id'], 'starter_name' => $this->ipsclass->member['id'] ? $this->ipsclass->member['members_display_name'] : $this->ipsclass->input['UserName'], 'start_date' => time(), 'last_poster_id' => $this->ipsclass->member['id'], 'last_poster_name' => $this->ipsclass->member['id'] ? $this->ipsclass->member['members_display_name'] : $this->ipsclass->input['UserName'], 'last_post' => time(), 'icon_id' => $this->ipsclass->input['iconid'], 'author_mode' => $this->ipsclass->member['id'] ? 1 : 0, 'poll_state' => ( count( $this->poll_questions ) AND $this->can_add_poll ) ? 1 : 0, 'last_vote' => 0, 'views' => 0, 'forum_id' => $this->forum['id'], 'approved' => ( $this->obj['moderate'] == 1 || $this->obj['moderate'] == 2 ) ? 0 : 1, 'pinned' => $pinned, 'topic_open_time' => $this->times['open'], 'topic_close_time' => $this->times['close'], ); //----------------------------------------- // Insert the topic into the database to get the // last inserted value of the auto_increment field // follow suit with the post //----------------------------------------- $this->ipsclass->DB->force_data_type = array( 'title' => 'string', 'description' => 'string', 'starter_name' => 'string', 'last_poster_name' => 'string' );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?