Zum Inhalt springen

Wikipedia:Statistik/NEWStics.pl

Us der alemannische Wikipedia, der freie Dialäkt-Enzyklopedy
#!/usr/bin/perl
use URI::Escape;
use LWP::UserAgent;
use HTML::Entities;
# This script was released by [[w:als:User:Melancholie]] under the GNU General Public License and Creative Commons by-sa (attribution + share alike); if you should improve this script, please tell me!
# sumUp is inaccurate if last; when $pos=$max
# = instead of =~ s?
# code/lang

$max = 15;
$timestamp = 0;
$timestart = 0;

$cruft{"Hauptseite"} = 1;
$cruft{"Diskussion"} = 1;
$cruft{"Benutzer"} = 1;
$cruft{"Kategorie"} = 1;
$cruft{"Bild"} = 1;

## WN ##

$code{1} = "en.n";
$lang{1} = "en";
$main{1} = "Main_Page";
$more{1} = "more";
$rdir{1} = "; incl. redirects";
$temp{1} = "Template:Popular_articles";
$upub{1} = "unpublished";

$code{2} = "de.n";
$lang{2} = "de";
$main{2} = "Hauptseite";
$more{2} = "mehr";
$rdir{2} = "; inkl. Weiterleitungen";
$temp{2} = "Vorlage:Beliebte_Artikel";
$upub{2} = "unveröffentlicht";

## WP ##

$code{3} = "en";
$lang{3} = "en";
$main{3} = "Main_Page";
$more{3} = "more";
$rdir{3} = "; incl. redirects";
$tmpN{3} = "Popular_articles";
$temp{3} = "Template:Popular_articles";
#>
$loop = 3;

open HITS, "totalHits.txt";
while (<HITS>) {
 if ($_ =~ /^([a-z\.]+) ([0-9]+)$/) {
  $totalWiki = $1;
  $totalHits{$totalWiki} = $2;
  $totalHits{$totalWiki} =~ s/([0-9])([0-9]{3})$/$1,$2/;
  $totalHits{$totalWiki} =~ s/([0-9])([0-9]{3}),/$1,$2,/;
 }
}
close HITS;

open TIME, "timestamp.log";
while (<TIME>) {
 if ($_ =~ /^([^\r\n]+)$/) {
  $logDump = $1;
  $timestamp = $logDump;
  $timestamp =~ s/^newscounts-[0-9]{8}-([0-9]{2}).+$/$1/;
  $timeEnd = $timestamp;
  $timestamp =~ s/^0//;
  if ($timestamp eq 0) {
   $timestamp = 24;
  }
  $timestart = $timestamp-1;
  $logDump =~ s/newscounts-//;
 }
}
close TIME;

