Commit bc604387 authored by Luke081515's avatar Luke081515 Committed by Luke081515

Add deletion of created pages

* Deletes created pages of the user, which should get blocked.
parent 8110129e
Pipeline #1388 passed with stages
in 1 minute and 45 seconds
......@@ -12,6 +12,11 @@ class GlobalMassBlock extends Core {
$this->initcurl($Account, $Job, $pUseHTTPS, "user");
while (true) {
$IP = $this->askOperator("\nGive me the IP:");
if (strpos($IP, ".0/24") === false && strpos($IP, ".0/16") === false) {
$single = null;
} else {
$single = $this->askOperator("\nGive me the single IP:");
}
$res = $this->blockGlobal($IP, "Spambot", "3 months", 0, 1, 0);
if ($res === "success") {
echo ("\033[01;32mBlocked (globally)!\033[0m");
......@@ -24,7 +29,50 @@ class GlobalMassBlock extends Core {
} else {
echo ("\n\033[01;31mNot blocked (locally)!\033[0m");
}
if ($single !== null) {
$IP = $single;
}
echo "\n\033[01;33mFetching created pages...\033[0m";
$created = $this->getCreatedPages($IP);
$failures = 0;
if ($created !== false) {
while ($created !== false) {
echo "\n\033[01;33mFound " . count($created) . " Pages...\n\033[0m";
for ($a = 0; isset($created[$a]); $a++) {
echo "\n\033[01;34mDeleting " . $created[$a] . "...\033[0m";
$res = $this->deletePage($created[$a], "Spam");
if ($res === "success") {
echo ("\n\033[01;32mDeleted " . $created[$a] . "!\n\033[0m");
} else {
echo ("\n\033[01;31mFailed to delete " . $created[$a] . "!\n\033[0m");
$failures++;
}
}
if ($failures >= 10) {
echo ("\n\033[01;31mToo many errors, ABORTING!\033[0m");
}
echo "\n\033[01;33mFetching created pages (again)...\033[0m";
$created = $this->getCreatedPages($IP);
}
if ($failures < 10) {
echo ("\n\033[01;32mFinished cleaning!\033[0m");
}
} else {
echo ("\n\033[01;32mNothing to clean!\033[0m");
}
}
}
public function getCreatedPages($user) {
$result = $this->httpRequest("action=query&format=json&list=usercontribs&uclimit=max&ucuser=" . urlencode($user)
. "&ucdir=older&ucshow=new", $this->job, "GET");
$result = json_decode($result, true);
for ($a = 0; isset($result["query"]["usercontribs"][$a]["title"]); $a++) {
$createResults[$a] = $result["query"]["usercontribs"][$a]["title"];
}
if (!isset($createResults[0])) {
return false;
}
return $createResults;
}
}
$Bot = new GlobalMassBlock ('Luke081515@deployment', 'MassBlock');
......
......@@ -10,7 +10,7 @@ require './Cygnus/BotCore.php';
class GlobalMassLock extends Core {
public function __construct($Account, $Job, $pUseHTTPS = true) {
$this->initcurl($Account, $Job, $pUseHTTPS, "user");
do {
while (true) {
$user = $this->askOperator("\nGive me the username:");
$res = $this->lockGlobal($user, "lock", "nochange", "Spambot");
if ($res === "success") {
......@@ -24,7 +24,47 @@ class GlobalMassLock extends Core {
} else {
echo ("\n\033[01;31mNot blocked!\033[0m");
}
} while (true);
echo "\n\033[01;33mFetching created pages...\033[0m";
$created = $this->getCreatedPages($user);
$failures = 0;
if ($created !== false) {
while ($created !== false) {
echo "\n\033[01;33mFound " . count($created) . " Pages...\n\033[0m";
for ($a = 0; isset($created[$a]); $a++) {
echo "\n\033[01;34mDeleting " . $created[$a] . "...\033[0m";
$res = $this->deletePage($created[$a], "Spam");
if ($res === "success") {
echo ("\n\033[01;32mDeleted " . $created[$a] . "!\n\033[0m");
} else {
echo ("\n\033[01;31mFailed to delete " . $created[$a] . "!\n\033[0m");
$failures++;
}
}
if ($failures >= 10) {
echo ("\n\033[01;31mToo many errors, ABORTING!\033[0m");
}
echo "\n\033[01;33mFetching created pages (again)...\033[0m";
$created = $this->getCreatedPages($user);
}
if ($failures < 10) {
echo ("\n\033[01;32mFinished cleaning!\033[0m");
}
} else {
echo ("\n\033[01;32mNothing to clean!\033[0m");
}
}
}
public function getCreatedPages($user) {
$result = $this->httpRequest("action=query&format=json&list=usercontribs&uclimit=max&ucuser=" . urlencode($user)
. "&ucdir=older&ucshow=new", $this->job, "GET");
$result = json_decode($result, true);
for ($a = 0; isset($result["query"]["usercontribs"][$a]["title"]); $a++) {
$createResults[$a] = $result["query"]["usercontribs"][$a]["title"];
}
if (!isset($createResults[0])) {
return false;
}
return $createResults;
}
}
$Bot = new GlobalMassLock ('Luke081515@deployment', 'MassLock');
......
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