ClickSpotter 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,94 @@
1
+ #
2
+ # VisitorRecord.rb - ClickSpotter
3
+ #
4
+ # Copyright (c) 2005, 2006 by Chris Schlaeger <cs@kde.org>
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of version 2 of the GNU General Public License as
7
+ # published by the Free Software Foundation.
8
+ #
9
+ # $Id: VisitorRecord.rb 8 2006-01-22 15:19:51Z cs $
10
+ #
11
+
12
+ require 'HitRecord'
13
+ require 'DNSResolver'
14
+
15
+ class VisitorRecord
16
+
17
+ attr_reader :ip, :browser, :pageCount, :firstHit, :lastHit, :firstPage,
18
+ :lastPage, :robot, :hits
19
+ attr_writer :robot
20
+
21
+ def initialize(ip, browser)
22
+ @hits = []
23
+ @ip = ip
24
+ @firstHit = nil
25
+ @lastHit = nil
26
+ @firstPage = nil
27
+ @lastPage = nil
28
+ @browser = browser
29
+ @pageCount = 0
30
+ @robot = nil
31
+ end
32
+
33
+ def addHit(hit)
34
+ @firstHit = hit if @firstHit == nil
35
+ @lastHit = hit
36
+ @hits.push(hit)
37
+ hit.visitor = self
38
+
39
+ if hit.page.isPage
40
+ # Remove old exit page flag from previous last page
41
+ @lastPage.exit = false if @lastPage
42
+ hit.exit = true
43
+ @pageCount += 1
44
+ if @firstPage == nil
45
+ @firstPage = hit
46
+ hit.entry = true
47
+ end
48
+ @lastPage = hit
49
+ end
50
+ end
51
+
52
+ def purge(deadline)
53
+ @hits.each do |h|
54
+ if h.timeStamp < deadline
55
+ @hits.delete(h)
56
+ else
57
+ return false
58
+ end
59
+ end
60
+ @hits.empty?
61
+ end
62
+
63
+ def host
64
+ return $resolver.hostName(@ip)
65
+ end
66
+
67
+ def hitCount
68
+ return @hits.length()
69
+ end
70
+
71
+ def bytes
72
+ bytes = 0
73
+ @hits.each do |h|
74
+ bytes += h.bytes
75
+ end
76
+ return bytes
77
+ end
78
+
79
+ def referer
80
+ @hits.each do |h|
81
+ return h.referer if h.referer != nil && h.referer.external?
82
+ end
83
+ return nil
84
+ end
85
+
86
+ def country
87
+ $geoLocator.country(ip)
88
+ end
89
+
90
+ def city
91
+ $geoLocator.city(ip)
92
+ end
93
+
94
+ end
@@ -0,0 +1,93 @@
1
+ #
2
+ # WorldMap.rb - ClickSpotter
3
+ #
4
+ # Copyright (c) 2005, 2006 by Chris Schlaeger <cs@kde.org>
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of version 2 of the GNU General Public License as
7
+ # published by the Free Software Foundation.
8
+ #
9
+ # $Id: WorldMap.rb 8 2006-01-22 15:19:51Z cs $
10
+ #
11
+
12
+ require 'WorldMapDlg'
13
+
14
+ class WorldMap < WorldMapDlg
15
+
16
+ def initialize(masterWindow)
17
+ super(nil)
18
+
19
+ @masterWindow = masterWindow
20
+ @gdv = GeoDistView.new(mapFrame, nil, nil, true)
21
+
22
+ if $globals.getSetting('LargeMapW') > 0 &&
23
+ $globals.getSetting('LargeMapH') > 0
24
+ resize($globals.getSetting('LargeMapW'),
25
+ $globals.getSetting('LargeMapH'))
26
+ end
27
+
28
+ @showIPsCB.checked = $globals.getSetting("WMShowIPs")
29
+ @showCitiesCB.checked = $globals.getSetting("WMShowCityNames")
30
+ @showHostNamesCB.checked = $globals.getSetting("WMShowHostNames")
31
+ @showRoutersCB.checked = $globals.getSetting("WMShowRouters")
32
+ @showRoutesCB.checked = $globals.getSetting("WMShowRoutes")
33
+ @showLastCB.checked = $globals.getSetting("WMShowLast")
34
+ @lastMinutes.value = $globals.getSetting("WMLastMinutes")
35
+
36
+ show
37
+ end
38
+
39
+ def update(visitors)
40
+ @gdv.update(visitors)
41
+ end
42
+
43
+ def close(dummy)
44
+ $globals.setSetting('LargeMapW', width)
45
+ $globals.setSetting('LargeMapH', height)
46
+ $globals.setSetting('WMShowIPs', @showIPsCB.isChecked)
47
+ $globals.setSetting('WMShowHostNames', @showHostNamesCB.isChecked)
48
+ $globals.setSetting('WMShowCityNames', @showCitiesCB.isChecked)
49
+ $globals.setSetting('WMShowRouters', @showRoutersCB.isChecked)
50
+ $globals.setSetting('WMShowRoutes', @showRoutesCB.isChecked)
51
+ $globals.setSetting('WMShowLast', @showLastCB.isChecked)
52
+ $globals.setSetting('WMLastMinutes', @lastMinutes.value)
53
+ # Enabling showRoutes can pump a whole lot of requests into these queues.
54
+ # So we flush them. All still needed requests will quickly be done again.
55
+ $traceRouter.flushQueue
56
+ $geoLocator.flushQueue
57
+
58
+ @masterWindow.worldMapClosed
59
+
60
+ super(true)
61
+ end
62
+
63
+ def showRoutersCBToggled(newVal)
64
+ @gdv.showRouters = newVal
65
+ end
66
+
67
+ def showRoutesCBToggled(newVal)
68
+ @gdv.showRoutes = newVal
69
+ end
70
+
71
+ def showIPsCBToggled(newVal)
72
+ @gdv.showIPs = newVal
73
+ end
74
+
75
+ def showHostNamesCBToggled(newVal)
76
+ @gdv.showHostNames = newVal
77
+ end
78
+
79
+ def showCitiesCBToggled(newVal)
80
+ @gdv.showCities = newVal
81
+ end
82
+
83
+ def showLastCBToggled(newVal)
84
+ @gdv.showLast = newVal
85
+ @lastMinutes.enabled = newVal
86
+ end
87
+
88
+ def lastMinutesValueChanged(val)
89
+ @gdv.lastMinutes = val
90
+ end
91
+
92
+ end
93
+
@@ -0,0 +1,166 @@
1
+ # Form implementation generated from reading ui file 'WorldMapDlg.ui'
2
+ #
3
+ # Created: Mon Jan 23 23:21:52 2006
4
+ # by: The QtRuby User Interface Compiler (rbuic)
5
+ #
6
+ # WARNING! All changes made in this file will be lost!
7
+
8
+
9
+ require 'Qt'
10
+
11
+ class WorldMapDlg < Qt::Widget
12
+
13
+ slots 'languageChange()',
14
+ 'showCitiesCBToggled(bool)',
15
+ 'showIPsCBToggled(bool)',
16
+ 'showRoutesCBToggled(bool)',
17
+ 'showHostNamesCBToggled(bool)',
18
+ 'showLastCBToggled(bool)',
19
+ 'lastMinutesValueChanged(int)',
20
+ 'showRoutersCBToggled(bool)'
21
+
22
+ attr_reader :mapFrame
23
+ attr_reader :textLabel2
24
+ attr_reader :lastMinutes
25
+ attr_reader :showRoutersCB
26
+ attr_reader :showIPsCB
27
+ attr_reader :showHostNamesCB
28
+ attr_reader :showCitiesCB
29
+ attr_reader :showRoutesCB
30
+ attr_reader :showLastCB
31
+ attr_reader :closeBtn
32
+
33
+
34
+ def initialize(parent = nil, name = nil, fl = 0)
35
+ super
36
+
37
+ if name.nil?
38
+ setName("WorldMapDlg")
39
+ end
40
+ setSizePolicy(Qt::SizePolicy.new(5, 5, 0, 0, self.sizePolicy().hasHeightForWidth()))
41
+
42
+ @WorldMapDlgLayout = Qt::GridLayout.new(self, 1, 1, 11, 6, 'WorldMapDlgLayout')
43
+
44
+ @mapFrame = Qt::GroupBox.new(self, "mapFrame")
45
+
46
+ @WorldMapDlgLayout.addMultiCellWidget(@mapFrame, 0, 0, 0, 10)
47
+ @spacer4 = Qt::SpacerItem.new(30, 20, Qt::SizePolicy::Expanding, Qt::SizePolicy::Minimum)
48
+ @WorldMapDlgLayout.addItem(@spacer4, 1, 9)
49
+
50
+ @textLabel2 = Qt::Label.new(self, "textLabel2")
51
+
52
+ @WorldMapDlgLayout.addWidget(@textLabel2, 1, 8)
53
+
54
+ @lastMinutes = Qt::SpinBox.new(self, "lastMinutes")
55
+ @lastMinutes.setEnabled( false )
56
+ @lastMinutes.setMaxValue( 32767 )
57
+ @lastMinutes.setMinValue( 1 )
58
+
59
+ @WorldMapDlgLayout.addWidget(@lastMinutes, 1, 7)
60
+ @spacer7 = Qt::SpacerItem.new(20, 21, Qt::SizePolicy::Expanding, Qt::SizePolicy::Minimum)
61
+ @WorldMapDlgLayout.addItem(@spacer7, 1, 5)
62
+
63
+ @showRoutersCB = Qt::CheckBox.new(self, "showRoutersCB")
64
+
65
+ @WorldMapDlgLayout.addWidget(@showRoutersCB, 1, 3)
66
+
67
+ @showIPsCB = Qt::CheckBox.new(self, "showIPsCB")
68
+
69
+ @WorldMapDlgLayout.addWidget(@showIPsCB, 1, 0)
70
+
71
+ @showHostNamesCB = Qt::CheckBox.new(self, "showHostNamesCB")
72
+
73
+ @WorldMapDlgLayout.addWidget(@showHostNamesCB, 1, 1)
74
+
75
+ @showCitiesCB = Qt::CheckBox.new(self, "showCitiesCB")
76
+
77
+ @WorldMapDlgLayout.addWidget(@showCitiesCB, 1, 2)
78
+
79
+ @showRoutesCB = Qt::CheckBox.new(self, "showRoutesCB")
80
+
81
+ @WorldMapDlgLayout.addWidget(@showRoutesCB, 1, 4)
82
+
83
+ @showLastCB = Qt::CheckBox.new(self, "showLastCB")
84
+
85
+ @WorldMapDlgLayout.addWidget(@showLastCB, 1, 6)
86
+
87
+ @closeBtn = Qt::PushButton.new(self, "closeBtn")
88
+
89
+ @WorldMapDlgLayout.addWidget(@closeBtn, 1, 10)
90
+ languageChange()
91
+ resize( Qt::Size.new(1033, 878).expandedTo(minimumSizeHint()) )
92
+ clearWState( WState_Polished )
93
+
94
+ Qt::Object.connect(@showCitiesCB, SIGNAL("toggled(bool)"), self, SLOT("showCitiesCBToggled(bool)") )
95
+ Qt::Object.connect(@showIPsCB, SIGNAL("toggled(bool)"), self, SLOT("showIPsCBToggled(bool)") )
96
+ Qt::Object.connect(@showRoutesCB, SIGNAL("toggled(bool)"), self, SLOT("showRoutesCBToggled(bool)") )
97
+ Qt::Object.connect(@closeBtn, SIGNAL("clicked()"), self, SLOT("close()") )
98
+ Qt::Object.connect(@showHostNamesCB, SIGNAL("toggled(bool)"), self, SLOT("showHostNamesCBToggled(bool)") )
99
+ Qt::Object.connect(@showLastCB, SIGNAL("toggled(bool)"), self, SLOT("showLastCBToggled(bool)") )
100
+ Qt::Object.connect(@lastMinutes, SIGNAL("valueChanged(int)"), self, SLOT("lastMinutesValueChanged(int)") )
101
+ Qt::Object.connect(@showRoutersCB, SIGNAL("toggled(bool)"), self, SLOT("showRoutersCBToggled(bool)") )
102
+
103
+ setTabOrder(@showIPsCB, @showHostNamesCB)
104
+ setTabOrder(@showHostNamesCB, @showCitiesCB)
105
+ setTabOrder(@showCitiesCB, @showRoutersCB)
106
+ setTabOrder(@showRoutersCB, @showRoutesCB)
107
+ setTabOrder(@showRoutesCB, @showLastCB)
108
+ setTabOrder(@showLastCB, @lastMinutes)
109
+ setTabOrder(@lastMinutes, @closeBtn)
110
+ end
111
+
112
+ #
113
+ # Sets the strings of the subwidgets using the current
114
+ # language.
115
+ #
116
+ def languageChange()
117
+ setCaption(trUtf8("Woldmap"))
118
+ @mapFrame.setTitle( trUtf8("Worldmap") )
119
+ @textLabel2.setText( trUtf8("minutes") )
120
+ @showRoutersCB.setText( trUtf8("Show &Routers") )
121
+ @showRoutersCB.setAccel( Qt::KeySequence.new(trUtf8("Alt+R")) )
122
+ @showIPsCB.setText( trUtf8("Show &IPs") )
123
+ @showIPsCB.setAccel( Qt::KeySequence.new(trUtf8("Alt+I")) )
124
+ @showHostNamesCB.setText( trUtf8("Show &Host Names") )
125
+ @showHostNamesCB.setAccel( Qt::KeySequence.new(trUtf8("Alt+H")) )
126
+ @showCitiesCB.setText( trUtf8("Show &City Names") )
127
+ @showCitiesCB.setAccel( Qt::KeySequence.new(trUtf8("Alt+C")) )
128
+ @showRoutesCB.setText( trUtf8("Show R&outes") )
129
+ @showRoutesCB.setAccel( Qt::KeySequence.new(trUtf8("Alt+O")) )
130
+ @showLastCB.setText( trUtf8("Show only &last") )
131
+ @showLastCB.setAccel( Qt::KeySequence.new(trUtf8("Alt+L")) )
132
+ @closeBtn.setText( trUtf8("Close &Window") )
133
+ @closeBtn.setAccel( Qt::KeySequence.new(trUtf8("Alt+W")) )
134
+ end
135
+ protected :languageChange
136
+
137
+
138
+ def showCitiesCBToggled(*k)
139
+ print("WorldMapDlg.showCitiesCBToggled(bool): Not implemented yet.\n")
140
+ end
141
+
142
+ def showIPsCBToggled(*k)
143
+ print("WorldMapDlg.showIPsCBToggled(bool): Not implemented yet.\n")
144
+ end
145
+
146
+ def showRoutesCBToggled(*k)
147
+ print("WorldMapDlg.showRoutesCBToggled(bool): Not implemented yet.\n")
148
+ end
149
+
150
+ def showHostNamesCBToggled(*k)
151
+ print("WorldMapDlg.showHostNamesCBToggled(bool): Not implemented yet.\n")
152
+ end
153
+
154
+ def showLastCBToggled(*k)
155
+ print("WorldMapDlg.showLastCBToggled(bool): Not implemented yet.\n")
156
+ end
157
+
158
+ def lastMinutesValueChanged(*k)
159
+ print("WorldMapDlg.lastMinutesValueChanged(int): Not implemented yet.\n")
160
+ end
161
+
162
+ def showRoutersCBToggled(*k)
163
+ print("WorldMapDlg.showRoutersCBToggled(bool): Not implemented yet.\n")
164
+ end
165
+
166
+ end
@@ -0,0 +1,38 @@
1
+ #
2
+ # clickspotter.rb - ClickSpotter
3
+ #
4
+ # Copyright (c) 2005, 2006 by Chris Schlaeger <cs@kde.org>
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of version 2 of the GNU General Public License as
7
+ # published by the Free Software Foundation.
8
+ #
9
+ # $Id: clickspotter.rb 10 2006-01-23 14:29:58Z cs $
10
+ #
11
+
12
+ # :main: README
13
+
14
+ require 'AppConfig'
15
+ require 'Qt'
16
+ require 'GlobalSettings'
17
+ require 'MainWindow'
18
+ require 'DNSResolver'
19
+ require 'GeoLocator'
20
+ require 'TraceRouter'
21
+
22
+ # Configure the application
23
+ AppConfig.version = "0.1.1"
24
+ AppConfig.name = "ClickSpotter"
25
+
26
+ # Create global settings class and read persistent settings
27
+ $globals = GlobalSettings.new(ARGV[0])
28
+
29
+ # Create asynchronos resolvers
30
+ $resolver = DNSResolver.new
31
+ $geoLocator = GeoLocator.new
32
+ $traceRouter = TraceRouter.new
33
+
34
+ # Create main widget and enter mail loop
35
+ qApp = Qt::Application.new(ARGV)
36
+ qApp.setMainWidget(MainWindow.new)
37
+ qApp.exec
38
+
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: ClickSpotter
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.1
7
+ date: 2006-01-23 00:00:00 +01:00
8
+ summary: Real-Time webserver usage monitor with IP Geolocation
9
+ require_paths:
10
+ - lib
11
+ email: cs@kde.org
12
+ homepage: http://clickspotter.ath.cx
13
+ rubyforge_project:
14
+ description:
15
+ autorequire: clickspotter
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.4
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Chris Schlaeger
30
+ files:
31
+ - lib/RefererRecord.rb
32
+ - lib/CSListView.rb
33
+ - lib/AppConfig.rb
34
+ - lib/OccurenceCounter.rb
35
+ - lib/TraceRouter.rb
36
+ - lib/About.rb
37
+ - lib/BrowserLauncher.rb
38
+ - lib/HostNameDlg.rb
39
+ - lib/GSServerLogSettings.rb
40
+ - lib/Configuration.rb
41
+ - lib/LogParser.rb
42
+ - lib/MainWindowDlg.rb
43
+ - lib/PageInformation.rb
44
+ - lib/GlobalSettings.rb
45
+ - lib/AboutDlg.rb
46
+ - lib/LogFileSelector.rb
47
+ - lib/StatusCode.rb
48
+ - lib/CSListViewItem.rb
49
+ - lib/ClickableCanvasView.rb
50
+ - lib/LogFileSelectorDlg.rb
51
+ - lib/VisitorInformationDlg.rb
52
+ - lib/PageInformationDlg.rb
53
+ - lib/ServerLogSettings.rb
54
+ - lib/MainWindow.rb
55
+ - lib/clickspotter.rb
56
+ - lib/AsyncResolverWithCache.rb
57
+ - lib/RefererInformationDlg.rb
58
+ - lib/RefererInformation.rb
59
+ - lib/VisitorRecord.rb
60
+ - lib/WorldMapDlg.rb
61
+ - lib/WorldMap.rb
62
+ - lib/GeoLocator.rb
63
+ - lib/PageRecord.rb
64
+ - lib/VisitorInformation.rb
65
+ - lib/GeoDistView.rb
66
+ - lib/ConfigurationDlg.rb
67
+ - lib/ServerLogSettingsDlg.rb
68
+ - lib/DNSResolver.rb
69
+ - lib/HitRecord.rb
70
+ - data/worldmap.png
71
+ - data/worldmap-large.jpg
72
+ - bin/clickspotter
73
+ - README
74
+ test_files: []
75
+
76
+ rdoc_options: []
77
+
78
+ extra_rdoc_files:
79
+ - README
80
+ executables:
81
+ - clickspotter
82
+ extensions: []
83
+
84
+ requirements:
85
+ - qtruby
86
+ dependencies: []
87
+