12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/concen/visits_controller.rb', line 12
def record
current_time = Time.now.utc
current_hour = Time.utc(current_time.year, current_time.month, current_time.day, current_time.hour)
Visit::Page.collection.update(
{:url => params[:u], :hour => current_hour},
{"$inc" => {:count => 1}, "$set" => {:title => params[:t]}},
:upsert => true, :safe => false
)
begin
referral_url = params[:r]
referral = Domainatrix.parse(referral_url)
referral_domain = referral.domain + "." + referral.public_suffix
rescue
referral_url = nil
referral_domain = nil
end
Visit::Referral.collection.update(
{:url => referral_url, :hour => current_hour},
{"$inc" => {:count => 1}, "$set" => {:domain => referral_domain}},
:upsert => true, :safe => false
)
image_path = "#{Concen::Engine.root}/app/assets/images/concen/record-visit.gif"
send_file image_path, :type => "image/gif", :disposition => "inline"
end
|