class_post.php

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

PHP
2,030
字号
			}			else			{				$in_delim  = "'";				$out_delim = '"';			}						$smilies .= "<td><a href={$out_delim}javascript:emoticon($in_delim".$elmo['typed']."$in_delim, {$in_delim}smid_$smilie_id{$in_delim}){$out_delim}><img id='smid_$smilie_id' src=\"".$this->ipsclass->vars['EMOTICONS_URL']."/".$elmo['image']."\" alt=$in_delim".$elmo['typed']."$in_delim border='0' /></a></td>\n";						if ($count == $this->ipsclass->vars['emo_per_row'])			{				$smilies .= "</tr>\n\n";				if( $smilie_id < $total )				{					$count = 0;					$smilies.= "<tr align='center'>";				}			}		}				//-----------------------------------------		// Write 'em		//-----------------------------------------				if ( $count != $this->ipsclass->vars['emo_per_row'] )		{			for ($i = $count ; $i < $this->ipsclass->vars['emo_per_row'] ; ++$i)			{				$smilies .= "<td>&nbsp;</td>\n";			}			$smilies .= "</tr>";		}				$table = $this->ipsclass->compiled_templates['skin_post']->smilie_table();				if ($show_table != 0)		{			$table   = preg_replace( "/<!--THE SMILIES-->/", $smilies, $table );			$in_html = preg_replace( "/<!--SMILIE TABLE-->/", $table, $in_html );		}				return $in_html;	}			/*-------------------------------------------------------------------------*/	// HTML: topic summary.	// ------------------	// displays the last 10 replies to the topic we're	// replying in.	/*-------------------------------------------------------------------------*/		function html_topic_summary($topic_id)	{		if (! $topic_id ) return;				$cached_members = array();				$this->output .= $this->ipsclass->compiled_templates['skin_post']->TopicSummary_top();				//-----------------------------------------		// Get the posts		// This section will probably change at some point		//-----------------------------------------				$this->ipsclass->DB->cache_add_query( 'post_get_topic_review', array( 'tid' => $topic_id ) );							 		$post_query = $this->ipsclass->DB->cache_exec_query();				while ( $row = $this->ipsclass->DB->fetch_row($post_query) )		{		    $row['author'] = $row['members_display_name'];						$row['date']   = $this->ipsclass->get_date( $row['post_date'], 'LONG' );						if ( ! $this->ipsclass->member['view_img'])			{				// unconvert smilies first, or it looks a bit crap.								$row['post'] = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $row['post'] );								$row['post'] = preg_replace( "/<img src=[\"'](.+?)[\"'].+?".">/", "(IMG:<a href='\\1' target='_blank'>\\1</a>)", $row['post'] );			}						$this->parser->parse_html  = ( $this->forum['use_html'] and $this->ipsclass->cache['group_cache'][ $row['mgroup'] ]['g_dohtml'] and $row['post_htmlstate'] ) ? 1 : 0;			$this->parser->parse_wordwrap = $this->ipsclass->vars['post_wordwrap'];			$this->parser->parse_nl2br    = $row['post_htmlstate'] == 2 ? 1 : 0;						$row['post'] = $this->parser->pre_display_parse( $row['post'] );						//-----------------------------------------			// Are we giving this bloke a good ignoring?			//-----------------------------------------						if ( $this->ipsclass->member['ignored_users'] )			{				if ( strstr( $this->ipsclass->member['ignored_users'], ','.$row['author_id'].',' ) and $this->ipsclass->input['qpid'] != $row['pid'] )				{					if ( ! strstr( $this->ipsclass->vars['cannot_ignore_groups'], ','.$row['mgroup'].',' ) )					{						$this->output .= $this->ipsclass->compiled_templates['skin_post']->TopicSummary_body_hidden( $row );						continue;					}				}			}									$this->output .= $this->ipsclass->compiled_templates['skin_post']->TopicSummary_body( $row );		}				$this->output .= $this->ipsclass->compiled_templates['skin_post']->TopicSummary_bottom();	}		/*-------------------------------------------------------------------------*/	//	// Get used space so far	//	/*-------------------------------------------------------------------------*/		function _get_attachment_sum()	{		if ( $this->attach_sum == -1 )		{			$stats = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'sum(attach_filesize) as sum',																	'from'   => 'attachments',																	'where'  => 'attach_member_id='.$this->ipsclass->member['id'] ) );												    			$this->attach_sum = intval( $stats['sum'] );		}	}		/*-------------------------------------------------------------------------*/	// HTML: Build Upload Area - yay	/*-------------------------------------------------------------------------*/		function html_build_uploads($post_key="",$type="",$pid="")	{		$this->_get_attachment_sum();				if ( $this->ipsclass->member['g_attach_max'] > 0 )		{			$size = intval( ( $this->ipsclass->member['g_attach_max'] * 1024 ) - $this->attach_sum );			$size = $size < 0 ? 0 : $size;			$main_space_left = $this->ipsclass->size_format( $size );		}		else		{			$main_space_left = $this->ipsclass->lang['upload_unlimited'];		}														$upload_field = $this->ipsclass->compiled_templates['skin_post']->Upload_field(  $main_space_left );				if ( $post_key != "" )		{			//-----------------------------------------			// Check for current uploads based on temp			// key			//-----------------------------------------						if ( ! is_array( $this->cur_post_attach ) or ! count( $this->cur_post_attach ) )			{				$this->ipsclass->DB->simple_construct( array( "select" => '*', 'from' => 'attachments', 'where' => "attach_post_key='$post_key'") );				$this->ipsclass->DB->simple_exec();								while ( $r = $this->ipsclass->DB->fetch_row() )				{					$this->cur_post_attach[] = $r;				}			}						if ( is_array( $this->cur_post_attach ) and count( $this->cur_post_attach ) )			{ 				$upload_tmp  = $this->ipsclass->compiled_templates['skin_post']->uploadbox_tabletop();				$upload_size = 0;								foreach( $this->cur_post_attach as $row )				{					$upload_size += $row['attach_filesize'];					$row['image'] = $this->ipsclass->cache['attachtypes'][ $row['attach_ext'] ]['atype_img'];					$row['size']  = $this->ipsclass->size_format( $row['attach_filesize'] );										if ( strlen( $row['attach_file'] ) > 40 )					{						$row['attach_file'] = substr( $row['attach_file'], 0, 35 ) .'...';					}										$upload_tmp .= $this->ipsclass->compiled_templates['skin_post']->uploadbox_entry($row);				}								$space_used  = $this->ipsclass->size_format( intval( $upload_size ) );								if ( $this->ipsclass->member['g_attach_max'] > 0 )				{					if ( $this->ipsclass->member['g_attach_per_post'] )					{						//-----------------------------------------						// Max + per post: show per post						//-----------------------------------------												// If you don't have enough space globally, let's take that into account						if( $size < $upload_size )						{							$space_left = $main_space_left;						}						else						{							$space_left = $this->ipsclass->size_format( intval( ( $this->ipsclass->member['g_attach_per_post'] * 1024 ) - $upload_size ) );						}					}					else					{						//-----------------------------------------						// Max + no per post: Show max						//-----------------------------------------												$space_left = $this->ipsclass->size_format( intval( ( $this->ipsclass->member['g_attach_max'] * 1024 ) - $upload_size - $this->attach_sum ) );					}				}				else				{ 					if ( $this->ipsclass->member['g_attach_per_post'] )					{						//-----------------------------------------						// No Max + per post: show per post						//-----------------------------------------												$space_left = $this->ipsclass->size_format( intval( ( $this->ipsclass->member['g_attach_per_post'] * 1024 ) - $upload_size ) );					}					else					{						//-----------------------------------------						// No Max + no per post: Show unlimited						//-----------------------------------------												$space_left = $this->ipsclass->lang['upload_unlimited'];					}				}								$upload_text = sprintf( $this->ipsclass->lang['attach_space_left'], $space_used, $space_left );								$upload_tmp .= $this->ipsclass->compiled_templates['skin_post']->uploadbox_tableend( $upload_text );			}		}				if ( $upload_tmp )		{			$upload_field = str_replace( '<!--IBF.UPLOADED_ITEMS-->', $upload_tmp, $upload_field );		}				return $upload_field;	}		/*-------------------------------------------------------------------------*/	// Moderators log	// ------------------	// Simply adds the last action to the mod logs	/*-------------------------------------------------------------------------*/		function moderate_log($title = 'unknown', $topic_title)	{		$this->ipsclass->DB->do_insert( 'moderator_logs', array (												'forum_id'    => $this->ipsclass->input['f'],												'topic_id'    => $this->ipsclass->input['t'],												'post_id'     => $this->ipsclass->input['p'],												'member_id'   => $this->ipsclass->member['id'],												'member_name' => $this->ipsclass->member['members_display_name'],												'ip_address'  => $this->ipsclass->input['IP_ADDRESS'],												'http_referer'=> $_SERVER['HTTP_REFERER'],												'ctime'       => time(),												'topic_title' => $topic_title,												'action'      => $title,												'query_string'=> $_SERVER['QUERY_STRING'],										     ) );	}		/*-------------------------------------------------------------------------*/	// perform: Check for new topic	/*-------------------------------------------------------------------------*/		function check_for_new_topic( $topic=array() )	{		if (! $this->ipsclass->member['g_post_new_topics'])		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_starting' ) );		}				if ( $this->ipsclass->check_perms($this->forum['start_perms']) == FALSE )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_starting' ) );		}	}		/*-------------------------------------------------------------------------*/	// perform: Check for reply	/*-------------------------------------------------------------------------*/		function check_for_reply( $topic=array() )	{		if ($topic['poll_state'] == 'closed' and $this->ipsclass->member['g_is_supadmin'] != 1)		{			$this->ipsclass->Error( array( 'LEVEL' => '1', MSG => 'no_replies') );		}				if ($topic['starter_id'] == $this->ipsclass->member['id'])		{			if (! $this->ipsclass->member['g_reply_own_topics'])			{				$this->ipsclass->Error( array( 'LEVEL' => '1', MSG => 'no_replies') );			}		}				if ($topic['starter_id'] != $this->ipsclass->member['id'])		{			if (! $this->ipsclass->member['g_reply_other_topics'])			{				$this->ipsclass->Error( array( 'LEVEL' => '1', MSG => 'no_replies') );			}		}		if ( $this->ipsclass->check_perms($this->forum['reply_perms']) == FALSE )		{			$this->ipsclass->Error( array( 'LEVEL' => '1', MSG => 'no_replies') );		}				// Is the topic locked?				if ($topic['state'] != 'open')		{			if ($this->ipsclass->member['g_post_closed'] != 1)			{				$this->ipsclass->Error( array( 'LEVEL' => '1', MSG => 'locked_topic') );			}		}	}		/*-------------------------------------------------------------------------*/	// perform: Check for edit	/*-------------------------------------------------------------------------*/		function check_for_edit( $topic=array() )	{		//-----------------------------------------		// Is the topic locked?		//-----------------------------------------				if (($topic['state'] != 'open') and (!$this->ipsclass->member['g_is_supmod']))		{			if ($this->ipsclass->member['g_post_closed'] != 1)			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'locked_topic' ) );			}		}				if ( $this->ipsclass->check_perms($this->forum['reply_perms']) == FALSE )		{			$this->ipsclass->Error( array( 'LEVEL' => '1', MSG => 'not_op') );		}	}			/*-------------------------------------------------------------------------*/	// process upload	// ------------------	// checks for an entry in the upload field, and uploads	// the file if it meets our criteria. This also inserts	// a new row into the attachments database if successful	/*-------------------------------------------------------------------------*/		function process_upload()	{		//-----------------------------------------		// Got attachment types?		//-----------------------------------------				if ( ! is_array( $this->ipsclass->cache['attachtypes'] ) )		{			$this->ipsclass->cache['attachtypes'] = array();							$this->ipsclass->DB->simple_construct( array( 'select' => 'atype_extension,atype_mimetype,atype_post,atype_photo,atype_img', 'from' => 'attachments_type', 'where' => "atype_photo=1 OR atype_post=1" ) );			$this->ipsclass->DB->simple_exec();					while ( $r = $this->ipsclass->DB->fetch_row() )			{				$this->ipsclass->cache['attachtypes'][ $r['atype_extension'] ] = $r;			}		}				//-----------------------------------------		// Set up array		//-----------------------------------------				$attach_data = array( 							  'attach_ext'            => "",							  'attach_file'           => "",							  'attach_location'       => "",							  'attach_thumb_location' => "",							  'attach_hits'           => 0,							  'attach_date'           => time(),							  'attach_temp'           => 0,							  'attach_pid'            => 0,							  'attach_post_key'       => $this->ipsclass->input['post_key'],							  'attach_member_id'      => $this->ipsclass->member['id'],							  'attach_filesize'       => 0,							);				if ( ($this->can_upload != 1) or ($this->ipsclass->member['g_attach_max'] == -1 ) )		{

⌨️ 快捷键说明

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