2009-10-03 04:42:58 +09:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* StatusNet - a distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2008, 2009, StatusNet, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-07-15 12:10:29 +09:00
|
|
|
define('INSTALLDIR', dirname(__DIR__));
|
|
|
|
define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
|
2009-10-03 04:42:58 +09:00
|
|
|
|
2015-04-22 06:47:55 +09:00
|
|
|
$shortoptions = 'i::n::u::y';
|
|
|
|
$longoptions = array('id=', 'nickname=', 'uri=', 'yes');
|
2009-10-03 04:42:58 +09:00
|
|
|
|
|
|
|
$helptext = <<<END_OF_DELETEUSER_HELP
|
2015-04-22 06:47:55 +09:00
|
|
|
deleteprofile.php [options]
|
|
|
|
deletes a profile from the database
|
2009-10-03 04:42:58 +09:00
|
|
|
|
2015-04-22 06:47:55 +09:00
|
|
|
-i --id ID of the profile
|
|
|
|
-n --nickname nickname of a local user
|
|
|
|
-u --uri OStatus profile URI (only remote users, requires OStatus plugin)
|
2009-10-03 04:42:58 +09:00
|
|
|
-y --yes do not wait for confirmation
|
|
|
|
|
|
|
|
END_OF_DELETEUSER_HELP;
|
|
|
|
|
|
|
|
require_once INSTALLDIR.'/scripts/commandline.inc';
|
|
|
|
|
|
|
|
if (have_option('i', 'id')) {
|
|
|
|
$id = get_option_value('i', 'id');
|
2015-04-22 06:47:55 +09:00
|
|
|
$profile = Profile::getKV('id', $id);
|
|
|
|
if (!$profile instanceof Profile) {
|
|
|
|
print "Can't find profile with ID $id\n";
|
2009-10-03 04:42:58 +09:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
} else if (have_option('n', 'nickname')) {
|
|
|
|
$nickname = get_option_value('n', 'nickname');
|
2013-08-18 20:04:58 +09:00
|
|
|
$user = User::getKV('nickname', $nickname);
|
2015-04-22 06:47:55 +09:00
|
|
|
if (!$user instanceof User) {
|
2009-10-03 04:42:58 +09:00
|
|
|
print "Can't find user with nickname '$nickname'\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
2015-04-22 06:47:55 +09:00
|
|
|
$profile = $user->getProfile();
|
|
|
|
} else if (have_option('u', 'uri')) {
|
|
|
|
$uri = get_option_value('u', 'uri');
|
|
|
|
$oprofile = Ostatus_profile::getKV('uri', $uri);
|
|
|
|
if (!$oprofile instanceof Ostatus_profile) {
|
|
|
|
print "Can't find profile with URI '$uri'\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
$profile = $oprofile->localProfile();
|
2009-10-03 04:42:58 +09:00
|
|
|
} else {
|
2015-04-22 06:47:55 +09:00
|
|
|
print "You must provide either an ID, a URI or a nickname.\n";
|
2009-10-03 04:42:58 +09:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!have_option('y', 'yes')) {
|
2015-04-22 06:47:55 +09:00
|
|
|
print "About to PERMANENTLY delete profile '".$profile->getNickname()."' ({$profile->id}). Are you sure? [y/N] ";
|
2009-10-03 04:42:58 +09:00
|
|
|
$response = fgets(STDIN);
|
2009-10-03 04:46:00 +09:00
|
|
|
if (strtolower(trim($response)) != 'y') {
|
2009-10-03 04:42:58 +09:00
|
|
|
print "Aborting.\n";
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print "Deleting...";
|
2015-04-22 06:47:55 +09:00
|
|
|
$profile->delete();
|
2009-10-03 04:42:58 +09:00
|
|
|
print "DONE.\n";
|