I''m building an app where I''d like to track the number of views of each item, but I''d like to keep it from being spammable, so it counts unique viewers rather than just the number of pageviews. What''s a good way to go about this? Should I build a database to record the IP addresses and save the request.remote_addr for each viewer in the database, associated with each item? And then check each viewer against that item''s database of IPs to see if they''re unique before incrementing the view counter? Are there other ways of doing it? Thanks, Jeff -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2/6/07, Jeff Coleman <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m building an app where I''d like to track the number of views of each > item, but I''d like to keep it from being spammable, so it counts unique > viewers rather than just the number of pageviews. > > What''s a good way to go about this? Should I build a database to record > the IP addresses and save the request.remote_addr for each viewer in the > database, associated with each item? And then check each viewer against > that item''s database of IPs to see if they''re unique before incrementing > the view counter? > > Are there other ways of doing it?You have to take into consideration the ISPs who force user requests through their proxy servers. Those users will appear to have the same IP address a lot of the time, AOL users for example. I usually go with checking that the UP address isn''t new in the last 24 hours or so, since dial up users stand a good chance of getting assigned a different proxy their next session. If you''re using MySQL I wouldn''t store raw IP addresses. That will cost you a varchar(15) field which may be up to 16 bytes. Instead convert the IP to a signed integer before storing it. That will only cost you 4 bytes, until ipv6 gets more love anyway. def ip2long( ip ) long = 0 ip.split( /\./ ).reverse.each_with_index do |x, i| long += x.to_i << ( i * 8 ) end long end -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> I''m building an app where I''d like to track the number of views of each > item, but I''d like to keep it from being spammable, so it counts unique > viewers rather than just the number of pageviews. > > What''s a good way to go about this? Should I build a database to record > the IP addresses and save the request.remote_addr for each viewer in the > database, associated with each item? And then check each viewer against > that item''s database of IPs to see if they''re unique before incrementing > the view counter?IP address won''t work.. all the machines at my company appear as a single public IP, but there''s 50 of us... About the only thing you can do is set a cookie and hope your viewers don''t bother to delete it. Or force them to login, but that might not be an option... -philip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---