mirror of https://github.com/BOINC/boinc.git
admin: add "delete_spammers.php": script to help delete spam profiles
This commit is contained in:
parent
b6f919b957
commit
6706f5c893
|
@ -387,7 +387,7 @@ class BoincProfile {
|
||||||
$db = BoincDb::get();
|
$db = BoincDb::get();
|
||||||
return $db->insert('profile', $clause);
|
return $db->insert('profile', $clause);
|
||||||
}
|
}
|
||||||
static function enum($clause, $clause2=null) {
|
static function enum($clause=null, $clause2=null) {
|
||||||
$db = BoincDb::get();
|
$db = BoincDb::get();
|
||||||
return $db->enum('profile', 'BoincProfile', $clause, $clause2);
|
return $db->enum('profile', 'BoincProfile', $clause, $clause2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
// This file is part of BOINC.
|
||||||
|
// http://boinc.berkeley.edu
|
||||||
|
// Copyright (C) 2014 University of California
|
||||||
|
//
|
||||||
|
// BOINC is free software; you can redistribute it and/or modify it
|
||||||
|
// under the terms of the GNU Lesser General Public License
|
||||||
|
// as published by the Free Software Foundation,
|
||||||
|
// either version 3 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// BOINC 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 Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public License
|
||||||
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// script to delete spammer accounts and profiles.
|
||||||
|
//
|
||||||
|
// delete_spammers.php --list filename
|
||||||
|
// "filename" contains a list of user IDs, one per line.
|
||||||
|
//
|
||||||
|
// delete_spammers.php --auto
|
||||||
|
// delete accounts that
|
||||||
|
// - have no hosts
|
||||||
|
// - have no message-board posts
|
||||||
|
// - have a profile containing a link.
|
||||||
|
// NOTE: use this with caution. See delete_auto() below.
|
||||||
|
// Run it in test mode first.
|
||||||
|
|
||||||
|
require_once("../inc/db.inc");
|
||||||
|
db_init();
|
||||||
|
|
||||||
|
function del($id) {
|
||||||
|
echo "deleting user $id\n";
|
||||||
|
$q = "delete from profile where userid=$id";
|
||||||
|
mysql_query($q);
|
||||||
|
$q = "delete from user where id=$id";
|
||||||
|
mysql_query($q);
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_list($fname) {
|
||||||
|
$f = fopen($fname, "r");
|
||||||
|
if (!$f) die("no such file $fname\n");
|
||||||
|
while ($s = fgets($f)) {
|
||||||
|
$s = trim($s);
|
||||||
|
if (!is_numeric($s)) die("bad ID $s\n");
|
||||||
|
del($s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function has_link($x) {
|
||||||
|
if (strstr($x, "[url")) return true;
|
||||||
|
if (strstr($x, "http://")) return true;
|
||||||
|
if (strstr($x, "https://")) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_auto() {
|
||||||
|
$profiles = BoincProfile::enum("");
|
||||||
|
foreach ($profiles as $p) {
|
||||||
|
if (has_link($p->response1) || has_link($p->response2)) {
|
||||||
|
$user = BoincUser::lookup_id($p->userid);
|
||||||
|
if (!$user) {
|
||||||
|
echo "profile has missing user: %p->userid\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// uncomment the following to delete only recent accounts
|
||||||
|
//
|
||||||
|
//if ($user->create_time < time() - 60*86400) continue;
|
||||||
|
|
||||||
|
$n = BoincHost::count("userid=$p->userid");
|
||||||
|
if ($n) continue;
|
||||||
|
$n = BoincPost::count("user=$p->userid");
|
||||||
|
if ($n) continue;
|
||||||
|
|
||||||
|
// By default, show profile but don't delete anything
|
||||||
|
// Change 0 to 1 if you want to actually delete
|
||||||
|
//
|
||||||
|
if (0) {
|
||||||
|
del($user->id);
|
||||||
|
} else {
|
||||||
|
echo "------------\n$p->userid\n$p->response1\n$p->response2\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($i=1; $i<$argc; $i++) {
|
||||||
|
if ($argv[$i] == "--list") {
|
||||||
|
delete_list($argv[++$i]);
|
||||||
|
} else if ($argv[$i] == "--auto") {
|
||||||
|
delete_auto();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -33,24 +33,33 @@ admin_page_head($title);
|
||||||
echo "<ul>\n";
|
echo "<ul>\n";
|
||||||
|
|
||||||
if (!file_exists(".htaccess")) {
|
if (!file_exists(".htaccess")) {
|
||||||
echo "<li><span style=\"color: #ff0000\">The Project Management directory is not
|
echo "<li><span style=\"color: #ff0000\">
|
||||||
protected from public access by a .htaccess file.</span></li>\n";
|
The Project Management directory is not
|
||||||
|
protected from public access by a .htaccess file.
|
||||||
|
</span></li>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined("SYS_ADMIN_EMAIL")) {
|
if (!defined("SYS_ADMIN_EMAIL")) {
|
||||||
echo "<li><span style=\"color: #ff0000\">The defined constant SYS_ADMIN_EMAIL
|
echo "<li><span style=\"color: #ff0000\">
|
||||||
|
The defined constant SYS_ADMIN_EMAIL
|
||||||
has not been set. Please edit <tt>project/project.inc</tt> and set this
|
has not been set. Please edit <tt>project/project.inc</tt> and set this
|
||||||
to an address which can be used to contact the project administrators.
|
to an address which can be used to contact the project administrators.
|
||||||
</span></li>\n";
|
</span></li>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parse_bool($config, "disable_account_creation")) {
|
if (parse_bool($config, "disable_account_creation")) {
|
||||||
echo "<li><span style=\"color: #ff9900\">Account creation is disabled.</span></li>\n";
|
echo "<li><span style=\"color: #ff9900\">
|
||||||
|
Account creation is disabled.</span></li>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined("INVITE_CODES")) {
|
if (defined("INVITE_CODES")) {
|
||||||
echo "<li><span style=\"color: #ff9900\">Account creation is restricted by the use of
|
echo "<li><span style=\"color: #ff9900\">
|
||||||
invitation codes.</span></li>\n";
|
Account creation is restricted by the use of
|
||||||
|
invitation codes.</span></li>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
$uotd_candidates = count_uotd_candidates();
|
$uotd_candidates = count_uotd_candidates();
|
||||||
|
@ -62,8 +71,10 @@ if ($uotd_candidates >= 0) {
|
||||||
} else {
|
} else {
|
||||||
$color = "#ff9900";
|
$color = "#ff9900";
|
||||||
}
|
}
|
||||||
echo "<li><span style=\"color: ".$color."\">There are ".$uotd_candidates." remaining
|
echo "<li><span style=\"color: ".$color."\">
|
||||||
candidates for User of the Day.</span></li>\n";
|
There are ".$uotd_candidates." remaining candidates for User of the Day.
|
||||||
|
</span></li>
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</ul>\n";
|
echo "</ul>\n";
|
||||||
|
|
Loading…
Reference in New Issue