streams/Zotlabs/Module/Removeme.php

77 lines
1.6 KiB
PHP
Raw Normal View History

2016-04-19 03:38:38 +00:00
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
2016-04-19 03:38:38 +00:00
class Removeme extends Controller {
2016-04-19 03:38:38 +00:00
function post() {
if (! local_channel()) {
2016-04-19 03:38:38 +00:00
return;
}
2016-04-19 03:38:38 +00:00
if ($_SESSION['delegate']) {
2016-04-19 03:38:38 +00:00
return;
}
2016-04-19 03:38:38 +00:00
if ((! x($_POST,'qxz_password')) || (! strlen(trim($_POST['qxz_password'])))) {
2016-04-19 03:38:38 +00:00
return;
}
2016-04-19 03:38:38 +00:00
if ((! x($_POST,'verify')) || (! strlen(trim($_POST['verify'])))) {
2016-04-19 03:38:38 +00:00
return;
}
2016-04-19 03:38:38 +00:00
if ($_POST['verify'] !== $_SESSION['remove_channel_verify']) {
2016-04-19 03:38:38 +00:00
return;
}
$account = App::get_account();
if (! $account) {
return;
}
$x = account_verify_password($account['account_email'],$_POST['qxz_password']);
if (! ($x && $x['account'])) {
2016-04-19 03:38:38 +00:00
return;
}
2016-04-19 03:38:38 +00:00
if ($account['account_password_changed'] > NULL_DATE) {
2016-04-19 03:38:38 +00:00
$d1 = datetime_convert('UTC','UTC','now - 48 hours');
if($account['account_password_changed'] > d1) {
notice( t('Channel removals are not allowed within 48 hours of changing the account password.') . EOL);
return;
}
}
channel_remove(local_channel(),true,true);
2016-04-19 03:38:38 +00:00
}
function get() {
2016-04-19 03:38:38 +00:00
if (! local_channel()) {
2016-04-19 03:38:38 +00:00
goaway(z_root());
}
2016-04-19 03:38:38 +00:00
$hash = random_string();
$_SESSION['remove_channel_verify'] = $hash;
2016-04-19 03:38:38 +00:00
$o .= replace_macros(get_markup_template('removeme.tpl'), [
2016-04-19 03:38:38 +00:00
'$basedir' => z_root(),
2018-05-15 05:10:21 +00:00
'$hash' => $hash,
'$title' => t('Remove This Channel'),
'$desc' => [ t('WARNING: '), t('This channel will be completely removed from this server. '), t('This action is permanent and can not be undone!') ],
2018-05-15 05:10:21 +00:00
'$passwd' => t('Please enter your password for verification:'),
'$submit' => t('Remove Channel')
]);
2016-04-19 03:38:38 +00:00
return $o;
}
}