# Return: 0 Not found, 1 Found
#------------------------------------------------------------------------------
sub SkipFile {
- debug(" Call to SkipFile to check $_[0]");
foreach (@SkipFiles) { if ($_[0] =~ /$_/) { return 1; } }
0; # Not in @SkipFiles
}
my $pluginname=$1;
if ($pluginname) {
if (! $PluginsLoaded{'init'}{"$pluginname"}) { # Plugin not already loaded
- my %pluginisfor=('tooltips'=>'o','ipv6'=>'u','hashfiles'=>'u','geoip'=>'u',
- 'geoipfree'=>'u','hostinfo'=>'o','userinfo'=>'o','urlalias'=>'o','timehires'=>'u','timezone'=>'ou');
+ my %pluginisfor=('ipv6'=>'u','hashfiles'=>'u','geoip'=>'u','geoipfree'=>'u','timehires'=>'u','timezone'=>'ou',
+ 'decodeutfkeys'=>'o','hostinfo'=>'o','userinfo'=>'o','urlalias'=>'o','tooltips'=>'o');
if ($pluginisfor{$pluginname}) {
# Do not load "update plugins" if output only
if (! $UpdateStats && scalar keys %HTMLOutput && $pluginisfor{$pluginname} !~ /o/) { $PluginsLoaded{'init'}{"$pluginname"}=1; next; }
# Return: decodedstring
#------------------------------------------------------------------------------
sub ChangeWordSeparatorsIntoSpace {
- $_[0] =~ s/%1[03]/ /g;
- $_[0] =~ s/%2[02789abc]/ /ig;
- $_[0] =~ s/%3a/ /ig;
+ $_[0] =~ s/%1[03]/ /g; # LF,CR
+ $_[0] =~ s/%2[02789abc]/ /ig; #
+ $_[0] =~ s/%3a/ /ig; # :
$_[0] =~ tr/\+\'\(\)\"\*,:/ /s; # "&" and "=" must not be in this list
}
#------------------------------------------------------------------------------
-# Function: Converts an UTF8 string to specified Charset
-# Parameters: utfstringtodecode charsettoencode
-# Return: newencodedstring
-#------------------------------------------------------------------------------
-sub Utf8_To_Ascii {
-#Function to prepare 'decodeUTFkeys' plugin
-#use Encode;
-#use URI::Escape;
-#my $string = shift;
-#my $encoding = shift;
-#if ( $string =~ m/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf])*$/ )
-#{
-# $string = decode("utf-8", $string);
-# $string = encode($encoding, $string);
-#}
-## trim space
-#$string =~ s/^ +//;
-#$string =~ s/ +$//;
-## reverse "+", ";" to space
-#$string =~ s/;+/\+/g;
-#$string =~ s/\s+/\+/g;
-#return $string;
-}
-
-#------------------------------------------------------------------------------
-# Function: Encode URL to XML (Transforms & into & as needed in XML/XHTML)
+# Function: Transforms & into & as needed in XML/XHTML
# Parameters: stringtoencode
# Return: encodedstring
#------------------------------------------------------------------------------
# Now param is keyphrase: "cache:mmm:www/zzz+aaa+bbb/ccc+ddd%20eee'fff,ggg"
$param =~ s/^(cache|related):[^\+]+//;
&ChangeWordSeparatorsIntoSpace($param); # Change [ aaa+bbb/ccc+ddd%20eee'fff,ggg ] into [ aaa bbb/ccc ddd eee fff ggg]
- # TODO Add a plugin to convert utf8 coded params (google, alltheweb) into locally coded string ($PageCode)
$param =~ s/^ +//; $param =~ s/ +$//; $param =~ tr/ /\+/s;
if ((length $param) > 0) { $_keyphrases{$param}++; }
last;
# Now param is keyphrase: "aaa+bbb/ccc+ddd%20eee'fff,ggg"
$param =~ s/^(cache|related):[^\+]+//;
&ChangeWordSeparatorsIntoSpace($param); # Change [ aaa+bbb/ccc+ddd%20eee'fff,ggg ] into [ aaa bbb/ccc ddd eee fff ggg ]
- # TODO Add a plugin to convert utf8 coded params (google, alltheweb) into locally coded string ($PageCode)
$param =~ s/^ +//; $param =~ s/ +$//; $param =~ tr/ /\+/s;
if ((length $param) > 2) { $_keyphrases{$param}++; last; }
}
# HTMLHeadSection
if ($FrameName ne 'index' && $FrameName ne 'mainleft') {
- print "<a name=\"TOP\"> </a>\n\n";
+ print "<a name=\"top\"> </a>\n\n";
print "$HTMLHeadSection\n";
print "\n";
}
if ($ShowMenu || $FrameName eq 'mainleft') {
if ($Debug) { debug("ShowMenu",2); }
my $frame=($FrameName eq 'mainleft');
- print "$Center<a name=\"MENU\"> </a>\n";
+ print "$Center<a name=\"menu\"> </a>\n";
my $WIDTHMENU1=($FrameName eq 'mainleft'?$FRAMEWIDTH:150);
# if ($HTMLOutput{'alldays'}) {
# if ($Debug) { debug("ShowMonthDayStats",2); }
-# print "$Center<a name=\"MONTHDAY\"> </a><br />\n";
+# print "$Center<a name=\"monthday\"> </a><br />\n";
# &tab_head("$Message[5]",0,0,"alldays");
#
# my $NewLinkParams=${QueryString};
my $count=0;
&BuildKeyList($MaxRowsInHTMLOutput,$MinHit{'Keyphrase'},\%_keyphrases,\%_keyphrases);
foreach my $key (@keylist) {
- my $mot = CleanFromCSSA(DecodeEncodedString($key));
+ my $mot;
+ # Convert coded keywords (utf8,...) to be correctly reported in HTML page.
+ if ($PluginsLoaded{'DecodeKey'}{'decodeutfkeys'}) { $mot=CleanFromCSSA(DecodeKey_decodeutfkeys($key,$PageCode||'iso-8859-1')); }
+ else { $mot = CleanFromCSSA(DecodeEncodedString($key)); }
my $p;
if ($TotalKeyphrases) { $p=int($_keyphrases{$key}/$TotalKeyphrases*1000)/10; }
print "<tr><td class=\"aws\">".XMLEncode($mot)."</td><td>$_keyphrases{$key}</td><td>$p %</td></tr>\n";
my $count=0;
&BuildKeyList($MaxRowsInHTMLOutput,$MinHit{'Keyword'},\%_keywords,\%_keywords);
foreach my $key (@keylist) {
- my $mot = CleanFromCSSA(DecodeEncodedString($key));
+ my $mot;
+ # Convert coded keywords (utf8,...) to be correctly reported in HTML page.
+ if ($PluginsLoaded{'DecodeKey'}{'decodeutfkeys'}) { $mot=CleanFromCSSA(DecodeKey_decodeutfkeys($key,$PageCode||'iso-8859-1')); }
+ else { $mot = CleanFromCSSA(DecodeEncodedString($key)); }
my $p;
if ($TotalKeywords) { $p=int($_keywords{$key}/$TotalKeywords*1000)/10; }
print "<tr><td class=\"aws\">".XMLEncode($mot)."</td><td>$_keywords{$key}</td><td>$p %</td></tr>\n";
}
if ($HTMLOutput{'info'}) {
# Not yet available
- print "$Center<a name=\"INFO\"> </a><br />";
+ print "$Center<a name=\"info\"> </a><br />";
&html_end;
}
if ($HTMLOutput{'main'}) {
}
}
- print "\n<a name=\"WHEN\"> </a>\n\n";
+ print "\n<a name=\"when\"> </a>\n\n";
# BY DAY OF MONTH
#---------------------------------------------------------------------
&tab_end;
}
- print "\n<a name=\"WHO\"> </a>\n\n";
+ print "\n<a name=\"who\"> </a>\n\n";
# BY COUNTRY/DOMAIN
#---------------------------
&tab_end("* $Message[158]");
}
- print "\n<a name=\"HOW\"> </a>\n\n";
+ print "\n<a name=\"how\"> </a>\n\n";
# BY SESSION
#----------------------------
#-------------------------
if ($ShowPagesStats) {
if ($Debug) { debug("ShowPagesStats (MaxNbOf{'PageShown'}=$MaxNbOf{'PageShown'} TotalDifferentPages=$TotalDifferentPages)",2); }
- print "$Center<a name=\"urls\"> </a><a name=\"ENTRY\"> </a><a name=\"EXIT\"> </a><br />\n";
+ print "$Center<a name=\"urls\"> </a><a name=\"entry\"> </a><a name=\"exit\"> </a><br />\n";
my $title="$Message[19] ($Message[77] $MaxNbOf{'PageShown'}) - <a href=\"".($ENV{'GATEWAY_INTERFACE'} || !$StaticLinks?XMLEncode("$AWScript?${NewLinkParams}output=urldetail"):"$PROG$StaticLinks.urldetail.$StaticExt")."\"$NewLinkTarget>$Message[80]</a>";
if ($ShowPagesStats =~ /E/i) { $title.=" - <a href=\"".($ENV{'GATEWAY_INTERFACE'} || !$StaticLinks?XMLEncode("$AWScript?${NewLinkParams}output=urlentry"):"$PROG$StaticLinks.urlentry.$StaticExt")."\"$NewLinkTarget>$Message[104]</a>"; }
if ($ShowPagesStats =~ /X/i) { $title.=" - <a href=\"".($ENV{'GATEWAY_INTERFACE'} || !$StaticLinks?XMLEncode("$AWScript?${NewLinkParams}output=urlexit"):"$PROG$StaticLinks.urlexit.$StaticExt")."\"$NewLinkTarget>$Message[116]</a>"; }
&tab_end;
}
- print "\n<a name=\"REFERING\"> </a>\n\n";
+ print "\n<a name=\"refering\"> </a>\n\n";
# BY REFERENCE
#---------------------------
&tab_end;
}
- print "\n<a name=\"KEYS\"> </a>\n\n";
+ print "\n<a name=\"keys\"> </a>\n\n";
# BY SEARCH KEYWORDS AND/OR KEYPHRASES
#-------------------------------------
my $count=0;
&BuildKeyList($MaxNbOf{'KeyphrasesShown'},$MinHit{'Keyphrase'},\%_keyphrases,\%_keyphrases);
foreach my $key (@keylist) {
- my $mot = CleanFromCSSA(DecodeEncodedString($key));
+ my $mot;
+ # Convert coded keywords (utf8,...) to be correctly reported in HTML page.
+ if ($PluginsLoaded{'DecodeKey'}{'decodeutfkeys'}) { $mot=CleanFromCSSA(DecodeKey_decodeutfkeys($key,$PageCode||'iso-8859-1')); }
+ else { $mot = CleanFromCSSA(DecodeEncodedString($key)); }
my $p;
if ($TotalKeyphrases) { $p=int($_keyphrases{$key}/$TotalKeyphrases*1000)/10; }
- print "<tr><td class=\"aws\">$mot</td><td>$_keyphrases{$key}</td><td>$p %</td></tr>\n";
+ print "<tr><td class=\"aws\">".XMLEncode($mot)."</td><td>$_keyphrases{$key}</td><td>$p %</td></tr>\n";
$total_s += $_keyphrases{$key};
$count++;
}
my $count=0;
&BuildKeyList($MaxNbOf{'KeywordsShown'},$MinHit{'Keyword'},\%_keywords,\%_keywords);
foreach my $key (@keylist) {
- my $mot = CleanFromCSSA(DecodeEncodedString($key));
+ my $mot;
+ # Convert coded keywords (utf8,...) to be correctly reported in HTML page.
+ if ($PluginsLoaded{'DecodeKey'}{'decodeutfkeys'}) { $mot=CleanFromCSSA(DecodeKey_decodeutfkeys($key,$PageCode||'iso-8859-1')); }
+ else { $mot = CleanFromCSSA(DecodeEncodedString($key)); }
my $p;
if ($TotalKeywords) { $p=int($_keywords{$key}/$TotalKeywords*1000)/10; }
- print "<tr><td class=\"aws\">$mot</td><td>$_keywords{$key}</td><td>$p %</td></tr>\n";
+ print "<tr><td class=\"aws\">".XMLEncode($mot)."</td><td>$_keywords{$key}</td><td>$p %</td></tr>\n";
$total_s += $_keywords{$key};
$count++;
}
}
if ($ShowKeyphrasesStats && $ShowKeywordsStats) { print "</tr></table>\n"; }
- print "\n<a name=\"OTHER\"> </a>\n\n";
+ print "\n<a name=\"other\"> </a>\n\n";
# BY MISC
#----------------------------
--- /dev/null
+#!/usr/bin/perl
+#-----------------------------------------------------------------------------
+# decodeUTFKeys AWStats plugin
+# Allow AWStats to convert keywords strings coded by some search engines in
+# UTF8 coding to a common string in a local charset.
+#-----------------------------------------------------------------------------
+# Perl Required Modules: Encode and URI::Escape
+#-----------------------------------------------------------------------------
+# $Revision$ - $Author$ - $Date$
+
+
+# <-----
+# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
+if (!eval ('require "Encode.pm"')) { return $@?"Error: $@":"Error: Need Perl module Encode"; }
+if (!eval ('require "URI/Escape.pm"')) { return $@?"Error: $@":"Error: Need Perl module URI::Escape"; }
+#if (!eval ('require "HTML/Entities.pm"')) { return $@?"Error: $@":"Error: Need Perl module HTML::Entities"; }
+# ----->
+use strict;no strict "refs";
+
+
+
+#-----------------------------------------------------------------------------
+# PLUGIN VARIABLES
+#-----------------------------------------------------------------------------
+# <-----
+# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
+# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
+my $PluginNeedAWStatsVersion="6.0";
+my $PluginHooksFunctions="DecodeKey";
+# ----->
+
+# <-----
+# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
+use vars qw/
+/;
+# ----->
+
+
+
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: Init_pluginname
+#-----------------------------------------------------------------------------
+sub Init_decodeutfkeys {
+ my $InitParams=shift;
+
+ # <-----
+ # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
+ # ----->
+
+ my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
+ return ($checkversion?$checkversion:"$PluginHooksFunctions");
+}
+
+
+#------------------------------------------------------------------------------
+# Function: Converts an UTF8 string to specified Charset
+# Parameters: utfstringtodecode charsettoencode
+# Return: newencodedstring
+#------------------------------------------------------------------------------
+sub DecodeKey_decodeutfkeys {
+ my $string = shift;
+ my $encoding = shift;
+ if (! $encoding) { error("Function DecodeKey from plugin decodeutfkeys was called but AWStats don't know language code required to output new value."); }
+ $string=URI::Escape::uri_unescape($string);
+ if ( $string =~ m/^([\x00-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf])*$/ )
+ {
+ $string=Encode::encode($encoding, Encode::decode("utf-8", $string));
+ }
+ #$string=HTML::Entities::encode_entities($string);
+ $string =~ s/;+/ /g;
+ return $string;
+}
+
+
+1; # Do not remove this line