Commit 4bb32ebb authored by Luke081515's avatar Luke081515

Merge branch 'missingURV' into 'master'

Missing urv

See merge request !45
parents 0568f130 5b821982
Pipeline #3078 passed with stage
in 23 seconds
#!/usr/bin/php
<?php
require './Cygnus/BotCore.php';
/** URVAddNew.php
* Checks cat for unadded entries
* @Author Luke081515
* @Version 0.1
* @Status Alpha
*/
class URVAddNew extends Core {
protected $DB;
public function __construct($Account, $Job, $pUseHTTPS = true) {
$this->initcurl($Account, $Job, $pUseHTTPS);
if ($this->readPage("Benutzer:Luke081515Bot/AutoQS-URV") === "true") {
$this->compare();
$this->compare2();
}
}
public function compare () {
$resCat = unserialize($this->getCurrentCatMembers("Kategorie:Wikipedia:Urheberschaft ungeklärt"));
$resPage = serialize($this->getLinks("Wikipedia:Löschkandidaten/Urheberrechtsverletzungen"));
for ($i = 0; isset($resCat[$i]); $i++) {
if(strpos($resPage, $resCat[$i]) === false) {
$content = "";
$content = $this->readSection("Wikipedia:Löschkandidaten/Urheberrechtsverletzungen", 1);
$content = $content . "\n# [[" . $resCat[$i] . "]]: Automatisch nachgetragen. Hilfreiche Tools: ([https://tools.wmflabs.org/copyvios/?lang=de&project=wikipedia&title=" . urlencode($resCat[$i])
. "&action=search&use_engine=1&use_links=1&turnitin=1 Aktuelle Version]). --[[Benutzer:Luke081515Bot/URV/Add|Luke081515Bot]] ~~~~~";
$this->editSection("Wikipedia:Löschkandidaten/Urheberrechtsverletzungen", $content, "Bot: Update aus Kategorie ([[Benutzer:Luke081515Bot/URV/Add|URV/Add]])", 1);
}
}
}
public function compare2 () {
$resCat = unserialize($this->getCurrentCatMembers("Kategorie:Wikipedia:URV"));
$resPage = serialize($this->getLinks("Wikipedia:Löschkandidaten/Urheberrechtsverletzungen"));
for ($i = 0; isset($resCat[$i]); $i++) {
if(strpos($resPage, $resCat[$i]) === false) {
$content = "";
if(substr($resCat[$i], -3) === '.js' || $resCat[$i] === "Vorlage:URV" || $resCat[$i] === "Vorlage:URV/Doku") {
} else {
$content = $this->readPage("Wikipedia:Löschkandidaten/Urheberrechtsverletzungen");
$content = $content . "\n# [[" . $resCat[$i] . "]]: Automatisch nachgetragen. Hilfreiche Tools: ([https://tools.wmflabs.org/copyvios/?lang=de&project=wikipedia&title=" . urlencode($resCat[$i])
. "&action=search&use_engine=1&use_links=1&turnitin=1 Aktuelle Version]). --[[Benutzer:Luke081515Bot/URV/Add|Luke081515Bot]] ~~~~~";
$this->editPage("Wikipedia:Löschkandidaten/Urheberrechtsverletzungen", $content, "Bot: Update aus Kategorie ([[Benutzer:Luke081515Bot/URV/Add|URV/Add]])");
}
}
}
}
/** getLinks
* returns all links that are located at a page, maximum 5000
* @author Luke081515
* @param $page - page that gets analyzed
* @return array with page titles
*/
public function getLinks($title) {
$request = "action=query&prop=links&format=json&assert=bot&maxlag=5&pllimit=max&pldir=ascending&rawcontinue=&indexpageids=1&titles=" . urlencode($title);
$result = json_decode($this->httpRequest($request, $this->job, "GET"), true);
$pageID = $result["query"]["pageids"][0];
$count = 0;
while (isset($result["query"]["pages"][$pageID]["links"][$count]["title"])) {
$links[] = $result["query"]["pages"][$pageID]["links"][$count]["title"];
$count++;
}
if (isset($links[0])) {
return $links;
}
return false;
}
public function getCurrentCatMembers($kat) {
try {
$result = $this->httpRequest("action=query&format=json&generator=categorymembers&indexpageids=1&gcmtitle=" . urlencode($kat) .
"&prop=info&gcmlimit=max&rawcontinue=&redirects", $this->job, "GET");
} catch (Exception $e) {
throw $e;
}
$i = 0;
$result = json_decode($result, true);
while (isset($result["query"]["pageids"][$i])) {
$pages[$i] = $result["query"]["pageids"][$i];
$i++;
}
$i = 0;
$c = 0;
if (isset($pages[$i])) {
while (isset($pages[$i])) {
$page[$c] = $result["query"]["pages"][$pages[$i]]["title"];
$c++;
$i++;
}
}
if (!isset($page[0])) {
return false;
} else {
return serialize($page);
}
}
}
$Bot = new URVAddNew ('Luke081515Bot@dewiki', 'URVAddNew');
?>
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