topics.php

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

PHP
1,929 行
字号
        }                //-----------------------------------------        // Do we have a poll question?        //-----------------------------------------                if ( ! $poll_data['poll_question'] )        {        	$poll_data['poll_question'] = $this->topic['title'];        }                //-----------------------------------------        // Show the poll        //-----------------------------------------                $voter = array( 'id' => 0 );                //-----------------------------------------        // Have we voted in this poll?        //-----------------------------------------                $this->ipsclass->DB->simple_construct( array( 'select' => 'member_id',													  'from'   => 'voters',													  'where'  => "member_id=".$this->ipsclass->member['id']." and tid=".$this->topic['tid']											 )      );        					         $this->ipsclass->DB->simple_exec();                $voter = $this->ipsclass->DB->fetch_row();                //-----------------------------------------        // Can we vote again?        //-----------------------------------------                if ($voter['member_id'] != 0)        {        	$check       = 1;        	$poll_footer = $this->ipsclass->lang['poll_you_voted'];        }                if ( ($poll_data['starter_id'] == $this->ipsclass->member['id']) and ($this->ipsclass->vars['allow_creator_vote'] != 1) )        {        	$check       = 1;        	$poll_footer = $this->ipsclass->lang['poll_you_created'];        }        	        if ( ! $this->ipsclass->member['id'] )        {        	$check       = 1;        	$poll_footer = $this->ipsclass->lang['poll_no_guests'];        }                //-----------------------------------------        // is the topic locked?        //-----------------------------------------                if ( $this->topic['state'] == 'closed' )        {        	$check       = 1;        	$poll_footer = '&nbsp;';        }                //-----------------------------------------        // Can we see the poll before voting?        //-----------------------------------------                if ( $this->ipsclass->vars['allow_result_view'] == 1 )        {        	if ( $this->ipsclass->input['mode'] == 'show' )        	{        		$check       = 1;        		$poll_footer = "";        	}        }                //-----------------------------------------        // Stop the parser killing images        // 'cos there are too many        //-----------------------------------------                $tmp_max_images                     = $this->ipsclass->vars['max_images'];        $this->ipsclass->vars['max_images'] = 0;                if ( $check == 1 )        {        	//-----------------------------------------        	// Show the results        	//-----------------------------------------        	        	$total_votes  = 0;        	$html         = $this->ipsclass->compiled_templates['skin_poll']->poll_header( $this->topic['tid'], $poll_data['poll_question'] );        	$poll_answers = unserialize(stripslashes($poll_data['choices']));        	        	reset($poll_answers);        	        	foreach ( $poll_answers as $id => $data )        	{        		//-----------------------------------------        		// Get the question        		//-----------------------------------------        		        		$question    = $data['question'];        		$choice_html = "";        		$tv_poll     = 0;        		        		# Get total votes for this question        		foreach( $poll_answers[ $id ]['votes'] as $index => $number)        		{        			$tv_poll += intval( $number );        		}        			        		//-----------------------------------------        		// Get the choices for this question        		//-----------------------------------------        		        		foreach( $data['choice'] as $choice_id => $text )        		{        			$choice  = $text;        			        			# Get total votes for this question -> choice        			$votes   = intval($data['votes'][ $choice_id ]);        								$total_votes += $votes;										if ( strlen($choice) < 1 )					{						continue;					}        							if ( $this->ipsclass->vars['poll_tags'] )					{						$choice = $this->parser->parse_poll_tags($choice);					}        			        			$percent = $votes == 0 ? 0 : $votes / $tv_poll * 100;        			$percent = sprintf( '%.2f' , $percent );        			$width   = $percent > 0 ? intval($percent * 2) : 0;        			        			$choice_html .= $this->ipsclass->compiled_templates['skin_poll']->poll_show_rendered_choice($choice_id, $votes, $id, $choice, $percent, $width);        		}        		        		//-----------------------------------------        		// Add HTML together        		//-----------------------------------------        		        		$html .= $this->ipsclass->compiled_templates['skin_poll']->poll_show_rendered_question( $id, $question, $choice_html );        	}        	        	$html   .= $this->ipsclass->compiled_templates['skin_poll']->show_total_votes($total_votes);        }        else        {        	$poll_answers = unserialize(stripslashes($poll_data['choices']));        	reset($poll_answers);        	        	//-----------------------------------------        	// Show poll form        	//-----------------------------------------        	        	$html = $this->ipsclass->compiled_templates['skin_poll']->poll_header($this->topic['tid'], $poll_data['poll_question']);        	        	foreach ( $poll_answers as $id => $data )        	{        		//-----------------------------------------        		// Get the question        		//-----------------------------------------        		        		$question    = $data['question'];        		$choice_html = "";        		        		//-----------------------------------------        		// Get the choices for this question        		//-----------------------------------------        		        		foreach( $data['choice'] as $choice_id => $text )        		{        			$choice = $text;        			$votes  = intval($data['votes'][ $choice_id ]);        						$total_votes += $votes;										if ( strlen($choice) < 1 )					{						continue;					}        							if ($this->ipsclass->vars['poll_tags'])					{						$choice = $this->parser->parse_poll_tags($choice);					}        		        			$choice_html .= $this->ipsclass->compiled_templates['skin_poll']->poll_show_form_choice($choice_id, $votes, $id, $choice);        		}        		        		//-----------------------------------------        		// Add HTML together        		//-----------------------------------------        		        		$html .= $this->ipsclass->compiled_templates['skin_poll']->poll_show_form_question( $id, $question, $choice_html );        	}        	        	$html   .= $this->ipsclass->compiled_templates['skin_poll']->show_total_votes($total_votes);        }                $html .= $this->ipsclass->compiled_templates['skin_poll']->poll_footer();                if ( $poll_footer != "" )        {        	//-----------------------------------------        	// Already defined..        	//-----------------------------------------        	        	$html = str_replace( "<!--IBF.VOTE-->", $poll_footer, $html );        }        else        {        	//-----------------------------------------        	// Not defined..        	//-----------------------------------------        	        	if ( $this->ipsclass->vars['allow_result_view'] == 1 )        	{        		if ( $this->ipsclass->input['mode'] == 'show' )        		{        			// We are looking at results..        			        			$html = str_replace( "<!--IBF.SHOW-->", $this->ipsclass->compiled_templates['skin_poll']->button_show_voteable(), $html );        		}        		else        		{        			$html = str_replace( "<!--IBF.SHOW-->", $this->ipsclass->compiled_templates['skin_poll']->button_show_results(), $html );        			$html = str_replace( "<!--IBF.VOTE-->", $this->ipsclass->compiled_templates['skin_poll']->button_vote(), $html );        		}        	}        	else        	{        		//-----------------------------------------        		// Do not allow result viewing        		//-----------------------------------------        		        		$html = str_replace( "<!--IBF.VOTE-->", $this->ipsclass->compiled_templates['skin_poll']->button_vote(), $html );        		$html = str_replace( "<!--IBF.SHOW-->", $this->ipsclass->compiled_templates['skin_poll']->button_null_vote(), $html );        	}        }                   $this->ipsclass->vars['max_images'] = $tmp_max_images;                return $html;	}		/*-------------------------------------------------------------------------*/	// Build topic permissions	/*-------------------------------------------------------------------------*/		function build_permissions()	{		//-----------------------------------------		// Polls		//-----------------------------------------				$this->can_vote = intval( $this->ipsclass->member['g_vote_polls'] );				//-----------------------------------------		// Topic rating: Rating		//-----------------------------------------				if ( $this->ipsclass->member['id'] )		{			$this->can_rate = intval( $this->ipsclass->member['g_topic_rate_setting'] );		}		else		{			$this->can_rate = 0;		}	}		/*-------------------------------------------------------------------------*/	// Add vote to rating	/*-------------------------------------------------------------------------*/		function topic_add_vote_to_rating()	{		//-----------------------------------------		// INIT		//-----------------------------------------				$topic_id  = intval($this->ipsclass->input['t']);		$rating_id = intval($this->ipsclass->input['rating']);		$vote_cast = array();				$this->ipsclass->load_language('lang_topic');				//-----------------------------------------		// Permissions check		//-----------------------------------------				if ( ! $this->forum['forum_allow_rating'] )		{			$this->can_rate = 0;		}				if ( ! $this->can_rate )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'topic_rate_no_perm') );		}				//-----------------------------------------		// Make sure we have a valid poll id		//-----------------------------------------				if ( ! $topic_id )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );		}   		   		//-----------------------------------------   		// No topic?   		//-----------------------------------------   		   		if ( ! $this->topic['tid'] )   		{   			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'topic_rate_no_perm') );   		}				//-----------------------------------------		// Locked topic?		//-----------------------------------------		   		if ( $this->topic['state'] != 'open' )   		{   			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'locked_topic') );   		}   				//-----------------------------------------		// Sneaky members rating topic more than 5?		//-----------------------------------------		   		   		if( $rating_id > 5 )   		{	   		$rating_id = 5;   		}   		   		//-----------------------------------------   		// Have we rated before?		//-----------------------------------------				$rating = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*', 'from' => 'topic_ratings', 'where' => "rating_tid={$this->topic['tid']} and rating_member_id=".$this->ipsclass->member['id'] ) );				//-----------------------------------------		// Already rated?		//-----------------------------------------				if ( $rating['rating_id'] )		{			//-----------------------------------------			// Do we allow re-ratings?			//-----------------------------------------						if ( $this->ipsclass->member['g_topic_rate_setting'] == 2 )			{				if ( $rating_id != $rating['rating_value'] )				{					$new_rating = $rating_id - $rating['rating_value'];										$this->ipsclass->DB->do_update( 'topic_ratings', array( 'rating_value' => $rating_id ), 'rating_id='.$rating['rating_id'] );										$this->ipsclass->DB->do_update( 'topics', array( 'topic_rating_total' => intval($this->topic['topic_rating_total']) + $new_rating ), 'tid='.$this->topic['tid'] );				}								$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['topic_rating_changed'] , "showtopic={$this->topic['tid']}&st={$this->ipsclass->input['st']}" );			}			else			{				$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['topic_rated_already'] , "showtopic={$this->topic['tid']}&st={$this->ipsclass->input['st']}" );				exit();			}		}				//-----------------------------------------		// NEW RATING!		//-----------------------------------------				else		{			$this->ips

⌨️ 快捷键说明

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