#!/usr/bin/php initcurl($Account, $Job, $pUseHTTPS = true); $this->Running = true; if ($this->readPage ("Benutzer:Luke081515Bot/Import") !== "true") { echo ("\nERROR: Bot deactivated! Wanted outtage?\n"); die (1); } echo ("\nCHECK: Bot has backlog? (1)"); $this->addNewTranslations (); if ($this->Running === false) { echo ("\nWARNING: Bot has backlog. Waiting 120 seconds before checking again."); sleep (120); $this->Running = true; echo ("\nCHECK: Bot has backlog? (2)"); $this->addNewTranslations (); if ($this->Running === false) { echo ("\nERROR: Bot has backlog! Seems like the bot is not working!\n"); die (1); } } echo ("\nSUCCESS: No backlog!\n"); die (0); } public function addNewTranslations () { $data = "action=query&list=recentchanges&format=php&rcdir=older&rctag=contenttranslation&rcprop=title&rclimit=5000&rcshow=!redirect&rawcontinue=&rctype=new"; try { $result = $this->httpRequest($data, $this->job, 'GET'); } catch (Exception $e) { throw $e; } $Answer = explode ("\"", $result); unset ($result); $i = 13; $a = 0; while (isset ($Answer [$i]) === true) { $Results [$a] = $Answer [$i]; $Result [$a] = urldecode ($Results [$a]); $a++; $i = $i + 10; } unset ($i); $a=0; while (isset ($Result [$a]) === true) { if (strstr ($Result [$a], "Benutzer:") !== false) { $Username = substr ($Result [$a], 9); $Username = strstr ($Username, "/", true); $Notification = true; } else $Notification = false; $AlreadySet = $this->readPage ("Wikipedia:Importwünsche"); $IgnoreList = $this->readPage ("Benutzer:Luke081515Bot/NoImport"); if (strstr ($IgnoreList, "") !== false) { if ((strstr ($AlreadySet, $Result [$a]) === false) && (strstr ($IgnoreList, $Result [$a]) === false)) { if (strstr ($AlreadySet, "{{/Intro}}") !== false) { $data = "action=query&prop=revisions&format=xml&rvprop=comment&rvlimit=1&rvdir=newer&rvtag=contenttranslation&titles=" . urlencode($Result [$a]); try { $result = $this->httpRequest($data, $this->job, 'GET'); } catch (Exception $e) { throw $e; } $website = $result; if (strstr ($website, "[[") !== false) { $Source = strstr ($website, "[["); $Target = $Source; $Source = explode (":", $Source); $Lang = $Source [1]; $Target = strstr ($Target, "|"); $Target = substr ($Target, 1); $Target = strstr ($Target, "]]", true); $data = "action=query&prop=revisions&format=xml&rvprop=comment&rvlimit=1&rvdir=newer&titles=" . urlencode($Result [$a]); try { $result = $this->httpRequest($data, $this->job, 'GET'); } catch (Exception $e) { throw $e; } $result = $website; if (strstr ($website, "[[") !== false) { $Comparision = strstr ($website, "[["); $Comparision = strstr ($Comparision, "|"); $Comparision = substr ($Comparision, 1); $Comparision = strstr ($Comparision, "]]", true); if ($Comparision === $Target) { if ($this->checkAlreadyImported ($Result [$a]) === false) $this->Running = false; } } } } } } $a++; } } public function checkAlreadyImported ($Site) { $data = "action=query&list=logevents&format=php&letype=import&ledir=older&letitle=" . urlencode ($Site) . "&lelimit=500&rawcontinue="; try { $result = $this->httpRequest($data, $this->job, 'GET'); } catch (Exception $e) { throw $e; } if (strstr ($result, "query") === false || strstr ($result, "import") !== false) return true; return false; } } $Bot = new IMPBotMonitor('Luke081515Bot@dewiki', 'CTT'); ?>