From e95ac18c740e1b02823e39c9e8d24293dec0cfc1 Mon Sep 17 00:00:00 2001 From: eldy <> Date: Fri, 5 Dec 2003 21:44:08 +0000 Subject: [PATCH] The link to whois informations for a host, provided by hostinfo plugin, has been replaced by an internal 'whois' showing in a popup window full whois informations whatever is the TLD of IP or host name. --- docs/awstats_changelog.txt | 3 ++ docs/awstats_config.html | 26 ++++------ tools/awstats_buildstaticpages.pl | 4 +- wwwroot/cgi-bin/awstats.model.conf | 23 ++------- wwwroot/cgi-bin/awstats.pl | 11 +++-- wwwroot/cgi-bin/plugins/hostinfo.pm | 75 ++++++++++++++++++++++++++--- 6 files changed, 93 insertions(+), 49 deletions(-) diff --git a/docs/awstats_changelog.txt b/docs/awstats_changelog.txt index 76511dc3..df936ba8 100644 --- a/docs/awstats_changelog.txt +++ b/docs/awstats_changelog.txt @@ -42,6 +42,9 @@ New features/improvements: supported for the moment). - A lot of part of codes have been rewritten to make code more easy to understand and reduce unknown bugs. +- The link to whois informations for a host, provided by hostinfo plugin, + has been replaced by an internal 'whois' showing in a popup window full + whois informations whatever is the TLD of IP or host name. - A new search engine database to allow several "match id" for same search engine. Example: All google ip referer id are recognised. - Can use UA and HOST fields to build personalized ExtraSection reports. diff --git a/docs/awstats_config.html b/docs/awstats_config.html index 368941fe..fc871c13 100644 --- a/docs/awstats_config.html +++ b/docs/awstats_config.html @@ -1517,26 +1517,20 @@ parameter.


LinksToWhoIs
-Version : 4.0+
-
# Set here the link used to point to Internet WhoIs database for hostnames. -
# This parameter is not used if plugin hostinfo is not enabled. -
# Default: "http://www.whois.net/search.cgi2?str=" -
# Example: "http://www.netsol.com/cgi-bin/whois/whois?SearchType=all&STRING=" -
# Example: "http://www.ripe.net/perl/whois?form_type=simple&searchtext=" -
# Example: "http://www.arin.net/cgi-bin/whois.pl?queryinput=" -
# -
LinksToWhoIs="http://www.whois.net/search.cgi2?str=" + +Version : 4.0 - 5.9 (deprecated since 6.0, replaced by plugin 'hostinfo')
+This parameter has been removed since 6.0.
+This parameter is no more required. +



LinksToIPWhoIs
-Version : 5.0+
-
# Set here the link used to point to Internet WhoIs database for ip addresses. -
# This parameter is not used if plugin hostinfo is not enabled. -
# Default: "http://ws.arin.net/cgi-bin/whois.pl?queryinput=" -
# Example: "http://ws.arin.net/cgi-bin/whois.pl?queryinput=" -
# -
LinksToIPWhoIs="http://ws.arin.net/cgi-bin/whois.pl?queryinput=" + +Version : 5.0 - 5.9 (deprecated since 6.0, replaced by plugin 'hostinfo')
+This parameter has been removed since 6.0.
+This parameter is no more required. +



