Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 269
- Log:
Overdue upgrade to AWStats v6.9, the most recent version
available at the time of writing.
- Author:
- rool
- Date:
- Wed May 27 23:57:15 +0100 2009
- Size:
- 7149 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/perl |
2 | #----------------------------------------------------------------------------- |
3 | # HostInfo AWStats plugin |
4 | # This plugin allow you to add information on hosts, like whois fields. |
5 | #----------------------------------------------------------------------------- |
6 | # Perl Required Modules: XWhois |
7 | #----------------------------------------------------------------------------- |
8 | # $Revision: 1.19 $ - $Author: eldy $ - $Date: 2008/11/15 16:03:42 $ |
9 | |
10 | |
11 | # <----- |
12 | # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES |
13 | push @INC, "${DIR}/plugins"; |
14 | if (!eval ('require "Net/XWhois.pm";')) { return $@?"Error: $@":"Error: Need Perl module Net::XWhois"; } |
15 | if (!eval ('require "Digest/MD5.pm";')) { return $@?"Error: $@":"Error: Need Perl module Digest::MD5"; } |
16 | # -----> |
17 | #use strict; |
18 | no strict "refs"; |
19 | |
20 | |
21 | |
22 | #----------------------------------------------------------------------------- |
23 | # PLUGIN VARIABLES |
24 | #----------------------------------------------------------------------------- |
25 | # <----- |
26 | # ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN |
27 | # AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE. |
28 | my $PluginNeedAWStatsVersion="6.0"; |
29 | my $PluginHooksFunctions="ShowInfoHost AddHTMLBodyHeader BuildFullHTMLOutput"; |
30 | # -----> |
31 | |
32 | # <----- |
33 | # IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE. |
34 | use vars qw/ |
35 | /; |
36 | # -----> |
37 | |
38 | |
39 | |
40 | #----------------------------------------------------------------------------- |
41 | # PLUGIN FUNCTION: Init_pluginname |
42 | #----------------------------------------------------------------------------- |
43 | sub Init_hostinfo { |
44 | my $InitParams=shift; |
45 | my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion); |
46 | |
47 | # <----- |
48 | # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS |
49 | debug(" Plugin hostinfo: InitParams=$InitParams",1); |
50 | # -----> |
51 | |
52 | return ($checkversion?$checkversion:"$PluginHooksFunctions"); |
53 | } |
54 | |
55 | |
56 | |
57 | #----------------------------------------------------------------------------- |
58 | # PLUGIN FUNCTION: AddHTMLBodyHeader_pluginname |
59 | # UNIQUE: NO (Several plugins using this function can be loaded) |
60 | # Function called to Add HTML code at beginning of BODY section. |
61 | # Parameters: None |
62 | #----------------------------------------------------------------------------- |
63 | sub AddHTMLBodyHeader_hostinfo { |
64 | # <----- |
65 | my $WIDTHINFO=640; |
66 | my $HEIGHTINFO=480; |
67 | |
68 | my $urlparam="pluginmode=hostinfo&config=$SiteConfig"; |
69 | $urlparam.=($DirConfig?"&configdir=$DirConfig":""); |
70 | |
71 | print <<EOF; |
72 | |
73 | <script type="text/javascript"> |
74 | function neww(a,b) { |
75 | var wfeatures="directories=0,menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,width=$WIDTHINFO,height=$HEIGHTINFO,left=" + eval("(screen.width - $WIDTHINFO)/2") + ",top=" + eval("(screen.height - $HEIGHTINFO)/2"); |
76 | EOF |
77 | print "fen=window.open('".XMLEncode("$AWScript?$urlparam&host")."='+a+'".XMLEncode("&key")."='+b,'whois',wfeatures);\n"; |
78 | print <<EOF; |
79 | } |
80 | </script> |
81 | |
82 | EOF |
83 | |
84 | return 1; |
85 | # -----> |
86 | } |
87 | |
88 | |
89 | #----------------------------------------------------------------------------- |
90 | # PLUGIN FUNCTION: ShowInfoHost_pluginname |
91 | # UNIQUE: NO (Several plugins using this function can be loaded) |
92 | # Function called to add additionnal columns to the Hosts report. |
93 | # This function is called when building rows of the report (One call for each |
94 | # row). So it allows you to add a column in report, for example with code : |
95 | # print "<TD>This is a new cell for $param</TD>"; |
96 | # Parameters: Host name or ip |
97 | #----------------------------------------------------------------------------- |
98 | sub ShowInfoHost_hostinfo { |
99 | my $param="$_[0]"; |
100 | # <----- |
101 | if ($param eq '__title__') { |
102 | print "<th width=\"40\">$Message[114]</th>"; |
103 | } |
104 | elsif ($param) { |
105 | my $keyforwhois; |
106 | if ($param =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) { # IPv4 address |
107 | $keyforwhois=$param; |
108 | } |
109 | elsif ($param =~ /^[0-9A-F]*:/i) { # IPv6 address |
110 | $keyforwhois=$param; |
111 | } |
112 | else { # Hostname |
113 | $param =~ /([-\w]+\.[-\w]+\.(?:au|uk|jp|nz))$/ or $param =~ /([-\w]+\.[-\w]+)$/; |
114 | $keyforwhois=$1; |
115 | } |
116 | print "<td>"; |
117 | # if ($keyforwhois) { print "<a href=\"javascript:neww('$keyforwhois','".md5_hex("${keyforwhois}XXX")."')\">?</a>"; } |
118 | if ($keyforwhois) { print "<a href=\"javascript:neww('$keyforwhois','${keyforwhois}XXX')\">?</a>"; } |
119 | else { print " " } |
120 | print "</td>"; |
121 | } |
122 | else { |
123 | print "<td> </td>"; |
124 | } |
125 | return 1; |
126 | # -----> |
127 | } |
128 | |
129 | |
130 | #----------------------------------------------------------------------------- |
131 | # PLUGIN FUNTION: BuildFullHTMLOutput_pluginname |
132 | # UNIQUE: NO (Several plugins using this function can be loaded) |
133 | # Function called to output an HTML page completely built by plugin instead |
134 | # of AWStats output |
135 | #----------------------------------------------------------------------------- |
136 | sub BuildFullHTMLOutput_hostinfo { |
137 | # <----- |
138 | my $Host=''; |
139 | if ($QueryString =~ /host=([^&]+)/i) { |
140 | $Host=lc(&DecodeEncodedString("$1")); |
141 | } |
142 | |
143 | my $ip=''; |
144 | my $HostResolved=''; |
145 | # my $regipv4=qr/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; |
146 | # my $regipv6=qr/^[0-9A-F]*:/i; |
147 | # if ($Host =~ /$regipv4/o) { $ip=4; } |
148 | # elsif ($Host =~ /$regipv6/o) { $ip=6; } |
149 | # if ($ip == 4) { |
150 | # my $lookupresult=lc(gethostbyaddr(pack("C4",split(/\./,$Host)),AF_INET)); # This is very slow, may spend 20 seconds |
151 | # if (! $lookupresult || $lookupresult =~ /$regipv4/o || ! IsAscii($lookupresult)) { |
152 | # $HostResolved='*'; |
153 | # } |
154 | # else { |
155 | # $HostResolved=$lookupresult; |
156 | # } |
157 | # if ($Debug) { debug(" Reverse DNS lookup for $Host done: $HostResolved",4); } |
158 | # } |
159 | if (! $ip) { $HostResolved=$Host; } |
160 | |
161 | if ($Debug) { debug(" Plugin hostinfo: DirData=$DirData Host=$Host HostResolved=$HostResolved ",4); } |
162 | my $w = new Net::XWhois Verbose=>$Debug, Cache=>$DirData, NoCache=>0, Timeout=>10, Domain=>$HostResolved; |
163 | |
164 | print "<br />\n"; |
165 | |
166 | if ($w && $w->response()) { |
167 | &tab_head("Common Whois Fields",0,0,'whois'); |
168 | print "<tr bgcolor=\"#$color_TableBGRowTitle\"><th>Common field info</th><th>Value</th></tr>\n"; |
169 | print "<tr><td>Name</td><td>".($w->name())." </td></tr>"; |
170 | print "<tr><td>Status</td><td>".($w->status())." </td></tr>"; |
171 | print "<tr><td>NameServers</td><td>".($w->nameservers())." </td></tr>"; |
172 | print "<tr><td>Registrant</td><td>".($w->registrant())." </td></tr>"; |
173 | print "<tr><td>Contact Admin</td><td>".($w->contact_admin())." </td></tr>"; |
174 | print "<tr><td>Contact Tech</td><td>".($w->contact_tech())." </td></tr>"; |
175 | print "<tr><td>Contact Billing</td><td>".($w->contact_billing())." </td></tr>"; |
176 | print "<tr><td>Contact Zone</td><td>".($w->contact_zone())." </td></tr>"; |
177 | print "<tr><td>Contact Emails</td><td>".($w->contact_emails())." </td></tr>"; |
178 | print "<tr><td>Contact Handles</td><td>".($w->contact_handles())." </td></tr>"; |
179 | print "<tr><td>Domain Handles</td><td>".($w->domain_handles())." </td></tr>"; |
180 | &tab_end; |
181 | } |
182 | |
183 | &tab_head("Full Whois Field",0,0,'whois'); |
184 | if ($w && $w->response()) { |
185 | print "<tr><td class=\"aws\"><pre>".($w->response())."</pre></td></tr>\n"; |
186 | } |
187 | else { |
188 | print "<tr><td><br />The Whois command failed.<br />Did the server running AWStats is allowed to send WhoIs queries (If a firewall is running, port 43 should be opened from inside to outside) ?<br /><br /></td></tr>\n"; |
189 | } |
190 | &tab_end; |
191 | |
192 | return 1; |
193 | # -----> |
194 | } |
195 | |
196 | 1; # Do not remove this line |