]> git.mxchange.org Git - friendica.git/blob - mod/removeme.php
0363bf9f32990ad900d182c2c14bd5719b22eaf9
[friendica.git] / mod / removeme.php
1 <?php
2 /**
3  * @file mod/removeme.php
4  */
5 use Friendica\App;
6 use Friendica\Core\L10n;
7 use Friendica\Core\System;
8 use Friendica\Model\User;
9
10 function removeme_post(App $a)
11 {
12         if (!local_user()) {
13                 return;
14         }
15
16         if (x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
17                 return;
18         }
19
20         if ((!x($_POST, 'qxz_password')) || (!strlen(trim($_POST['qxz_password'])))) {
21                 return;
22         }
23
24         if ((!x($_POST, 'verify')) || (!strlen(trim($_POST['verify'])))) {
25                 return;
26         }
27
28         if ($_POST['verify'] !== $_SESSION['remove_account_verify']) {
29                 return;
30         }
31
32         if (User::authenticate($a->user, trim($_POST['qxz_password']))) {
33                 User::remove($a->user['uid']);
34                 // NOTREACHED
35         }
36 }
37
38 function removeme_content(App $a)
39 {
40         if (!local_user()) {
41                 goaway(System::baseUrl());
42         }
43
44         $hash = random_string();
45
46         require_once("mod/settings.php");
47         settings_init($a);
48
49         $_SESSION['remove_account_verify'] = $hash;
50
51         $tpl = get_markup_template('removeme.tpl');
52         $o = replace_macros($tpl, [
53                 '$basedir' => System::baseUrl(),
54                 '$hash' => $hash,
55                 '$title' => L10n::t('Remove My Account'),
56                 '$desc' => L10n::t('This will completely remove your account. Once this has been done it is not recoverable.'),
57                 '$passwd' => L10n::t('Please enter your password for verification:'),
58                 '$submit' => L10n::t('Remove My Account')
59         ]);
60
61         return $o;
62 }