--- votingapi.module	2008-04-23 20:40:33.000000000 -0400
+++ votingapiNEW.module	2008-04-23 20:39:59.000000000 -0400
@@ -92,8 +92,18 @@ function votingapi_set_vote($content_typ
     if (!isset($vote->tag)) {
       $vote->tag = VOTINGAPI_VALUE_DEFAULT_TAG;
     }
+    
+  	$hostname = $_SERVER['REMOTE_ADDR'];
+	  if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+	    $hostname .= '-' . $_SERVER['HTTP_X_FORWARDED_FOR'];
+	  }
+	  
+		if ($uid) { //registered user - check if vote exists from same user account
+	    $result = db_query("SELECT * FROM {votingapi_vote} WHERE content_type='%s' AND content_id=%d AND tag='%s' AND value_type='%s' AND uid=%d", $content_type, $content_id, $vote->tag, $vote->value_type, $uid);
+		} else { //anonymous user - check if vote exists from anonymous user with same IP
+    	$result = db_query("SELECT * FROM {votingapi_vote} WHERE content_type='%s' AND content_id=%d AND tag='%s' AND value_type='%s' AND uid=%d AND hostname='%s'", $content_type, $content_id, $vote->tag, $vote->value_type, $uid, $hostname);
+		}
 
-    $result = db_query("SELECT * FROM {votingapi_vote} WHERE content_type='%s' AND content_id=%d AND tag='%s' AND value_type='%s' AND uid=%d", $content_type, $content_id, $vote->tag, $vote->value_type, $uid);
     while ($vobj = db_fetch_object($result)) {
       votingapi_change_vote($vobj, $vote->value);
       $exists = TRUE;
