Record "XMLRPC Request" in ipadress field of XML RPC created votes.
authorJohn Dong <jdong@mit.edu>
Wed, 15 Aug 2007 21:03:41 +0000 (17:03 -0400)
committerJohn Dong <jdong@mit.edu>
Wed, 15 Aug 2007 21:03:41 +0000 (17:03 -0400)
Added IPAddr verification of IP Addresses

app/models/selectricity_service.rb
app/views/quickvote/results.rhtml

index ac2ef205261198986e1add69fe7e3178828bad85..add5ab9c2bb08f951ce315c852f6f9ba9bf2a140 100644 (file)
@@ -7,7 +7,7 @@ class SelectricityService < ActionWebService::Base
     if election
       voter = QuickVoter.new
       voter.election = election
-      voter.ipaddress = "0.0.0.0"
+      voter.ipaddress = "XMLRPC Request"
       voter.session_id = "XMLRPC:#{voter_id}"
       voter.vote=Vote.new
       voter.vote.votes=vote_list[0]
index 1fad7ea36a907186d565ff633e7877b0fe1613b6..98a71e54c97cdf8f05368832506b5b5ba8f5327d 100644 (file)
@@ -1,4 +1,4 @@
-<% %>
+<%require 'IPAddr' %>
 <h1>Results</h1>
 
 <% if @election.shortdesc %>
@@ -156,7 +156,13 @@ by several other names.</p>
   <% next unless voter.voted? %>
   <tr>
   <td><%= voter.ipaddress %></td>
-  <td><%= `host #{voter.ipaddress}`.sub(/^.*pointer (.*)\.$/, '\1') %></td>
+  <td><% begin %>
+      <%= `host #{IPAddr.new(voter.ipaddress).to_s}`.sub(/^.*pointer (.*)\.$/, '\1') %>
+    
+    <% rescue ArgumentError => err %>
+      <%= " - " %>
+    <% end %>
+    </td>
   <td><%= voter.vote.votestring %></td>
   </tr>
 <% end %>

Benjamin Mako Hill || Want to submit a patch?