diff --git a/tools/awstats_buildstaticpages.pl b/tools/awstats_buildstaticpages.pl index 9c7fc681..c04658b8 100644 --- a/tools/awstats_buildstaticpages.pl +++ b/tools/awstats_buildstaticpages.pl @@ -343,7 +343,9 @@ if ($Date) { my $cpt=0; -my $smallcommand="\"$Awstats\" -config=$SiteConfig".($BuildPDF?" -buildpdf -noloadplugin=tooltips,rawlog,hostinfo":"")." -staticlinks".($OutputSuffix ne $SiteConfig?"=$OutputSuffix":""); +my $NoLoadPlugin=""; +if ($BuildPDF) { $NoLoadPlugin.="tooltips,rawlog,hostinfo"; } +my $smallcommand="\"$Awstats\" -config=$SiteConfig".($BuildPDF?" -buildpdf":"").($NoLoadPlugin?" -noloadplugin=$NoLoadPlugin":"")." -staticlinks".($OutputSuffix ne $SiteConfig?"=$OutputSuffix":""); if ($StaticExt && $StaticExt ne 'html') { $smallcommand.=" -staticlinksext=$StaticExt"; } if ($DirIcons) { $smallcommand.=" -diricons=$DirIcons"; } if ($Lang) { $smallcommand.=" -lang=$Lang"; } diff --git a/wwwroot/cgi-bin/awstats.model.conf b/wwwroot/cgi-bin/awstats.model.conf index 3d362713..c9aef8d4 100644 --- a/wwwroot/cgi-bin/awstats.model.conf +++ b/wwwroot/cgi-bin/awstats.model.conf @@ -1050,23 +1050,6 @@ UseHTTPSLinkForUrl="" MaxLengthOfShownURL=64 -# Set here the link used to point to Internet WhoIs database for hostnames. -# This parameter is not used if plugin hostinfo is not enabled. -# Default: "http://www.whois.net/search.cgi2?str=" -# Example: "http://www.ripe.net/perl/whois?form_type=simple&searchtext=" -# Example: "http://ws.arin.net/cgi-bin/whois.pl?queryinput=" -# -LinksToWhoIs="http://www.whois.net/search.cgi2?str=" - - -# Set here the link used to point to Internet WhoIs database for ip addresses. -# This parameter is not used if plugin hostinfo is not enabled. -# Default: "http://ws.arin.net/cgi-bin/whois.pl?queryinput=" -# Example: "http://ws.arin.net/cgi-bin/whois.pl?queryinput=" -# -LinksToIPWhoIs="http://ws.arin.net/cgi-bin/whois.pl?queryinput=" - - # You can enter HTML code that will be added at the top of AWStats reports. # Default: "" # @@ -1198,9 +1181,9 @@ color_x="C1B2E2" # Background color for number of exit pages (Default = "C1B2 #LoadPlugin="userinfo" # Plugin: HostInfo -# Perl modules required: None -# Add a column into host chart with a clicable link to a popup that show WhoIs -# info, on a popup window. +# Perl modules required: XWhois +# Add a column into host chart with a link to open a popup window that shows +# info on host (like whois records). # #LoadPlugin="hostinfo" diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index d538f577..c313ade2 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -5330,7 +5330,7 @@ if ($ENV{'GATEWAY_INTERFACE'}) { # Run from a browser as CGI if ($QueryString =~ /(^|&)lang=([^&]+)/i) { $Lang="$2"; } if (! $Lang || $Lang eq 'auto') { # If lang not defined or forced to auto my $langlist=$ENV{'HTTP_ACCEPT_LANGUAGE'}||''; $langlist =~ s/;[^,]*//g; - debug("Search an available language among HTTP_ACCEPT_LANGUAGE=$langlist",1); + if ($Debug) { debug("Search an available language among HTTP_ACCEPT_LANGUAGE=$langlist",1); } foreach my $code (split(/,/,$langlist)) { # Search for a valid lang in priority if ($LangBrowserToLangAwstats{$code}) { $Lang=$LangBrowserToLangAwstats{$code}; debug(" Will try to use Lang=$Lang",1); last; } $code =~ s/-.*$//; @@ -5345,11 +5345,12 @@ if (! $Lang || $Lang eq 'auto') { debug(" No language defined or available. Will # Define frame name and correct variable for frames if (! $FrameName) { - if ($ENV{'GATEWAY_INTERFACE'} && $UseFramesWhenCGI && $HTMLOutput{'main'}) { $FrameName='index'; } + if ($ENV{'GATEWAY_INTERFACE'} && $UseFramesWhenCGI && $HTMLOutput{'main'} && ! $PluginMode) { $FrameName='index'; } else { $FrameName='main'; } } # Load Message files, Reference data files and Plugins +if ($Debug) { debug("FrameName=$FrameName",1); } if ($FrameName ne 'index') { &Read_Language_Data($Lang); if ($FrameName ne 'mainleft') { @@ -9745,7 +9746,7 @@ if (scalar keys %HTMLOutput) { my $p=int($_errors_h{$key}/$TotalHitsErrors*1000)/10; print ""; if ($TrapInfosForHTTPErrorCodes{$key}) { print "$key"; } - else { print "$key"; } + else { print "$key"; } print "".($httpcodelib{$key}?$httpcodelib{$key}:'Unknown error')."$_errors_h{$key}$p %".Format_Bytes($_errors_k{$key}).""; print "\n"; $total_h+=$_errors_h{$key}; @@ -9754,7 +9755,7 @@ if (scalar keys %HTMLOutput) { &tab_end("* $Message[154]"); } - # BY SMTP ERRORS + # BY SMTP STATUS #---------------------------- if ($ShowSMTPErrorsStats) { if ($Debug) { debug("ShowSMTPErrorsStats",2); } @@ -9768,7 +9769,7 @@ if (scalar keys %HTMLOutput) { foreach my $key (@keylist) { my $p=int($_errors_h{$key}/$TotalHitsErrors*1000)/10; print ""; - print "$key"; + print "$key"; print "".($smtpcodelib{$key}?$smtpcodelib{$key}:'Unknown error')."$_errors_h{$key}$p %".Format_Bytes($_errors_k{$key}).""; print "\n"; $total_h+=$_errors_h{$key}; diff --git a/wwwroot/cgi-bin/plugins/hostinfo.pm b/wwwroot/cgi-bin/plugins/hostinfo.pm index 2afcafc4..5172a69e 100644 --- a/wwwroot/cgi-bin/plugins/hostinfo.pm +++ b/wwwroot/cgi-bin/plugins/hostinfo.pm @@ -1,15 +1,17 @@ #!/usr/bin/perl #----------------------------------------------------------------------------- # HostInfo AWStats plugin -# This plugin allow you to add information on hosts, like a whois link. +# This plugin allow you to add information on hosts, like a whois fields. #----------------------------------------------------------------------------- -# Perl Required Modules: None +# Perl Required Modules: XWhois #----------------------------------------------------------------------------- # $Revision$ - $Author$ - $Date$ # <----- -# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES. +push @INC, "${DIR}/plugins"; +# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES +if (!eval ('require "Net/XWhoIs.pm";')) { return $@?"Error: $@":"Error: Need Perl module Net::XWhoIs"; } # -----> use strict;no strict "refs"; @@ -22,7 +24,7 @@ use strict;no strict "refs"; # ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN # AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE. my $PluginNeedAWStatsVersion="5.7"; -my $PluginHooksFunctions="ShowInfoHost AddHTMLBodyHeader"; +my $PluginHooksFunctions="ShowInfoHost AddHTMLBodyHeader BuildFullHTMLOutput"; # -----> # <----- @@ -43,7 +45,6 @@ sub Init_hostinfo { # <----- # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS debug(" InitParams=$InitParams",1); - if (! $LinksToWhoIs || ! $LinksToIPWhoIs) { return "Error: Parameters LinksToWhoIs and LinksToIPWhoIs must be defined in config file to use hostinfo plugin."; } # -----> return ($checkversion?$checkversion:"$PluginHooksFunctions"); @@ -66,8 +67,8 @@ sub AddHTMLBodyHeader_hostinfo { @@ -122,4 +123,64 @@ sub ShowInfoHost_hostinfo { } +#----------------------------------------------------------------------------- +# PLUGIN FUNTION: BuildFullHTMLOutput_pluginname +# UNIQUE: NO (Several plugins using this function can be loaded) +# Function called to output an HTML page completely built by plugin instead +# of AWStats output +#----------------------------------------------------------------------------- +sub BuildFullHTMLOutput_hostinfo { + # <----- +# my $regipv4=qr/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/; +# my $regipv6=qr/^[0-9A-F]*:/i; + + my $Host=''; + if ($QueryString =~ /host=([^&]+)/i) { + $Host=lc(&DecodeEncodedString("$1")); + } + + my $ip=''; + my $HostResolved=''; +# if ($Host =~ /$regipv4/o) { $ip=4; } +# elsif ($Host =~ /$regipv6/o) { $ip=6; } +# if ($ip == 4) { +# my $lookupresult=lc(gethostbyaddr(pack("C4",split(/\./,$Host)),AF_INET)); # This is very slow, may spend 20 seconds +# if (! $lookupresult || $lookupresult =~ /$regipv4/o || ! IsAscii($lookupresult)) { +# $HostResolved='*'; +# } +# else { +# $HostResolved=$lookupresult; +# } +# if ($Debug) { debug(" Reverse DNS lookup for $Host done: $HostResolved",4); } +# } + if (! $ip) { $HostResolved=$Host; } + + if ($Debug) { debug(" DirData=$DirData Host=$Host HostResolved=$HostResolved ",4); } + my $w = new Net::XWhois Verbose=>$Debug, Cache=>$DirData, NoCache=>0, Timeout=>30, Domain=>$HostResolved; + + print "
\n"; + + &tab_head("Common Whois Fields",0,0,'whois'); + print "Common field infoValue\n"; + print "Name".($w->name())." "; + print "Status".($w->status())." "; + print "NameServers".($w->nameservers())." "; + print "Registrant".($w->registrant())." "; + print "Contact Admin".($w->contact_admin())." "; + print "Contact Tech".($w->contact_tech())." "; + print "Contact Billing".($w->contact_billing())." "; + print "Contact Zone".($w->contact_zone())." "; + print "Contact Emails".($w->contact_emails())." "; + print "Contact Handles".($w->contact_handles())." "; + print "Domain Handles".($w->domain_handles())." "; + &tab_end; + + &tab_head("Full Whois Field",0,0,'whois'); + print "
".($w->response())."
\n"; + &tab_end; + + return 1; + # -----> +} + 1; # Do not remove this line -- 2.47.3