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:
- 4801 Bytes
- Properties:
- Property svn:executable is set
1 | #!/usr/bin/perl |
2 | #----------------------------------------------------------------------------- |
3 | # UrlAlias AWStats plugin |
4 | # This plugin allow you to report all URL links with a text title instead of |
5 | # URL value. |
6 | # You must create a file called urlalias.cnfigvalue.txt and store it in |
7 | # plugin directory that contains 2 columns separated by a tab char. |
8 | # First column is URL value and second column is text title to use instead of. |
9 | #----------------------------------------------------------------------------- |
10 | # Perl Required Modules: None |
11 | #----------------------------------------------------------------------------- |
12 | # $Revision: 1.18 $ - $Author: eldy $ - $Date: 2008/11/15 16:03:42 $ |
13 | |
14 | |
15 | # <----- |
16 | # ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES |
17 | #if (!eval ('require "TheModule.pm";')) { return $@?"Error: $@":"Error: Need Perl module TheModule"; } |
18 | # -----> |
19 | #use strict; |
20 | no strict "refs"; |
21 | |
22 | |
23 | |
24 | #----------------------------------------------------------------------------- |
25 | # PLUGIN VARIABLES |
26 | #----------------------------------------------------------------------------- |
27 | # <----- |
28 | # ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN |
29 | # AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE. |
30 | my $PluginNeedAWStatsVersion="5.5"; |
31 | my $PluginHooksFunctions="ShowInfoURL"; |
32 | # -----> |
33 | |
34 | # <----- |
35 | # IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE. |
36 | use vars qw/ |
37 | $urlinfoloaded |
38 | %UrlAlias |
39 | @UrlMatch |
40 | /; |
41 | # -----> |
42 | |
43 | |
44 | |
45 | #----------------------------------------------------------------------------- |
46 | # PLUGIN FUNCTION: Init_pluginname |
47 | #----------------------------------------------------------------------------- |
48 | sub Init_urlalias { |
49 | my $InitParams=shift; |
50 | my $checkversion=&Check_Plugin_Version($PluginNeedAWStatsVersion); |
51 | |
52 | # <----- |
53 | # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS |
54 | debug(" Plugin urlalias: InitParams=$InitParams",1); |
55 | $urlinfoloaded=0; |
56 | %UrlAlias=(); |
57 | @UrlMatch=(); |
58 | # -----> |
59 | |
60 | return ($checkversion?$checkversion:"$PluginHooksFunctions"); |
61 | } |
62 | |
63 | |
64 | |
65 | #----------------------------------------------------------------------------- |
66 | # PLUGIN FUNCTION: ShowInfoURL_pluginname |
67 | # UNIQUE: NO (Several plugins using this function can be loaded) |
68 | # Function called to add additionnal information for URLs in URLs' report. |
69 | # This function is called after writing the URL value in the URL cell of the |
70 | # Top Pages-URL report. |
71 | # Parameters: URL |
72 | #----------------------------------------------------------------------------- |
73 | sub ShowInfoURL_urlalias { |
74 | my $param="$_[0]"; |
75 | # <----- |
76 | my $found = 0; # flag for testing for whether a match occurs. unused at present |
77 | my $filetoload=''; |
78 | my $filetoload2=''; |
79 | if ($param && ! $urlinfoloaded) { |
80 | # Load urlalias and match files |
81 | if ($SiteConfig && open(URLALIASFILE,"$DirData/urlalias.$SiteConfig.txt")) { $filetoload2="$DirData/urlalias.$SiteConfig.txt"; } |
82 | elsif (open(URLALIASFILE,"$DirData/urlalias.txt")) { $filetoload2="$DirData/urlalias.txt"; } |
83 | else { error("Couldn't open UrlAlias file \"$DirData/urlalias.txt\": $!"); } |
84 | if ($SiteConfig && open(URLMATCHFILE,"$DirData/urlmatch.$SiteConfig.txt")) { $filetoload="$DirData/urlmatch.$SiteConfig.txt"; } |
85 | elsif (open(URLMATCHFILE,"$DirData/urlmatch.txt")) { $filetoload="$DirData/urlmatch.txt"; } |
86 | # Load UrlAlias |
87 | %UrlAlias = map(/^([^\t]+)\t+([^\t]+)/o,<URLALIASFILE>); |
88 | # Load UrlMatch |
89 | my $iter = 0; |
90 | foreach my $key (<URLMATCHFILE>) { |
91 | $key =~ /^([^\t]+)\t+([^\t]+)/o; |
92 | $UrlMatch[$iter][0] = $1; |
93 | $UrlMatch[$iter][1] = $2; |
94 | $iter++; |
95 | } |
96 | close URLALIASFILE; |
97 | close URLMATCHFILE; |
98 | debug(" Plugin urlalias: UrlAlias file loaded: ".(scalar keys %UrlAlias)." entries found."); |
99 | debug(" Plugin urlalias: UrlMatch file loaded: ".(scalar @UrlMatch)." entries found."); |
100 | $urlinfoloaded=1; |
101 | } |
102 | if ($param) { |
103 | if ($UrlAlias{$param}) { |
104 | print "<font style=\"color: $color_link; font-weight: bold\">$UrlAlias{$param}</font><br />"; |
105 | $found=1; |
106 | } |
107 | else { |
108 | foreach my $iter (0..@UrlMatch-1) { |
109 | my $key = $UrlMatch[$iter][0]; |
110 | if ( $param =~ /$key/ ) { |
111 | print "<font style=\"color: #$color_link; font-weight: bold\">$UrlMatch[$iter][1]</font><br />"; |
112 | $found = 1; |
113 | # $UrlAlias{$param} = $UrlMatch[$iter][1]; |
114 | # if ($SiteConfig && open(URLALIASFILE,">> $DirData/urlalias.$SiteConfig.txt")) { |
115 | # $filetoload="$DirData/urlalias.$SiteConfig.txt"; |
116 | # } |
117 | # elsif (open(URLALIASFILE,">> $DirData/urlalias.txt")) { |
118 | # $filetoload="$DirData/urlalias.txt"; |
119 | # } |
120 | # else { |
121 | # error("Couldn't open UrlAlias file \"$DirData/urlalias.txt\": $!"); |
122 | # } |
123 | # print URLALIASFILE "$param\t$UrlAlias{$param}"; |
124 | # close URLALIASFILE; |
125 | last; |
126 | } |
127 | } |
128 | } |
129 | if (!$found) { # does nothing right now |
130 | print ""; |
131 | } |
132 | } |
133 | else { print ""; } # Url info title |
134 | return 1; |
135 | # -----> |
136 | } |
137 | |
138 | |
139 | 1; # Do not remove this line |