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