Added Analytics function to track user hits by ip address, referrer and user agent
This commit is contained in:
@@ -5,7 +5,23 @@ class AdminController < ApplicationController
|
||||
|
||||
def dashboard
|
||||
end
|
||||
|
||||
|
||||
def analytics
|
||||
|
||||
if params[:field].nil?
|
||||
fields = "*"
|
||||
else
|
||||
fields = params[:field].map {|k,v| k}.join(",")
|
||||
end
|
||||
|
||||
if params[:ip]
|
||||
@analytics = Analytics.hits_by_ip(params[:ip], fields)
|
||||
else
|
||||
@analytics = Analytics.all
|
||||
end
|
||||
render "layouts/admin/_analytics"
|
||||
end
|
||||
|
||||
def get_all_users
|
||||
@users = User.all
|
||||
render :partial => "layouts/admin/get_all_users"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
|
||||
before_filter :authenticated, :has_info
|
||||
before_filter :authenticated, :has_info, :create_analytic
|
||||
helper_method :current_user, :is_admin?, :sanitize_font
|
||||
|
||||
# Our security guy keep talking about sea-surfing, cool story bro.
|
||||
@@ -45,6 +45,10 @@ class ApplicationController < ActionController::Base
|
||||
redirect_to home_dashboard_index_path if redirect
|
||||
end
|
||||
|
||||
def create_analytic
|
||||
Analytics.create({ :ip_address => request.remote_ip, :referrer => request.referrer, :user_agent => request.user_agent})
|
||||
end
|
||||
|
||||
def sanitize_font(css)
|
||||
css
|
||||
# css if css.match(/\A[0-9]+([\%]|pt)\z/)
|
||||
|
||||
Reference in New Issue
Block a user