Class: VisitorInformation

Inherits:
VisitorInformationDlg show all
Includes:
BrowserLauncher
Defined in:
lib/VisitorInformation.rb

Instance Attribute Summary

Attributes inherited from VisitorInformationDlg

#Duration, #browser, #bytes, #city, #country, #duration, #firstSeen, #fixVisitorBtn, #groupBox30, #groupBox31, #hits, #host, #ip, #label, #largeMapBtn, #lastSeen, #latitude, #longitude, #mapFrame, #openButton, #pageList, #pages, #referer, #robot, #routeList, #splitter1, #textLabel1, #textLabel10, #textLabel12, #textLabel14, #textLabel15, #textLabel16, #textLabel16_2, #textLabel1_2, #textLabel1_3, #textLabel2, #textLabel3, #textLabel4, #textLabel6

Instance Method Summary collapse

Methods included from BrowserLauncher

#browseURL

Constructor Details

#initialize(visitor, parent = nil, name = nil) ⇒ VisitorInformation

Returns a new instance of VisitorInformation.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/VisitorInformation.rb', line 23

def initialize(visitor, parent = nil, name = nil)
  super(parent, name)
  $windowList.push(self)
  @visitor = visitor
  setCaption("Visitor Information - %s" % visitor.host)
  @pageListCSLV = CSListView.new(@pageList)
  @pageList.setSorting(3, true)
  @pageListCSLV.setColumnWidth(0, 400)
  @pageListCSLV.setColumnWidth(1, 400)
  @pageList.hideColumn(3)

  @visitorGDV = GeoDistView.new(mapFrame, nil, routeList)
  @visitorGDV.showRoutes = true
  @visitorGDV.showAll = true

  connect(@pageList, SIGNAL('clicked(QListViewItem*)'),
          SLOT('pageListClicked(QListViewItem*)'))
  connect(@openButton, SIGNAL('clicked()'), SLOT('openReferer()'))

  if $globals.getSetting("VisitorWindowW") > 0 &&
     $globals.getSetting("VisitorWindowH") > 0
    resize($globals.getSetting("VisitorWindowW"),
           $globals.getSetting("VisitorWindowH"))
  end
  @worldMapWindow = nil
  updateWindow
  show

end

Instance Method Details

#close(dummy) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/VisitorInformation.rb', line 110

def close(dummy)
  @worldMapWindow.close(true) if @worldMapWindow
  $globals.setSetting("VisitorWindowW", width())
  $globals.setSetting("VisitorWindowH", height())
  $windowList.delete(self)
  super(true)
end

#fixVisitorBtnClickedObject



123
124
125
# File 'lib/VisitorInformation.rb', line 123

def fixVisitorBtnClicked
  browseURL("http://www.hostip.info/correct.html?spip=#{@visitor.ip}")
end

#largeMapBtnClickedObject



118
119
120
121
# File 'lib/VisitorInformation.rb', line 118

def largeMapBtnClicked
  @worldMapWindow.close(true) if @worldMapWindow
  @worldMapWindow = WorldMap.new(self)
end

#openRefererObject



58
59
60
61
# File 'lib/VisitorInformation.rb', line 58

def openReferer
  return if @visitor.referer == nil
  browseURL(@visitor.referer.url)
end

#pageListClicked(item) ⇒ Object



53
54
55
56
# File 'lib/VisitorInformation.rb', line 53

def pageListClicked(item)
  return if item == nil
  win = PageInformation.new($pages[item.text(0)])
end

#updateWindowObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/VisitorInformation.rb', line 63

def updateWindow
  unless $visitors.values.include?(@visitor)
    close(true)
    return
  end

  @ip.setText(@visitor.ip)
  @host.setText(@visitor.host)
  geoloc = $geoLocator.resolve(@visitor.ip)
  if geoloc && geoloc.country != nil
    @country.setText(geoloc.country)
    @city.setText(geoloc.city)
    @latitude.setText("%7.2f" % geoloc.latitude) if geoloc.latitude
    @longitude.setText("%7.2f" % geoloc.longitude) if geoloc.longitude
    vl = { @visitor.ip => @visitor }
    @visitorGDV.update(vl)
    @worldMapWindow.update(vl) if @worldMapWindow
  end
  @hits.setText('%d' % @visitor.hitCount)
  @bytes.setText('%d' % @visitor.bytes)
  @pages.setText('%d' % @visitor.pageCount)
  @firstSeen.setText(@visitor.firstHit.timeStamp.
                     strftime("%H:%M:%S %Y/%m/%d"))
  @lastSeen.setText(@visitor.lastHit.timeStamp.
                   strftime("%H:%M:%S %Y/%m/%d"))
  @duration.setText("%d min" % ((@visitor.lastHit.timeStamp -
        @visitor.firstHit.timeStamp) / 60))
  @browser.setText(@visitor.browser)
  @robot.setText(@visitor.robot ? @visitor.robot : '')
  @referer.setText(@visitor.referer ? @visitor.referer.url : '')

  @pageListCSLV.startUpdate
  index = 0
  showRegularPages = $globals.getSetting("ShowRegularPages") != 0
  showAuxPages = $globals.getSetting("ShowAuxPages") != 0
  @visitor.hits.each do |h|
    if (h.page.isPage && !showRegularPages) ||
       (!h.page.isPage && !showAuxPages)
      next
    end
    @pageListCSLV.insertItem(h, h.page.url, h.referer ? h.referer.url : '',
                             h.timeStamp, index)
    index += 1
  end
  @pageListCSLV.finishUpdate
end

#worldMapClosedObject



127
128
129
# File 'lib/VisitorInformation.rb', line 127

def worldMapClosed
  @worldMapWindow = nil
end