GetOldreviewedRedirects.php 1.56 KB
Newer Older
Luke081515's avatar
Luke081515 committed
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 41 42 43 44 45
#!/usr/bin/php
<?php
require './Cygnus/BotCore.php';
/** GetUnreviewedRedirects.php
* Shows unreviewed redirects
* @Author Luke081515
* @Version 0.1
* @Status Alpha
*/
class OldRedirects extends Core {
	public function __construct($Account, $Job) {
		$this->initcurl($Account, $Job, true, "user");
		$res = $this->generateUnreviewedChanges();
		echo "Count " . count($res) . " results\n";
		$this->askOperator('');
		for($a = 0; isset($res[$a]); $a++) {
			echo "https://de.wikipedia.org/w/index.php?curid=" . urlencode($res[$a]) . "&redirect=no\n";
		}
	}
	public function generateUnreviewedChanges() {
		$data = "action=query&format=json&list=oldreviewedpages&rawcontinue=1&orfilterredir=all&orfilterredir=redirects&orlimit=max";
		$i = 0;
		do {
			$result = $this->httpRequest($data, $this->job, "GET");
			$result = json_decode($result, true);
			if (isset($result["query-continue"])) {
				$continue = $result["query-continue"]["oldreviewedpages"]["orstart"];
			} else {
				$continue = false;
			}
			for($a = 0; isset($result["query"]["oldreviewedpages"][$a]["title"]); $a++) {
				$temp = $this->getPageID($result["query"]["oldreviewedpages"][$a]["title"]);
				if($temp !== false) {
					$resTitle[$i] = $result["query"]["oldreviewedpages"][$a]["title"];
					$res[$i] = $temp;
					$i++;
				}
			}
			$data = "action=query&format=json&list=oldreviewedpages&rawcontinue=1&orfilterredir=all&orlimit=max&orfilterredir=redirects&orstart=" . urlencode($continue);
		} while ($continue !== false);
		return $res;
	}
}
$Bot = new OldRedirects ('Luke081515Bot@dewiki', 'OldRedirects');
?>