1 # Copyright (c) 2007 Thiago Jackiw
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in all
11 # copies or substantial portions of the Software.
13 # The "Created with Sitealizer" footer text should not be removed from the
14 # locations where it's currently shown (under the '/sitealizer' controller)
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 require 'app/models/site_tracker'
27 require 'app/controllers/sitealizer_controller'
28 require 'sitealizer/parser'
30 SA_CONFIG = YAML::load_file(File.dirname(__FILE__)+'/config.yml') unless defined?(SA_CONFIG)
34 def initialize #:nodoc:
35 $visits = [] unless $visits
38 # This is the before_filter method that you will call when
39 # using the Sitealizer Web Stats plugin
41 # class ApplicationController < ActionController::Base
43 # before_filter :use_sitealizer
47 $visits << request.env
48 if $visits.size == SA_CONFIG['sitealizer']['queue_size']
49 thread = Thread.start{store_visits}
62 :user_agent => env['HTTP_USER_AGENT'],
63 :language => env['HTTP_ACCEPT_LANGUAGE'],
64 :path => env['PATH_INFO'],
65 :ip => env['REMOTE_ADDR'],
66 :referer => env['HTTP_REFERER']
69 open(File.dirname(__FILE__)+'/last_update','w'){|f| f.puts Time.now.to_s}
72 RAILS_ENV == 'production' ? logger.info(e) : logger.debug(e)