if ($timestart < 10) {
 $timestart = "0$timestart";
 if ($timestamp < 10) {
  $timestamp = "0$timestamp";
 }
}
for (my $i = 1; $i <= $loop; $i++) {
 $pos = 0;
 $item = 0;
 $hitSum = 0;
 $list[0] = "";
 undef($wanted);
 $redirect = $rdir{$i};
 if ($code{$i} =~ /\.n$/) {
  $url = "http://$lang{$i}.wikinews.org/w/index.php?title=$main{$i}&action=render&stable=0&oldid=cur";
  $file = "frontPage.htm";
  for (my $bl = 1; $bl <= 1; $bl++) {
   $userAgent = LWP::UserAgent->new();
   $userAgent->agent("WikiNEWSticsBOT (by user Melancholie)");
   $httpRequest = HTTP::Request->new("GET", $url);
   $serverResponse = $userAgent->request($httpRequest, $file);
   if ($serverResponse->is_error()) {
    if ($serverResponse->code() !~ /^(301|302|307|401|403|404)$/) {#...|500|503
     sleep(30);#++/*2
     redo;
    }
   }
  }
  open HTM, "frontPage.htm";
  while (<HTM>) {# to be checked frequently
   if ($lang{$i} eq "en" && $_ =~ /id="Most_popular_articles"/) {$skip = 1;}
   if ($lang{$i} eq "de" && $_ =~ /id="Beliebte_Artikel"/) {$skip = 1;}
   if ($lang{$i} eq "en" && $_ =~ /title="Template:Popular articles"/) {undef($skip);}
   if ($lang{$i} eq "de" && $_ =~ /title="Vorlage:Beliebte Artikel"/) {undef($skip);}
   if (!$skip && $_ =~ /<a [^>]+ title="([^"]+)"/) {
    $title = $1;
    if ($title =~ /&/) {decode_entities($title);}
    if ($title !~ /:[^_ ]/) {
     $lead{$title} = 1;
    }
   }
  }
  close HTM;
 }
 open IN, "newscounts/sortedFilteredLog";
 if ($code{$i} =~ /\.n$/) {
  open OUT, ">../../pywpbot_news/Top_$lang{$i}.txt";
  open WTD, ">../../pywpbot_news/Wtd_$lang{$i}.txt";
 } else {
  open OUT, ">../../pywikipedia/Top_$lang{$i}.txt";
 }
 print OUT "\#START<noinclude>{{/top|$timeEnd}}</noinclude>";
 if ($code{$i} eq "en.n") {
  print WTD "\#START<noinclude>__NOEDITSECTION__\n== Latest most awaited Articles ==\n<div style=\"margin-top: -12px;\"><small>Often visited non-published Articles</small></div>\n</noinclude>";
 } elsif ($code{$i} eq "de.n") {
  print WTD "\#START<noinclude>__NOEDITSECTION__\n== Meistbesuchte unveröffentlichte Artikel ==\n<div style=\"margin-top: -12px;\"><small>Am meisten aufgerufene unveröffentlichte Artikel</small></div>\n</noinclude>";
 }
 while (<IN>) {
  if ($_ =~ /^([a-z\.]+) ([0-9]+) ([^ \r\n]+)$/ && $1 eq $code{$i}) {
   $hits = $2;
   $page = $3;
   if ($lang{$i} eq "en" && $hits < 5) {last;}#?
   if ($page =~ /^(Portal|Wikinews|WN|Media[Ww]iki)(_[tT]alk)?$/) {next;}
   if ($lang{$i} eq "en" && $page =~ /^(Main_?[Pp]age|Alleged_Main_Page|Talk|User|Category|Template|Comments?|Image|Help)(_[tT]alk)?$/) {next;}
   if ($cruft{$page}) {next;}
   $page =~ s/_/ /g;
   if ($code{$i} =~ /\.n$/) {
    $pageEnc = uri_escape($page);
    $url = "http://$lang{$i}.wikinews.org/w/api.php?action=query&format=xml&prop=categories&titles=$pageEnc&cllimit=500&redirects";
    $file = "categories.xml";
    for (my $j = 1; $j <= 1; $j++) {
     $userAgent = LWP::UserAgent->new();
     $userAgent->agent("WikiNEWSticsBOT (by user Melancholie)");
     $httpRequest = HTTP::Request->new("GET", $url);
    $serverResponse = $userAgent->request($httpRequest, $file);
    if ($serverResponse->is_error()) {
     if ($serverResponse->code() !~ /^(301|302|307|401|403|404)$/) {#...|500|503
      sleep(30);#++/*2
      redo;
     }
    }
   }
   undef($public);
   $redirDest = 0;
   open XML, "categories.xml";
   while (<XML>) {
    if ($_ =~ /<redirects>/ && $_ =~ /<r from="[^"]+" to="([^"]+)"/) {
     $redirDest = $1;
     if ($redirDest =~ /&/) {decode_entities($redirDest);}
     if ($redirDest !~ /:[^_ ]/ && $redirDest !~ /^(Main Page|Hauptseite)$/) {
      if ($article{$redirDest}) {# inaccurate if last; when $pos=$max
       if ($list[$article{$redirDest}] =~ /'''([^']+)''' (hits|Aufrufe)/) {#\{\{\/hits\|hits|summed up\}\}
        $cVal = $1;
        $cVal =~ s/,//g;
        $sum = $cVal + $hits;
        $sumTxt = $sum;
        $sumTxt =~ s/([0-9])([0-9]{3})$/$1,$2/;
        $list[$article{$redirDest}] =~ s/'''[^']+''' (hits last hour|Aufrufe)($redirect)?/'''$sumTxt\''' $1$redirect/g;
       }
      } else {
       $item++;
       $article{$redirDest} = $item;
       $hitsTxt = $hits;
       $hitsTxt =~ s/([0-9])([0-9]{3})$/$1,$2/;
#      $redirDestTxt = $redirDest;
#      if ($redirDest =~ /=/) {
#       $redirDestTxt =~ s/=/\%3D/g;
#      }
       if ($lang{$i} eq "en") {
        $list[$item] = "\n\# [[$redirDest]] <small>('''$hitsTxt\''' hits last hour$redirect; <u>not yet published</u>)</small>";
       } elsif ($lang{$i} eq "de") {
        $list[$item] = "\n\# [[$redirDest]] <small>('''$hitsTxt\''' Aufrufe$redirect; <u>noch nicht veröffentlicht</u>)</small>";
       }
      }
     }
    }
    if (($lang{$i} eq "en" && $_ =~ /"Category:(Published|Breaking[_ ]News|No[_ ]publish)"/) || ($lang{$i} eq "de" && $_ =~ /"Kategorie:(Veröffentlicht|Artikelstatus:[_ ]Aktuell|Artikelstatus:[_ ]Fertig)"/)) {
     $public = 1;
     last;
    } elsif ($lang{$i} eq "de" && $_ =~ /"Kategorie: ?[0-9]{1,2}\. ?([0-9]{1,2}\. ?200[1-6]|0?[1-3]\. ?2007)"/) {
     $public = 1;
     last;
    }
   }
   close XML;
   if ($redirDest ne 0) {
    if ($public) {
     if ($pos < $max && ($lead{$redirDest} || $lead{$page})) {
      $hitSum = $hitSum + $hits;
      if ($list[$article{$redirDest}] =~ /\#[^\r\n]+>$/) {
       $pos++;
       $hitsTxt = $hits;
       $hitsTxt =~ s/([0-9])([0-9]{3})$/$1,$2/;
#      $redirDestTxt = $redirDest;
#      if ($redirDest =~ /=/) {
#       $redirDestTxt =~ s/=/\%3D/g;
#      }
       if ($lang{$i} eq "en") {
        $list[$article{$redirDest}] = "\n\# [[$redirDest]]{{\#if:{{{nohits|}}}||&nbsp;<small>('''$hitsTxt\''' hits last hour$redirect)</small>}}";#contains redundant text
       } elsif ($lang{$i} eq "de") {
        $list[$article{$redirDest}] = "\n\# [[$redirDest]]{{\#if:{{{nohits|}}}||&nbsp;<small>('''$hitsTxt\''' Aufrufe$redirect)</small>}}";#contains redundant text
       }
      }
     } elsif ($list[$article{$redirDest}] =~ /\#[^\r\n]+>$/) {
      $list[$article{$redirDest}] = "";
      delete $article{$redirDest};
#     $hitsTxt = $hits;
#     $hitsTxt =~ s/([0-9])([0-9]{3})$/$1,$2/;
#     $redirDestTxt = $redirDest;
#     if ($redirDest =~ /=/) {
#      $redirDestTxt =~ s/=/\%3D/g;
#     }
#     if ($lang{$i} eq "en") {
#      $list[$article{$redirDest}] = "\n\# [[$redirDest]] <small>('''$hitsTxt\''' hits last hour$redirect; <i>archived</i>)</small>";
#     } elsif ($lang{$i} eq "de") {
#      $list[$article{$redirDest}] = "\n\# [[$redirDest]] <small>('''$hitsTxt\''' Aufrufe$redirect; <i>archiviert</i>)</small>";
#     }
     }
    }
    next;
   }
  } elsif ($pos < $max) {
   $pageEnc = uri_escape($page);
   $url = "http://$lang{$i}.wikipedia.org/w/api.php?action=query&format=xml&prop=revisions&titles=$pageEnc&rvprop=";
   $file = "history.xml";
   for (my $j = 1; $j <= 1; $j++) {
    $userAgent = LWP::UserAgent->new();
    $userAgent->agent("WikiNEWSticsBOT (by user Melancholie)");
    $httpRequest = HTTP::Request->new("GET", $url);
    $serverResponse = $userAgent->request($httpRequest, $file);
    if ($serverResponse->is_error()) {
     if ($serverResponse->code() !~ /^(301|302|307|401|403|404)$/) {#...|500|503
      sleep(30);#++/*2
      redo;
     }
    }
   }
   undef($missing);
   open XML, "history.xml";
   while (<XML>) {
    if ($_ =~ /missing="/) {
     $missing = 1;
    }
   }
   close XML;
   if ($missing) {# only if given!
    next;
   }
   $public = 1;
   $lead{$page} = 1;
  } else {
   $public = 1;
   $lead{$page} = 1;
  }
  if (!$public || !$lead{$page}) {
   if ($public) {
    $list[$article{$page}] = "";
    delete $article{$page};
    next;
   } elsif (!$lead{$page} && $page !~ /^[^ ]+ [^ ]+ [^ ]/) {
    $list[$article{$page}] = "";
    delete $article{$page};
    next;
   }
   if ($article{$page}) {
    if ($list[$article{$page}] =~ /'''([^']+)''' (hits|Aufrufe)/) {
     $cVal = $1;
     $cVal =~ s/,//g;
     $sum = $cVal + $hits;
     $sumTxt = $sum;
     $sumTxt =~ s/([0-9])([0-9]{3})$/$1,$2/;
     $list[$article{$page}] =~ s/'''[^']+''' (hits last hour|Aufrufe)/'''$sumTxt\''' $1; summed up/g;
    }
   } else {
    if ($code{$i} eq "de.n" && $hits < 3) {
     next;
    }
    $item++;
    $article{$page} = $item;
#   if (!$public) {
     $google = $page;
     $google =~ s/ /+/g;
     $hitsTxt = $hits;
     $hitsTxt =~ s/([0-9])([0-9]{3})$/$1,$2/;
#    $pageTxt = $page;
#    if ($page =~ /=/) {
#     $pageTxt =~ s/=/\%3D/g;
#    }
     if ($lang{$i} eq "en") {
      $list[$item] = "{{subst:\#ifexist:$page|\n\# [[$page]] <small>('''$hitsTxt\''' hits last hour; <u>not yet published</u>)</small>|\n\# [[$page]] [[google:\"$google\"|<sup title=\"Breaking news?\">(investigate)</sup>]] <small>('''$hitsTxt\''' hits last hour; [{{FULLURL:Special:Log|type=delete&page=$google}} deleted] <b>or</b> yet to be written)</small>}}";#contains redundant text
     } elsif ($lang{$i} eq "de") {
      $list[$item] = "{{subst:\#ifexist:$page|\n\# [[$page]] <small>('''$hitsTxt\''' Aufrufe; <u>noch nicht veröffentlicht</u>)</small>|\n\# [[$page]] [[google:\"$google\"|<sup title=\"Breaking news; aktuell?\">(recherchiere)</sup>]] <small>('''$hitsTxt\''' Aufrufe; [{{FULLURL:Spezial:Logbuch|type=delete&page=$google}} gelöscht] <b>oder</b> noch nicht erstellt)</small>}}";#contains redundant text
     }
#   } else {
#    $hitsTxt = $hits;
#    $hitsTxt =~ s/([0-9])([0-9]{3})$/$1,$2/;
#    $pageTxt = $page;
#    if ($page =~ /=/) {
#     $pageTxt =~ s/=/\%3D/g;
#    }
#    if ($lang{$i} eq "en") {
#     $list[$item] = "\n\# [[$page]] <small>('''$hitsTxt\''' hits last hour; <i>archived</i>)</small>";
#    } elsif ($lang{$i} eq "de") {
#     $list[$item] = "\n\# [[$page]] <small>('''$hitsTxt\''' Aufrufe; <i>archiviert</i>)</small>";
#    }
#   }
   }
  } else {
   if ($article{$page}) {
    $hitSum = $hitSum + $hits;
    if ($list[$article{$page}] =~ /'''([^']+)''' (hits|Aufrufe)/) {
     $cVal = $1;
     $cVal =~ s/,//g;
     $sum = $cVal + $hits;
     $sumTxt = $sum;
     $sumTxt =~ s/([0-9])([0-9]{3})$/$1,$2/;
     $list[$article{$page}] =~ s/'''[^']+''' (hits last hour|Aufrufe)/'''$sumTxt\''' $1; summed up/;
    }
   } elsif ($pos < $max || $code{$i} eq "en") {
    if ($page !~ /^(404 error\/?|\%s|Favicon.ico|\$1)$/) {
     if ($pos < $max) {
      $hitSum = $hitSum + $hits;
     }
     $pos++;
    }
    $item++;
    $article{$page} = $item;
    $hitsTxt = $hits;
    $hitsTxt =~ s/([0-9])([0-9]{3})$/$1,$2/;
#   $pageTxt = $page;
#   if ($page =~ /=/) {
#    $pageTxt =~ s/=/\%3D/g;
#   }
    if ($page =~ /^(404 error\/?|\%s|Favicon.ico|\$1)$/) {
     $list[$item] = "\n<!-- $page ($hitsTxt hits) -->";
    } elsif ($pos > $max) {
     if ($lang{$i} eq "en") {
      $list[$item] = "{{subst:\#ifexist:$page|\n\* [[$page]]{{\#if:{{{nohits|}}}||&nbsp;<small>('''$hitsTxt\''' hits last hour)</small>}}|}}";#contains redundant text
     } elsif ($lang{$i} eq "de") {
      $list[$item] = "{{subst:\#ifexist:$page|\n\* [[$page]]{{\#if:{{{nohits|}}}||&nbsp;<small>('''$hitsTxt\''' Aufrufe)</small>}}|}}";#contains redundant text
     }
    } else {
     if ($lang{$i} eq "en") {
      $list[$item] = "\n\# [[$page]]{{\#if:{{{nohits|}}}||&nbsp;<small>('''$hitsTxt\''' hits last hour)</small>}}";#contains redundant text
     } elsif ($lang{$i} eq "de") {
      $list[$item] = "\n\# [[$page]]{{\#if:{{{nohits|}}}||&nbsp;<small>('''$hitsTxt\''' Aufrufe)</small>}}";#contains redundant text
     }
    }
   } elsif ($code{$i} ne "en.n" && $code{$i} ne "de.n") {#?
    last;
   } else {
    $list[$article{$page}] = "";
    delete $article{$page};
   }
  }
  if ($item > 999) {#-$max (500, wg. Parser?)
   last;
  }
 }
 }
 #########################
 foreach (keys %article) {
  delete $article{$_};
 }
 #########################
 $a = -1;#!
 foreach (@list) {#ToDo: $prevPubHits5, $movePubUp3, what if $a-X also is an item to be moved up?
  $a++;
  if ($_ ne "" && (($lang{$i} eq "en" && $_ !~ />not yet published</) || ($lang{$i} eq "de" && $_ !~ />noch nicht veröffentlicht</))) {#|archived/|archiviert
   if ($_ ne "" && $_ =~ /'''([^']+)''' (hits|Aufrufe)/) {
    $pubHits = $1;
    $pubHits =~ s/,//g;
    if ($prevPubHits3 && $pubHits > $prevPubHits3) {
     $movePubUp{$a-3} = $a;
    } elsif ($prevPubHits2 && $pubHits > $prevPubHits2) {
     $movePubUp{$a-2} = $a;
     $prevPubHits3 = $prevPubHits2;
    } elsif ($prevPubHits && $pubHits > $prevPubHits) {
     $movePubUp{$a-1} = $a;
     $prevPubHits2 = $prevPubHits;
    }
    $prevPubHits = $pubHits;
   }
  } elsif ($_ ne "" && $_ =~ /'''([^']+)''' (hits|Aufrufe)/) {
   $unpHits = $1;
   $unpHits =~ s/,//g;
   if ($_ =~ /(fuck|shit|crap|arse|damn|hell|cunt|piss|cock|dick|penis|sucker|vagina|pussy|bitch|asshole)/i) {#no four-letter words
    $list[$a] = "";
   } else {
    if ($prevUnpHits3 && $unpHits > $prevUnpHits3) {
     $moveUnpUp{$a-3} = $a;
    } elsif ($prevUnpHits2 && $unpHits > $prevUnpHits2) {
     $moveUnpUp{$a-2} = $a;
     $prevUnpHits3 = $prevUnpHits2;
    } elsif ($prevUnpHits && $unpHits > $prevUnpHits) {
     $moveUnpUp{$a-1} = $a;
     $prevUnpHits2 = $prevUnpHits;
    }
    $prevUnpHits = $unpHits;
   }
  }
 }
 #####################
 undef($prevPubHits3);
 undef($prevPubHits2);
 undef($prevPubHits);
 undef($prevUnpHits3);
 undef($prevUnpHits2);
 undef($prevUnpHits);
 #####################
 $a = -1;#!
 $p = 0;
 foreach (@list) {
  $a++;
  if ($_ ne "" && (($lang{$i} eq "en" && $_ !~ />not yet published</) || ($lang{$i} eq "de" && $_ !~ />noch nicht veröffentlicht</))) {#|archived/|archiviert
   if ($_ !~ /-->$/) {
    $p++;
    if ($p eq 4) {
     print OUT "\n{{\#ifexpr:{{{top|$max}}} > 3|";
    } elsif ($p eq 6) {
     print OUT "\n{{\#ifexpr:{{{top|$max}}} > 5|";
    } elsif ($p eq 11) {
     print OUT "\n{{\#ifexpr:{{{top|$max}}} > 10|";
    } elsif ($p eq $max+1) {
     print OUT "\n{{\#ifexpr:{{{top|999}}} > $max|";
     print OUT "\n{{$tmpN{$i}/more|";
    }
   }
   if ($movePubUp{$a} && !($code{$i} eq "en" && $a <= $max)) {#ToDo!
    print OUT $list[$movePubUp{$a}];
    if ($list[$movePubUp{$a}] !~ /-->$/) {
     $p++;
     if ($p eq 4) {
      print OUT "\n{{\#ifexpr:{{{top|$max}}} > 3|";
     } elsif ($p eq 6) {
      print OUT "\n{{\#ifexpr:{{{top|$max}}} > 5|";
     } elsif ($p eq 11) {
      print OUT "\n{{\#ifexpr:{{{top|$max}}} > 10|";
     } elsif ($p eq $max+1) {
      print OUT "\n{{\#ifexpr:{{{top|999}}} > $max|";
      print OUT "\n{{$tmpN{$i}/more|";
     }
    }
    $list[$movePubUp{$a}] = "";
    delete $movePubUp{$a};
   }
   print OUT $_;
   $list[$a] = "";
  } elsif ($_ ne "") {#archived|archiviert
   if ($moveUnpUp{$a}) {
    print WTD $list[$moveUnpUp{$a}];
    $list[$moveUnpUp{$a}] = "";
    delete $moveUnpUp{$a};
   }
   print WTD $_;
   $wanted = 1;
   $list[$a] = "";
  }
 }
 #####################
 $list = ();
 @list = ();
 undef @list;
 foreach (keys %movePubUp) {
  delete $movePubUp{$_};
 }
 foreach (keys %moveUnpUp) {
  delete $moveUnpUp{$_};
 }
 #####################
 if ($p > 3) {
  print OUT "\n}}";
 }
 if ($p > 5) {
  print OUT "\n}}";
 }
 if ($p > 10) {
  print OUT "\n}}";
 }
 if ($p > $max) {
  print OUT "\n}}";
  print OUT "\n}}";
 }
 print OUT "<includeonly><div style=\"float: right; margin: -5px 0 -2px 0;\"><small>[[$temp{$i}|» $more{$i}]]</small></div></includeonly>";
 $hitSum =~ s/([0-9])([0-9]{3})$/$1,$2/;
 if ($pos < $max) {$posTxt = "|$pos";} else {$posTxt = "";}#|$max
 print OUT "<noinclude>";
 if ($code{$i} eq "en") {
  print OUT "\n";
 }
 print OUT "{{/bottom|$hitSum|$totalHits{$code{$i}}|$logDump|04:52, 3. Apr. 2009 (MESZ)|$timestart|$timestamp$posTxt";
 if (!$wanted) {
  print OUT "|WTD=";
 }
 print OUT "}}";
 if ($code{$i} eq "en") {
  print OUT "\n";
 }
 print OUT "</noinclude>\#END";
 if ($code{$i} eq "en.n") {
  print WTD "\n<noinclude><!--[[$temp{$i}/$upub{$i}]]-->\n\n\nThese have been the most accessed non-published or non-existent articles lately<!-- 5+, no \"four-letter words\" -->, not shown at '''[[Vorlage:Popular articles]]'''.<sup>[[Vorlage Diskussion:Popular_articles/unpublished|?]]</sup>\n----\n* <span style=\"color: #696969;\">Last update: 04:52, 3. Apr. 2009 (MESZ), based on period of $timestart:00–$timestamp:00 (UTC)</span>\n\n[[de:Vorlage:Beliebte_Artikel/unveröffentlicht]]\n</noinclude>\#END";
 } elsif ($code{$i} eq "de.n") {
  print WTD "\n<noinclude><!--[[$temp{$i}/$upub{$i}]]-->\n\n\nDies sind die kürzlich am meisten besuchten unveröffentlichten oder nicht vorhandenen Artikel<!-- 5+, no \"four-letter words\" -->, die unter '''[[Vorlage:Beliebte Artikel]]''' nicht angezeigt werden.<sup>[[Vorlage_Diskussion:Beliebte_Artikel/unveröffentlicht|?]]</sup>\n----\n* <span style=\"color: #696969;\">Letzte Aktualisierung: 04:52, 3. Apr. 2009 (MESZ), für den Zeitraum von $timestart:00–$timestamp:00 (UTC)</span>\n\n[[en:Template:Popular_articles/unpublished]]\n</noinclude>\#END";
 }
 close OUT;
 close IN;
 if ($code{$i} =~ /\.n$/) {
  close WTD;
  if (-e "wantstics_$lang{$i}.sh") {
   chmod 0700, "wantstics_$lang{$i}.sh";
  }
  open EXE, ">wantstics_$lang{$i}.sh";
  print EXE "#!/bin/bash\n";
  if ($wanted) {
   print EXE "cd && cd pywpbot_news\n/usr/local/bin/python2.5 pagefromfile.py -lang:$lang{$i} -file:Wtd_$lang{$i}.txt -force -minor -start:\"\\#START\" -titlestart:\"\\<\\!--\\[\\[\" -titleend:\"\\]\\]--\\>\" -end:\"\\#END\"\n";
  } else {
   print EXE "exit 0\n";
  }
  close EXE;
  chmod 0700, "wantstics_$lang{$i}.sh";
 }
}
unlink ("frontPage.htm");
unlink ("newscounts/sortedFilteredLog");

# [[Wikipedia:Statistik/NEWStics.pl]] !END