iwla/tools/iwla_convert.pl

114 lines
2.6 KiB
Perl
Raw Permalink Normal View History

2014-11-18 20:18:53 +01:00
#!/usr/bin/perl
2022-06-23 21:09:15 +02:00
#my $awstats_lib_root = '/usr/share/awstats/lib/';
2022-11-04 20:13:02 +01:00
my $awstats_lib_root = './awstats/wwwroot/cgi-bin/lib/';
my @awstats_libs = ('search_engines.pm', 'robots.pm', 'operating_systems.pm', 'browsers.pm');
2014-11-26 16:17:16 +01:00
# my @awstats_libs = ('browsers.pm', 'browsers_phone.pm', 'mime.pm', 'referer_spam.pm', 'search_engines.pm', 'operating_systems.pm', 'robots.pm', 'worms.pm');
2014-11-18 20:18:53 +01:00
foreach $lib (@awstats_libs) {require $awstats_lib_root . $lib;}
2015-06-12 17:56:27 +02:00
require './tools/own_search_engines.pm';
2014-11-18 20:18:53 +01:00
2014-11-26 16:17:16 +01:00
sub dumpList {
my @list = @{$_[0]};
my $FIC = $_[1];
my $first = $_[2];
2014-11-18 20:18:53 +01:00
2014-11-26 16:17:16 +01:00
foreach $r (@list)
2014-11-18 20:18:53 +01:00
{
2014-11-26 16:17:16 +01:00
$r =~ s/\'/\\\'/g;
2014-11-26 16:17:16 +01:00
if ($first == 0)
{
print $FIC ", ";
}
else
{
$first = 0;
}
2014-11-26 16:56:33 +01:00
print $FIC "'$r'";
2014-11-18 20:18:53 +01:00
}
}
2014-11-26 16:17:16 +01:00
sub dumpHash {
my %hash = %{$_[0]};
my $FIC = $_[1];
my $first = $_[2];
while( my ($k,$v) = each(%hash) ) {
$k =~ s/\'/\\\'/g;
$v =~ s/\'/\\\'/g;
next if ($k eq "" || $v eq "");
2014-11-26 16:17:16 +01:00
if ($first == 0)
{
print $FIC ", ";
}
else
{
$first = 0;
}
2014-11-26 16:56:33 +01:00
print $FIC "'$k' : '$v'";
2014-11-26 16:17:16 +01:00
}
2014-11-18 20:18:53 +01:00
}
2014-11-26 16:17:16 +01:00
# Robots
open($FIC,">", "awstats_data.py") or die $!;
print $FIC "#This file was automatically generated by iwla_convert.pl. Do not edit manually.\n\n";
2014-11-26 16:17:16 +01:00
print $FIC "robots = [";
dumpList(\@RobotsSearchIDOrder_list1, $FIC, 1);
dumpList(\@RobotsSearchIDOrder_list2, $FIC, (@RobotsSearchIDOrder_list1 == 0) ? 1 : 0);
2014-11-18 20:18:53 +01:00
print $FIC "]\n\n";
2014-11-26 16:17:16 +01:00
print $FIC "search_engines = [";
dumpList(\@SearchEnginesSearchIDOrder_list1, $FIC, 1);
print $FIC "]\n\n";
print $FIC "search_engines_2 = [";
dumpList(\@SearchEnginesSearchIDOrder_list2, $FIC, 1);
dumpList(\@Own_SearchEnginesSearchIDOrder, $FIC, (@SearchEnginesSearchIDOrder_list2 == 0) ? 1 : 0);
2014-11-26 16:17:16 +01:00
print $FIC "]\n\n";
2014-11-18 20:18:53 +01:00
2014-11-26 16:17:16 +01:00
print $FIC "not_search_engines_keys = {";
dumpHash(\%NotSearchEnginesKeys, $FIC, 1);
print $FIC "}\n\n";
2014-11-18 20:18:53 +01:00
2014-11-26 16:17:16 +01:00
print $FIC "search_engines_hashid = {";
dumpHash(\%SearchEnginesHashID, $FIC, 1);
2015-06-12 17:56:27 +02:00
dumpHash(\%Own_SearchEnginesHashID, $FIC, 0);
2014-11-26 16:17:16 +01:00
print $FIC "}\n\n";
print $FIC "search_engines_knwown_url = {";
dumpHash(\%SearchEnginesKnownUrl, $FIC, 1);
2015-06-12 17:56:27 +02:00
dumpHash(\%Own_SearchEnginesKnownUrl, $FIC, 0);
2014-11-26 16:17:16 +01:00
print $FIC "}\n\n";
print $FIC "operating_systems = [";
dumpList(\@OSSearchIDOrder, $FIC, 1);
print $FIC "]\n\n";
print $FIC "operating_systems_hashid = {";
dumpHash(\%OSHashID, $FIC, 1);
print $FIC "}\n\n";
print $FIC "operating_systems_family = {";
dumpHash(\%OSFamily, $FIC, 1);
print $FIC "}\n\n";
print $FIC "browsers = [";
dumpList(\@BrowsersSearchIDOrder, $FIC, 1);
print $FIC "]\n\n";
print $FIC "browsers_hashid = {";
dumpHash(\%BrowsersHashIDLib, $FIC, 1);
print $FIC "}\n\n";
print $FIC "browsers_icons = {";
dumpHash(\%BrowsersHashIcon, $FIC, 1);
print $FIC "}\n\n";
2014-11-26 16:17:16 +01:00
close($FIC);
2016-01-18 07:33:48 +01:00
print "Done !\n";