Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tools/RemoveBlacklist.pl
blob: 2c969b67f8d8820a1bf0158fc45a88afade913d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/perl

my $blacklist = $ARGV[0];
my $redirects = $ARGV[1];
my $pages = $ARGV[2];

open(BLACK,$blacklist) or die;
my %blacklist = ();
while (<BLACK>) {
  chomp;
  $blacklist{$_} = 0;
}
close(BLACK);

my %redirects = ();
open(REDIR,$redirects) or die;
while (<REDIR>) {
  if (/\[\[(.*)\]\].*\[\[(.*)\]\]/) {
    $redirects{$1} = $2;
  }
}
close(REDIR);

open(PAGE,$pages) or die;
while (<PAGE>) {
  chomp;
  my $inblacklist = 0;
  if (exists $blacklist{$_}) {
    $inblacklist = 1;
  }
  if (exists $redirects{$_}) {
    if (exists $blacklist{$redirects{$_}}) {
      $inblacklist = 1;
    }
  }
  unless ($inblacklist) {
    print "$_\n";
  }
}