function getNewPages($user) { global $wgOut, $wgUser; $wgOut->addHTML(Xml::openElement('form', array('action' => $this->getTitle()->getLocalURL('action=delete'), 'method' => 'post')) . HTML::hidden('wpEditToken', $wgUser->getEditToken()) . '<ul>'); $pages = BanPests::getBannablePages($user); $ips = BanPests::getBannableIP($user); if (count($pages)) { $wgOut->addHTML("<h2>" . wfMsg("blockandnuke-pages") . "</h2>"); $wgOut->addHtml("<ul>"); foreach ($pages as $title) { $wgOut->addHtml("<li>" . Linker::link($title)); $wgOut->addHtml(HTML::hidden('pages[]', $title)); } $wgOut->addHtml("</ul>\n"); } if (count($user)) { $wgOut->addHTML("<h2>" . wfMsg("blockandnuke-users") . "</h2>"); foreach ($user as $users) { $dbr = wfGetDB(DB_SLAVE); $result = $dbr->select('recentchanges', array('rc_user', 'rc_user_text'), array('rc_user_text' => $users), __METHOD__, array('ORDER BY' => 'rc_user ASC')); $name = array(); while ($row = $dbr->fetchObject($result)) { $name[] = array($row->rc_user_text, $row->rc_user); } $wgOut->addHtml("<ul>"); $seen = array(); foreach ($name as $infos) { list($user_2, $user_id) = $infos; if (!isset($seen[$user_2])) { $seen[$user_2] = true; $wgOut->addHtml("<li>" . Linker::link(Title::newFromText($user_2, NS_USER))); $wgOut->addHTML(HTML::hidden('names_2[]', $user_2) . HTML::hidden('userid[]', $user_id)); } } $wgOut->addHtml("</ul>\n"); } } if ($ips) { $wgOut->addHTML("<h2>" . wfMsg("blockandnuke-ip-addresses") . "</h2>"); foreach ($ips as $ip) { $wgOut->addHtml("<ul>"); $seen = array(); if (!isset($seen[$ip])) { $seen[$ip] = true; $wgOut->addHtml("<li>" . Linker::link(Title::newFromText($ip, NS_USER))); $wgOut->addHTML(HTML::hidden('ip[]', $ip)); } $wgOut->addHtml("</ul>\n"); } } $wgOut->addHTML("</ul>\n" . XML::submitButton(wfMsg('blockandnuke')) . "</form>"); }
public function execute() { global $wgBaNSpamUser; $this->output("Starting "); $real = $this->hasOption("hammer"); $brief = $this->hasOption("brief"); if (!$real) { $this->output("dry run\n"); } else { $this->output("\n"); } $bannable = BanPests::getBannableUsers(); $pages = BanPests::getBannablePages($bannable); $this->output(sprintf("Found %d bannable users and %d pages:\n", count($bannable), count($pages))); if (count($pages)) { $this->maybeOutput("Pages\n"); foreach ($pages as $page) { if ($page) { $this->maybeOutput("\t{$page}"); if ($real) { $this->maybeOutput(" ... deleting\n"); BanPests::deletePage(Title::newFromURL($page)); } else { $this->maybeOutput("\n"); } } } } $spammer = User::newFromName($wgBaNSpamUser); $banningUser = User::newFromName("WikiSysop"); $um = null; if (class_exists("UserMerger")) { $um = new UserMerger(null); } if (count($bannable)) { $this->maybeOutput("Users\n"); foreach ($bannable as $user) { $this->maybeOutput("\t{$user}"); $u = User::newFromName($user); if ($u === false) { $ips = array($user); } else { $ips = BanPests::getBannableIP($u); } if ($real) { $this->maybeOutput(" ... banning\n"); if ($u !== false) { BanPests::banUser($u, $banningUser, $spammer, $um); } if ($ips) { foreach ($ips as $ip) { $this->maybeOutput("\t\tEnsuring ban on {$ip}\n"); BanPests::banIPs($ip, $banningUser); } } } else { $this->maybeOutput("\n"); foreach ($ips as $ip) { $this->maybeOutput("\t\t{$ip}\n"); } } } } }