Index: fivestar.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fivestar/fivestar.module,v
retrieving revision 1.2.2.105
diff -u -r1.2.2.105 fivestar.module
--- fivestar.module	5 Oct 2008 21:13:16 -0000	1.2.2.105
+++ fivestar.module	5 Oct 2008 22:37:17 -0000
@@ -699,17 +699,9 @@
 
   // Prep variables for anonymous vs. registered voting.
   if (!isset($uid)) {
-    if ($user->uid) {
-      $uid = $user->uid;
-    }
-    else {
-      $uid = 0;
-      $hostname = $_SERVER['REMOTE_ADDR'];
-      if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
-        $hostname .= '-'. $_SERVER['HTTP_X_FORWARDED_FOR'];
-      }
-    }
+    $uid = $user->uid;
   }
+
   $anon_interval = variable_get('fivestar_anonymous_vote_interval', 86400);
 
   // Sanity-check the incoming values.
@@ -725,6 +717,11 @@
     }
     else {
       // Otherwise, we'll look for votes from the same IP address within the anonymous interval.
+      $hostname = $_SERVER['REMOTE_ADDR'];
+      if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+        $hostname .= '-'. $_SERVER['HTTP_X_FORWARDED_FOR'];
+      }
+
       $sql = "SELECT vote_id FROM {votingapi_vote} WHERE content_type='%s' AND content_id=%d AND value_type='percent' AND uid=%d AND tag = '%s' AND hostname='%s'";
       $sql .= $anon_interval != -1 ? " AND timestamp > %d" : '';
       $result = db_query($sql, $type, $cid, $uid, $tag, $hostname, time() - $anon_interval);
