Location: PHPKode > projects > Content*Builder > libraries/rating.class.php
<?



	/* vim: set expandtab tabstop=4 shiftwidth=4: */

	// +----------------------------------------------------------------------+

	// | Netbuilder 2.0beta - rating-class                                    |

	// +----------------------------------------------------------------------+

	// | Copyright (c) 2001, Stefan Ernst                                     |

	// +----------------------------------------------------------------------+

	// | Author: Stefan Ernst <hide@address.com>                      |

	// +----------------------------------------------------------------------+

	//



	 class Rating {

	 	

		 function rate($id,$rate) {

		 	 global $REMOTE_ADDR;

			 $check = mysql_fetch_array(mysql_query("SELECT ide,vote,ip FROM nbuilder_recommend WHERE ide = '$id'"),MYSQL_ASSOC);

			 if(empty($check[ide])) {

				 $rate = mysql_query("INSERT INTO nbuilder_recommend VALUES ('$id','$rate','$REMOTE_ADDR')");

			 } else {

			 		$select = mysql_fetch_array(mysql_query("SELECT * FROM nbuilder_recommend WHERE ip = '$REMOTE_ADDR'"),MYSQL_ASSOC);

			 		if($select["ide"] == "") {

							$rate = mysql_query("INSERT INTO nbuilder_recommend VALUES ('$id','$rate','$REMOTE_ADDR')");

						}

				}

			 }



		 function getScores($id) {

		 	$av_vote = mysql_fetch_array(mysql_query("SELECT AVG(vote) FROM nbuilder_recommend WHERE ide = '$id'"));

		 	$sum_votes = mysql_fetch_array(mysql_query("SELECT COUNT(vote) FROM nbuilder_recommend WHERE ide = '$id'"));

		 	$av[0] = $sum_votes[0];

		 	$av[1] = $av_vote[0];

		 return $av;

		 }

	 }

	 

	 class Score extends Rating {

	 	

	 	var $vote;

	 	var $votes;

	 	

	 	function setVote($v) {

	 		$this->vote = $v;

	 	}



	 		function getVote() {

	 			return $this->vote;

	 		}



		function setVotes($v) {

			$this->votes = $v;

		}



			function getVotes() {

				return $this->votes;

			}

	 }

?>
Return current item: Content*Builder