module WPSessioniser
WPSessioniser
¶ ↑
Example Usage¶ ↑
file = File.open("/var/log/apache/access.log") visitors = WPSessioniser.parse(file)
Constants
- FORMAT
Changing this string breaks parsing. I don't know why.
- PARSER
Public Class Methods
parse(file)
click to toggle source
# File lib/wp-sessioniser.rb, line 29 def WPSessioniser.parse file visitors = Hash.new() file.each do |line| h = PARSER.parse! line #Ignore non-pages next if h["%r"] !~ /GET/ next if h["%r"] =~ /xmlrpc.php/ next if h["%r"] =~ /favicon.ico/ next if h["%r"] =~ /robots.txt/ next if h["%r"] =~ /\?sccss/ next if h["%r"] =~ /wp-admin/ next if h["%r"] =~ /wp-content/ next if h["%r"] =~ /wp-includes/ next if h["%r"] =~ /wp-json/ next if h["%r"] =~ /\/\/images/ next if h["%r"] =~ /\?plugin=/ page = h["%r"].delete('GET ', '').delete(' HTTP/1.1', '') if visitors.has_key? h["%h"] visitors[h["%h"]].push_hit page, h["%t"] else visitors[h["%h"]] = Visitor.new visitors[h["%h"]].push_hit page, h["%t"] end end return visitors end