⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vote.inc.php

📁 学校网站源码http://您的网址/admin/admin_login.asp 默认登录用户:admin 默认登录密码:admin
💻 PHP
字号:
<?php


class vote
{

	var $cookie_expire = 24;

	function result_poll( )
	{
		global $msql;
		global $tbl_poll_index;
		global $tbl_poll_data;
		global $tbl_poll_config;
		global $strVoteTotal;
		$poll_id = $_GET['pollid'];
		$action = $_GET['action'];
		$option_id = $_POST['option_id'];
		$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
		$msql->query( " SELECT * FROM {$tbl_poll_config} " );
		if ( $msql->next_record( ) )
		{
			$img_height = $msql->f( "img_height" );
			$img_length = $msql->f( "img_length" );
			$vodinfo = $msql->f( "vodinfo" );
		}
		if ( $action == "add" )
		{
			if ( $this->cookie_check( $REMOTE_ADDR, $poll_id ) == "1" )
			{
				return $vodinfo;
			}
			$msql->query( " UPDATE {$tbl_poll_data} SET votes = votes+1 where option_id = '{$option_id}' and poll_id = '{$poll_id}' " );
		}
		if ( $action == "add" || $action == "show" )
		{
			$msql->query( " SELECT * FROM {$tbl_poll_index} WHERE poll_id='{$poll_id}' and status = '1' " );
			if ( $msql->next_record( ) )
			{
				$question = $msql->f( "question" );
			}
			$msql->query( " SELECT sum(votes) FROM {$tbl_poll_data} WHERE poll_id='{$poll_id}' " );
			if ( $msql->next_record( ) )
			{
				$svotes = $msql->f( "sum(votes)" );
			}
			$result_poll = "<table width=\"100%\" class=table height=100% border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"1\"><tr><td colspan=\"2\" class=\"title\" height=28><div align=\"center\">".$question."</div></td></tr>";
			$msql->query( " SELECT * FROM {$tbl_poll_data} WHERE poll_id = '{$poll_id}' " );
			while ( $msql->next_record( ) )
			{
				$option_id = $msql->f( "option_id" );
				$option_text = $msql->f( "option_text" );
				$color = $msql->f( "color" );
				$votes = $msql->f( "votes" );
				$percent = @round( $votes / $svotes * 100 );
				$table_width = $percent + $img_length;
				$result_poll .= "<tr><td nowrap class=\"title\"><div align=\"right\">{$option_text}:</div></td>\r\n\t\t\t<td  class=\"con\"><img src=\"images/{$color}.gif\" width={$table_width} height={$img_height} align=\"absmiddle\"> {$percent}%({$votes})</td></tr>";
			}
			$result_poll .= "<tr><td colspan=\"2\" class=\"title\" height=28><div align=\"center\">".$strVoteTotal." : ".$svotes."</div></td></tr></table>";
			return $result_poll;
		}
	}

	function cookie_check( $ip, $poll_id )
	{
		global $tbl_poll_index;
		global $tbl_poll_data;
		global $tbl_poll_config;
		$IP = $_COOKIE['IP'];
		$POID = $_COOKIE['POID'];
		$action = $_GET['action'];
		$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
		if ( $REMOTE_ADDR == $IP && $poll_id == $POID )
		{
			$result = 1;
		}
		else
		{
			$result = 0;
			$endtime = time( ) + 3600 * $this->cookie_expire;
			setcookie( "IP", $ip, $endtime );
			setcookie( "POID", $poll_id );
		}
		return $result;
	}

}

?>

⌨️ 快捷键说明

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