Browse Source

remove self

pull/1/head
Friendika 10 years ago
parent
commit
a4cbdc2414
7 changed files with 79 additions and 5 deletions
  1. +5
    -1
      include/Contact.php
  2. +50
    -0
      mod/removeme.php
  3. +1
    -1
      view/de/settings.tpl
  4. +1
    -1
      view/en/settings.tpl
  5. +1
    -1
      view/fr/settings.tpl
  6. +1
    -1
      view/it/settings.tpl
  7. +20
    -0
      view/removeme.tpl

+ 5
- 1
include/Contact.php View File

@ -6,6 +6,10 @@
// authorisation to do this.
function user_remove($uid) {
if(! $uid)
return;
$a = get_app();
logger('Removing user: ' . $uid);
q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `group` WHERE `uid` = %d", intval($uid));
q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid));
@ -19,7 +23,7 @@ function user_remove($uid) {
if($uid == local_user()) {
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
killme();
goaway($a->get_baseurl());
}
}


+ 50
- 0
mod/removeme.php View File

@ -0,0 +1,50 @@
<?php
function removeme_post(&$a) {
if(! local_user())
return;
if((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password']))))
return;
if((! x($_POST,'verify')) || (! strlen(trim($_POST['verify']))))
return;
if($_POST['verify'] !== $_SESSION['remove_account_verify'])
return;
$encrypted = hash('whirlpool',trim($_POST['qxz_password']));
if((strlen($a->user['password'])) && ($encrypted === $a->user['password'])) {
require_once('include/Contact.php');
user_remove($a->user['uid']);
// NOTREACHED
}
}
function removeme_content(&$a) {
if(! local_user())
goaway($a->get_baseurl());
$hash = random_string();
$_SESSION['remove_account_verify'] = $hash;
$tpl = load_view_file('view/removeme.tpl');
$o .= replace_macros($tpl, array(
'$basedir' => $a->get_baseurl(),
'$hash' => $hash,
'$title' => t('Remove My Account'),
'$desc' => t('This will completely remove your account. Once this has been done it is not recoverable.'),
'$passwd' => t('Please enter your password for verification:'),
'$submit' => t('Remove My Account')
));
return $o;
}

+ 1
- 1
view/de/settings.tpl View File

@ -5,7 +5,7 @@
$nickname_block
<form action="settings" id="settings-form" method="post" autocomplete="false" >
<form action="settings" id="settings-form" method="post" autocomplete="off" >
<h3 class="settings-heading">Grundeinstellungen</h3>


+ 1
- 1
view/en/settings.tpl View File

@ -5,7 +5,7 @@
$nickname_block
<form action="settings" id="settings-form" method="post" autocomplete="false" >
<form action="settings" id="settings-form" method="post" autocomplete="off" >
<h3 class="settings-heading">Basic Settings</h3>


+ 1
- 1
view/fr/settings.tpl View File

@ -5,7 +5,7 @@
$nickname_block
<form action="settings" id="settings-form" method="post" autocomplete="false" >
<form action="settings" id="settings-form" method="post" autocomplete="off" >
<h3 class="settings-heading">Basic Settings</h3>


+ 1
- 1
view/it/settings.tpl View File

@ -6,7 +6,7 @@
$nickname_block
<form action="settings" id="settings-form" method="post" autocomplete="false" >
<form action="settings" id="settings-form" method="post" autocomplete="off" >
<h3 class="settings-heading">Impostazioni base</h3>


+ 20
- 0
view/removeme.tpl View File

@ -0,0 +1,20 @@
<h1>$title</h1>
<div id="remove-account-wrapper">
<div id="remove-account-desc">$desc</div>
<form action="$basedir/removeme" autocomplete="off" method="post" >
<input type="hidden" name="verify" value="$hash" />
<div id="remove-account-pass-wrapper">
<label id="remove-account-pass-label" for="remove-account-pass">$passwd</label>
<input type="password" id="remove-account-pass" name="qxz_password" />
</div>
<div id="remove-account-pass-end"></div>
<input type="submit" name="submit" value="$submit" />
</form>
</div>

Loading…
Cancel
Save