3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 use Friendica\Core\Renderer;
24 use Friendica\Database\DBA;
26 use Friendica\Model\User;
27 use Friendica\Util\Strings;
29 function removeme_post(App $a)
35 if (!empty($_SESSION['submanage'])) {
39 if (empty($_POST['qxz_password'])) {
43 if (empty($_POST['verify'])) {
47 if ($_POST['verify'] !== $_SESSION['remove_account_verify']) {
51 // send notification to admins so that they can clean um the backups
52 // send email to admins
53 $admin_mails = explode(",", str_replace(" ", "", DI::config()->get('config', 'admin_email')));
54 foreach ($admin_mails as $mail) {
55 $admin = DBA::selectFirst('user', ['uid', 'language', 'email', 'username'], ['email' => $mail]);
56 if (!DBA::isResult($admin)) {
60 $email = DI::emailer()
63 DI::l10n()->t('[Friendica System Notify]') . ' ' . DI::l10n()->t('User deleted their account'),
64 DI::l10n()->t('On your Friendica node an user deleted their account. Please ensure that their data is removed from the backups.'),
65 DI::l10n()->t('The user id is %d', local_user()))
67 ->withRecipient($admin['email'])
69 DI::emailer()->send($email);
72 if (User::getIdFromPasswordAuthentication($a->getLoggedInUserId(), trim($_POST['qxz_password']))) {
73 User::remove($a->getLoggedInUserId());
75 unset($_SESSION['authenticated']);
76 unset($_SESSION['uid']);
77 DI::baseUrl()->redirect();
82 function removeme_content(App $a)
85 DI::baseUrl()->redirect();
88 $hash = Strings::getRandomHex();
90 require_once("mod/settings.php");
93 $_SESSION['remove_account_verify'] = $hash;
95 $tpl = Renderer::getMarkupTemplate('removeme.tpl');
96 $o = Renderer::replaceMacros($tpl, [
97 '$basedir' => DI::baseUrl()->get(),
99 '$title' => DI::l10n()->t('Remove My Account'),
100 '$desc' => DI::l10n()->t('This will completely remove your account. Once this has been done it is not recoverable.'),
101 '$passwd' => DI::l10n()->t('Please enter your password for verification:'),
102 '$submit' => DI::l10n()->t('Remove My Account')