iwla

iwla Git Source Tree

Root/tools/iwla_convert.pl

Source at commit 4e02325733e5e8e4f5de2f0046e721f8da7abfff created 6 years 10 months ago.
By Gregory Soutade, Initial commit
1#!/usr/bin/perl
2
3my $awstats_lib_root = './';
4my @awstats_libs = ('search_engines.pm', 'robots.pm');
5
6# my $awstats_lib_root = '/usr/share/awstats/lib/';
7# my @awstats_libs = ('browsers.pm', 'browsers_phone.pm', 'mime.pm', 'referer_spam.pm', 'search_engines.pm', 'operating_systems.pm', 'robots.pm', 'worms.pm');
8
9foreach $lib (@awstats_libs) {require $awstats_lib_root . $lib;}
10
11sub dumpList {
12 my @list = @{$_[0]};
13 my $FIC = $_[1];
14 my $first = $_[2];
15
16 foreach $r (@list)
17 {
18$r =~ s/\'/\\\'/g;
19if ($first == 0)
20{
21 print $FIC ", ";
22}
23else
24{
25 $first = 0;
26}
27print $FIC "'$r'";
28 }
29}
30
31sub dumpHash {
32 my %hash = %{$_[0]};
33 my $FIC = $_[1];
34 my $first = $_[2];
35
36 while( my ($k,$v) = each(%hash) ) {
37$k =~ s/\'/\\\'/g;
38$v =~ s/\'/\\\'/g;
39if ($first == 0)
40{
41 print $FIC ", ";
42}
43else
44{
45 $first = 0;
46}
47print $FIC "'$k' : '$v'";
48 }
49}
50
51# Robots
52open($FIC,">", "awstats_data.py") or die $!;
53
54print $FIC "robots = [";
55dumpList(\@RobotsSearchIDOrder_list1, $FIC, 1);
56dumpList(\@RobotsSearchIDOrder_list2, $FIC, 0);
57print $FIC "]\n\n";
58
59print $FIC "search_engines = [";
60dumpList(\@SearchEnginesSearchIDOrder_list1, $FIC, 1);
61print $FIC "]\n\n";
62
63print $FIC "search_engines_2 = [";
64dumpList(\@SearchEnginesSearchIDOrder_list2, $FIC, 1);
65print $FIC "]\n\n";
66
67print $FIC "not_search_engines_keys = {";
68dumpHash(\%NotSearchEnginesKeys, $FIC, 1);
69print $FIC "}\n\n";
70
71print $FIC "search_engines_hashid = {";
72dumpHash(\%SearchEnginesHashID, $FIC, 1);
73print $FIC "}\n\n";
74
75print $FIC "search_engines_knwown_url = {";
76dumpHash(\%SearchEnginesKnownUrl, $FIC, 1);
77print $FIC "}\n\n";
78
79close($FIC);

Archive Download this file

Branches

Tags