(file) Return to decodeutfkeys.pm CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / awstats-6.3 / wwwroot / cgi-bin / plugins

 1 rizwank 1.1 #!/usr/bin/perl
 2             #-----------------------------------------------------------------------------
 3             # decodeUTFKeys AWStats plugin
 4             # Allow AWStats to convert keywords strings coded by some search engines in
 5             # UTF8 coding to a common string in a local charset.
 6             #-----------------------------------------------------------------------------
 7             # Perl Required Modules: Encode and URI::Escape
 8             #-----------------------------------------------------------------------------
 9             # $Revision: 1.4 $ - $Author: eldy $ - $Date: 2004/08/14 14:49:09 $
10             
11             
12             # <-----
13             # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
14             if (!eval ('require "Encode.pm"')) { return $@?"Error: $@":"Error: Need Perl module Encode"; }
15             if (!eval ('require "URI/Escape.pm"')) { return $@?"Error: $@":"Error: Need Perl module URI::Escape"; }
16             #if (!eval ('require "HTML/Entities.pm"')) { return $@?"Error: $@":"Error: Need Perl module HTML::Entities"; }
17             # ----->
18             use strict;no strict "refs";
19             
20             
21             
22 rizwank 1.1 #-----------------------------------------------------------------------------
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="DecodeKey";
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 rizwank 1.1 sub Init_decodeutfkeys {
44             	my $InitParams=shift;
45             
46             	# <-----
47             	# ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
48             	# ----->
49             
50             	my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion);
51             	return ($checkversion?$checkversion:"$PluginHooksFunctions");
52             }
53             
54             
55             #------------------------------------------------------------------------------
56             # Function:     Converts an UTF8 string to specified Charset
57             # Parameters:	utfstringtodecode charsettoencode
58             # Return:		newencodedstring
59             #------------------------------------------------------------------------------
60             sub DecodeKey_decodeutfkeys {
61             	my $string = shift;
62             	my $encoding = shift;
63             	if (! $encoding) { error("Function DecodeKey from plugin decodeutfkeys was called but AWStats don't know language code required to output new value."); }
64 rizwank 1.1 	$string =~ s/\\x(\w\w)/%$1/gi;	# Change "\xc4\xbe\xd7\xd3\xc3\xc0" into "%c4%be%d7%d3%c3%c0"
65             	$string=URI::Escape::uri_unescape($string);
66             	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])*$/ )
67             	{
68             		$string=Encode::encode($encoding, Encode::decode("utf-8", $string));
69             	}
70             	#$string=HTML::Entities::encode_entities($string);
71             	$string =~ s/[;+]/ /g;
72             	return $string;
73             }
74             
75             
76             1;	# Do not remove this line

Rizwan Kassim
Powered by
ViewCVS 0.9.2