2022-12-08 22:35:45 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$_ = function() {
|
|
|
|
$id = trim($_GET['id']);
|
|
|
|
if (!valid_mastodon_account_id($id))
|
|
|
|
return apiresult(['error' => 'id parameter has incorrect format'], 400);
|
|
|
|
|
2022-12-13 12:15:19 +00:00
|
|
|
instance_config();
|
|
|
|
|
2022-12-08 23:36:06 +00:00
|
|
|
$explain = 'Your account has been suspended';
|
|
|
|
if (isset($_POST['explain']))
|
|
|
|
$explain = trim($_POST['explain']);
|
|
|
|
|
2022-12-12 19:59:10 +00:00
|
|
|
$is_remote_account = false;
|
|
|
|
$pg = new PgDatabase();
|
|
|
|
if ($pg->is_ok()) {
|
|
|
|
$result = $pg->fetch('SELECT domain FROM accounts WHERE id = '.$id);
|
|
|
|
$is_remote_account = isset($result['domain']) && $result['domain'] !== null;
|
|
|
|
}
|
|
|
|
|
2022-12-09 21:38:27 +00:00
|
|
|
$output = instance_http_post('/api/v1/admin/accounts/'.$id.'/action',
|
2022-12-08 23:36:06 +00:00
|
|
|
['type' => 'suspend', 'text' => $explain ]);
|
2022-12-12 19:59:10 +00:00
|
|
|
if ($is_remote_account)
|
|
|
|
instance_http_delete('/api/v1/admin/accounts/'.$id);
|
|
|
|
|
2022-12-13 12:15:19 +00:00
|
|
|
$suspended = [];
|
|
|
|
$susp_file = 'suspended_accounts,'.$GLOBALS['ap_software'].','.$GLOBALS['ap_instance'];
|
|
|
|
if (filedb_exists('cache', $susp_file))
|
|
|
|
$suspended = unserialize(filedb_get('cache', $susp_file));
|
|
|
|
$suspended []= $id;
|
|
|
|
$suspended = array_unique($suspended);
|
|
|
|
filedb_put('cache', $susp_file, serialize($suspended));
|
|
|
|
|
2022-12-12 19:59:10 +00:00
|
|
|
if (!isset($_SERVER['REQUEST_URI']))
|
|
|
|
sleep(3);
|
2022-12-13 12:15:19 +00:00
|
|
|
|
2022-12-08 22:35:45 +00:00
|
|
|
return apiresult($output);
|
|
|
|
};
|
|
|
|
$_();
|