3 * @file mod/removeme.php
7 use Friendica\Core\Config;
8 use Friendica\Core\L10n;
9 use Friendica\Core\Renderer;
10 use Friendica\Core\System;
11 use Friendica\Database\DBA;
12 use Friendica\Model\User;
13 use Friendica\Util\Strings;
15 require_once 'include/enotify.php';
17 function removeme_post(App $a)
23 if (x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
27 if ((!x($_POST, 'qxz_password')) || (!strlen(trim($_POST['qxz_password'])))) {
31 if ((!x($_POST, 'verify')) || (!strlen(trim($_POST['verify'])))) {
35 if ($_POST['verify'] !== $_SESSION['remove_account_verify']) {
39 // send notification to admins so that they can clean um the backups
40 // send email to admins
41 $admin_mails = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
42 foreach ($admin_mails as $mail) {
43 $admin = DBA::selectFirst('user', ['uid', 'language', 'email', 'username'], ['email' => $mail]);
44 if (!DBA::isResult($admin)) {
48 'type' => SYSTEM_EMAIL,
49 'subject' => L10n::t('[Friendica System Notify]') . ' ' . L10n::t('User deleted their account'),
50 'preamble' => L10n::t('On your Friendica node an user deleted their account. Please ensure that their data is removed from the backups.'),
51 'body' => L10n::t('The user id is %d', local_user()),
52 'to_email' => $admin['email'],
53 'to_name' => $admin['username'],
54 'uid' => $admin['uid'],
55 'language' => $admin['language'] ? $admin['language'] : 'en',
56 'show_in_notification_page' => false
60 if (User::authenticate($a->user, trim($_POST['qxz_password']))) {
61 User::remove($a->user['uid']);
66 function removeme_content(App $a)
69 $a->internalRedirect();
72 $hash = Strings::getRandomHex();
74 require_once("mod/settings.php");
77 $_SESSION['remove_account_verify'] = $hash;
79 $tpl = Renderer::getMarkupTemplate('removeme.tpl');
80 $o = Renderer::replaceMacros($tpl, [
81 '$basedir' => $a->getBaseURL(),
83 '$title' => L10n::t('Remove My Account'),
84 '$desc' => L10n::t('This will completely remove your account. Once this has been done it is not recoverable.'),
85 '$passwd' => L10n::t('Please enter your password for verification:'),
86 '$submit' => L10n::t('Remove My Account')