Commit 1a9a8a47 authored by Freddy's avatar Freddy

Merge branch '1-add-olympiatools' into 'master'

Resolve "Add Olympiatools"

Closes #1

See merge request freddy2001/LarusBot!1
parents 5885ecd6 1aa54c99
#!/usr/bin/php
<?php
require 'Core/BotCore.php';
/** KennyOlympia.php
* Check missing links in Category:Olympische Spiele
* @Author Freddy2001 <freddy2001@wikipedia.de>
* @Version 0.1
* @Status Alpha
* @Runs Manually, on request
*/
class KennyOlympia extends Core {
public function KennyOlympia ($Account, $Job, $pUseHTTPS = true) {
$this->initcurl ($Account, $Job, $pUseHTTPS = true);
echo "---" . $Job . "---\nDurchlauf: " . date ('l jS F Y H:i:s') . "\n---\n";
$members = file_get_contents("https://petscan.wmflabs.org/?language=de&project=wikipedia&depth=15&categories=Olympische%20Spiele&combination=subset&negcats=&larger=&smaller=&minlinks=&maxlinks=&before=&after=&max_age=&show_redirects=both&edits%5Bbots%5D=both&edits%5Banons%5D=both&edits%5Bflagged%5D=both&templates_yes=&templates_any=&templates_no=&outlinks_yes=&outlinks_any=&outlinks_no=&links_to_all=&links_to_any=&links_to_no=&sparql=&manual_list=&manual_list_wiki=&pagepile=&wikidata_source_sites=&subpage_filter=either&common_wiki=auto&source_combination=&wikidata_item=no&wikidata_label_language=&wikidata_prop_item_use=&wpiu=any&sitelinks_yes=&sitelinks_any=&sitelinks_no=&min_sitelink_count=&max_sitelink_count=&labels_yes=&cb_labels_yes_l=1&langs_labels_yes=&labels_any=&cb_labels_any_l=1&langs_labels_any=&labels_no=&cb_labels_no_l=1&langs_labels_no=&format=json&output_compatability=catscan&sortby=none&sortorder=ascending&regexp_filter=&min_redlink_count=1&doit=Do%20it%21&interface_language=en&active_tab=tab_output");
$members = json_decode($members, true);
$members = $members['*'][0]['a']['*'];
$titles = array();
for($i = 0; $i < count($members); $i++) {
$titles[] = str_replace("_", " ", $members[$i]['title']);
}
$members = $titles;
sort($members, SORT_STRING);
for($i = 0; $i < count($members); $i++) {
echo "Checking Article ";
echo $i+1 . " of " . count($members) . ": " . $members[$i] ;
$links = $this->getLinks($members[$i]);
echo " (" . count($links) . " links)\n";
$missinglinks = $this->getMissingLinks($members[$i]);
if($missinglinks !== false) {
for($j = 0; $j < count($missinglinks); $j++) {
$rotlinks[] = $missinglinks[$j];
}
}
}
$result = array_unique($rotlinks);
sort($result, SORT_STRING);
$textfile = "";
for($i = 0; $i < count($result); $i++) {
$textfile .= "* [[" . $result[$i] . "]]\n";
}
file_put_contents("wikitext.txt", $textfile);
}
}
$Bot = new KennyOlympia ('LarusBot@dewiki', 'KennyOlympia');
?>
#!/usr/bin/php
<?php
require 'Core/BotCore.php';
/** WriteOlympia.php
* Second part of redlink check of Category:Olympia
* @Author Freddy2001 <freddy2001@wikipedia.de>
* @Version 0.1
* @Status Alpha
* @Runs Manually, on request (KennyOlympia must run before this!!!)
*/
class WriteOlympia extends Core {
public function WriteOlympia($Account, $Job, $pUseHTTPS = true) {
$this->initcurl($Account, $Job, $pUseHTTPS = true);
echo "---" . $Job . "---\nDurchlauf: " . date('l jS F Y H:i:s') . "\n---\n";
$page = "User:Kenny McFly/Olympia";
$content = file_get_contents ("wikitext.txt");
$contentarray = explode("\n",$content);
for($i = 0; $i < count($contentarray); $i++) {
$contentarray[$i] = substr(substr($contentarray[$i], 4), 0, -2);
}
$buchstabenarray = array();
for($i = 0; $i < count($contentarray); $i++) {
$buchstabe = mb_substr($contentarray[$i], 0, 1);
$buchstabeinbsarray = false;
if(count($buchstabeinbsarray) > 0) {
for($j = 0; $j <= count($buchstabenarray); $j++) {
if($j > 0) {
if($buchstabenarray[$j]['buchstabe'] == $buchstabe) {
$buchstabeinbsarray = true;
$buchstabeinbsarraypos = $j;
}
}
}
} else {
$buchstabeinbsarray = false;
}
if($buchstabeinbsarray == true) {
// Buchstabe schon vorhanden
$buchstabenarray[$buchstabeinbsarraypos]['entry'][] = $contentarray[$i];
} else {
$temp = count($buchstabenarray) + 1;
$buchstabenarray[$temp]['buchstabe'] = $buchstabe;
$buchstabenarray[$temp]['entry'][] = $contentarray[$i];
// Buchstabe anlegen
}
}
$count = 0;
$linklistenarray = array();
for($i = 0; $i < count($buchstabenarray); $i++) {
$content = '== ' . $buchstabenarray[$i]['buchstabe'] . ' ==' . "\n";
if(isset($buchstabenarray[$i]) AND ($buchstabenarray[$i]['buchstabe'] !== "")) {
echo $i . " of " . count($buchstabenarray) . "\n";
$count++;
$linklistenarray[] = $buchstabenarray[$i]['buchstabe'];
for($j = 0; $j < count($buchstabenarray[$i]['entry']); $j++) {
$content = $content . "# [[" . $buchstabenarray[$i]['entry'][$j] . "]]\n";
}
$this->editPage($page . "/" . $buchstabenarray[$i]['buchstabe'], $content, "Bot: Aktualisiere Rotlinkliste", 2);
}
}
$linkliste = "";
for($i = 0; $i < count($linklistenarray); $i++) {
$linkliste = $linkliste . "# [[/" . $linklistenarray[$i] . "|Rotlinks beginnend mit " . $linklistenarray[$i] . "]]\n" ;
}
$this->editPage($page , $linkliste, "Bot: Aktualisiere Rotlinkliste", 2);
}
}
$Bot = new WriteOlympia ('LarusBot@dewiki', 'WriteOlympia');
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment