iwla

iwla Git Source Tree

Root/tools/iwla_convert.pl

1#!/usr/bin/perl
2
3my $awstats_lib_root = '/usr/share/awstats/lib/';
4# my $awstats_lib_root = './';
5my @awstats_libs = ('search_engines.pm', 'robots.pm', 'operating_systems.pm', 'browsers.pm');
6
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;}
10require './tools/own_search_engines.pm';
11
12sub dumpList {
13 my @list = @{$_[0]};
14 my $FIC = $_[1];
15 my $first = $_[2];
16
17 foreach $r (@list)
18 {
19$r =~ s/\'/\\\'/g;
20if ($first == 0)
21{
22 print $FIC ", ";
23}
24else
25{
26 $first = 0;
27}
28print $FIC "'$r'";
29 }
30}
31
32sub dumpHash {
33 my %hash = %{$_[0]};
34 my $FIC = $_[1];
35 my $first = $_[2];
36
37 while( my ($k,$v) = each(%hash) ) {
38$k =~ s/\'/\\\'/g;
39$v =~ s/\'/\\\'/g;
40if ($first == 0)
41{
42 print $FIC ", ";
43}
44else
45{
46 $first = 0;
47}
48print $FIC "'$k' : '$v'";
49 }
50}
51
52# Robots
53open($FIC,">", "awstats_data.py") or die $!;
54
55print $FIC "#This file was automatically generated by iwla_convert.pl. Do not edit manually.\n\n";
56
57print $FIC "robots = [";
58dumpList(\@RobotsSearchIDOrder_list1, $FIC, 1);
59dumpList(\@RobotsSearchIDOrder_list2, $FIC, 0);
60print $FIC "]\n\n";
61
62print $FIC "search_engines = [";
63dumpList(\@SearchEnginesSearchIDOrder_list1, $FIC, 1);
64print $FIC "]\n\n";
65
66print $FIC "search_engines_2 = [";
67dumpList(\@SearchEnginesSearchIDOrder_list2, $FIC, 1);
68dumpList(\@Own_SearchEnginesSearchIDOrder, $FIC, 0);
69print $FIC "]\n\n";
70
71print $FIC "not_search_engines_keys = {";
72dumpHash(\%NotSearchEnginesKeys, $FIC, 1);
73print $FIC "}\n\n";
74
75print $FIC "search_engines_hashid = {";
76dumpHash(\%SearchEnginesHashID, $FIC, 1);
77dumpHash(\%Own_SearchEnginesHashID, $FIC, 0);
78print $FIC "}\n\n";
79
80print $FIC "search_engines_knwown_url = {";
81dumpHash(\%SearchEnginesKnownUrl, $FIC, 1);
82dumpHash(\%Own_SearchEnginesKnownUrl, $FIC, 0);
83print $FIC "}\n\n";
84
85print $FIC "operating_systems = [";
86dumpList(\@OSSearchIDOrder, $FIC, 1);
87print $FIC "]\n\n";
88
89print $FIC "operating_systems_hashid = {";
90dumpHash(\%OSHashID, $FIC, 1);
91print $FIC "}\n\n";
92
93print $FIC "operating_systems_family = {";
94dumpHash(\%OSFamily, $FIC, 1);
95print $FIC "}\n\n";
96
97print $FIC "browsers = [";
98dumpList(\@BrowsersSearchIDOrder, $FIC, 1);
99print $FIC "]\n\n";
100
101print $FIC "browsers_hashid = {";
102dumpHash(\%BrowsersHashIDLib, $FIC, 1);
103print $FIC "}\n\n";
104
105print $FIC "browsers_icons = {";
106dumpHash(\%BrowsersHashIcon, $FIC, 1);
107print $FIC "}\n\n";
108
109close($FIC);

Archive Download this file

Branches

Tags