function post()
 {
     if (!local_channel()) {
         return;
     }
     if ($_SESSION['delegate']) {
         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;
     }
     $account = \App::get_account();
     $account_id = get_account_id();
     if (!account_verify_password($account['account_email'], $_POST['qxz_password'])) {
         return;
     }
     if ($account['account_password_changed'] != NULL_DATE) {
         $d1 = datetime_convert('UTC', 'UTC', 'now - 48 hours');
         if ($account['account_password_changed'] > d1) {
             notice(t('Account removals are not allowed within 48 hours of changing the account password.') . EOL);
             return;
         }
     }
     $global_remove = intval($_POST['global']);
     account_remove($account_id, 1 - $global_remove);
 }
Example #2
0
function removeaccount_post(&$a)
{
    if (!local_user()) {
        return;
    }
    if (x($_SESSION, 'submanage') && intval($_SESSION['submanage'])) {
        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;
    }
    $account = $a->get_account();
    $account_id = get_account_id();
    if (!account_verify_password($account['account_email'], $_POST['qxz_password'])) {
        return;
    }
    if ($account['account_password_changed'] != NULL_DATE) {
        $d1 = datetime_convert('UTC', 'UTC', 'now - 48 hours');
        if ($account['account_password_changed'] > d1) {
            notice(t('Account removals are not allowed within 48 hours of changing the account password.') . EOL);
            return;
        }
    }
    require_once 'include/Contact.php';
    $global_remove = intval($_POST['global']);
    account_remove($account_id, true);
}
Example #3
0
function testdrive_cron($a, $b)
{
    $r = q("select * from account where account_expires_on < %s + INTERVAL %s and\n\t\taccount_expire_notified = '%s' ", db_utcnow(), db_quoteinterval('5 DAY'), dbesc(NULL_DATE));
    if ($r) {
        foreach ($r as $rr) {
            $uid = $rr['account_default_channel'];
            if (!$uid) {
                continue;
            }
            $x = q("select * from channel where channel_id = %d limit 1", intval($uid));
            if (!$x) {
                continue;
            }
            \Zotlabs\Lib\Enotify::submit(array('type' => NOTIFY_SYSTEM, 'system_type' => 'testdrive_expire', 'from_xchan' => $x[0]['channel_hash'], 'to_xchan' => $x[0]['channel_hash']));
            q("update account set account_expire_notified = '%s' where account_id = %d", dbesc(datetime_convert()), intval($rr['account_id']));
        }
    }
    // give them a 5 day grace period. Then nuke the account.
    $r = q("select * from account where account_expired = 1 and account_expires < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('5 DAY'));
    if ($r) {
        foreach ($r as $rr) {
            account_remove($rr['account_id']);
        }
    }
}
Example #4
0
 /**
  * @brief Generate users admin page and handle single item operations.
  *
  * This function generates the users/account admin page and handles the actions
  * if an icon next to an entry was clicked. If several items were selected and
  * the form was submitted it is handled by the function admin_page_users_post().
  *
  * @param App &$a
  * @return string
  */
 function admin_page_users(&$a)
 {
     if (argc() > 2) {
         $uid = argv(3);
         $account = q("SELECT * FROM account WHERE account_id = %d", intval($uid));
         if (!$account) {
             notice(t('Account not found') . EOL);
             goaway(z_root() . '/admin/users');
         }
         check_form_security_token_redirectOnErr('/admin/users', 'admin_users', 't');
         switch (argv(2)) {
             case 'delete':
                 // delete user
                 require_once 'include/Contact.php';
                 account_remove($uid, true, false);
                 notice(sprintf(t("Account '%s' deleted"), $account[0]['account_email']) . EOL);
                 break;
             case 'block':
                 q("UPDATE account SET account_flags = ( account_flags | %d ) WHERE account_id = %d", intval(ACCOUNT_BLOCKED), intval($uid));
                 notice(sprintf(t("Account '%s' blocked"), $account[0]['account_email']) . EOL);
                 break;
             case 'unblock':
                 q("UPDATE account SET account_flags = ( account_flags & ~%d ) WHERE account_id = %d", intval(ACCOUNT_BLOCKED), intval($uid));
                 notice(sprintf(t("Account '%s' unblocked"), $account[0]['account_email']) . EOL);
                 break;
         }
         goaway(z_root() . '/admin/users');
     }
     /* get pending */
     $pending = q("SELECT account.*, register.hash from account left join register on account_id = register.uid where (account_flags & %d )>0 ", intval(ACCOUNT_PENDING));
     /* get users */
     $total = q("SELECT count(*) as total FROM account");
     if (count($total)) {
         \App::set_pager_total($total[0]['total']);
         \App::set_pager_itemspage(100);
     }
     //	We'll still need to link email addresses to admin/users/channels or some such, but this bit doesn't exist yet.
     //	That's where we need to be doing last post/channel flags/etc, not here.
     $serviceclass = $_REQUEST['class'] ? " and account_service_class = '" . dbesc($_REQUEST['class']) . "' " : '';
     $order = " order by account_email asc ";
     if ($_REQUEST['order'] === 'expires') {
         $order = " order by account_expires desc ";
     }
     if ($_REQUEST['order'] === 'created') {
         $order = " order by account_created desc ";
     }
     $users = q("SELECT `account_id` , `account_email`, `account_lastlog`, `account_created`, `account_expires`, " . "`account_service_class`, ( account_flags & %d )>0 as `blocked`, " . "(SELECT %s FROM channel as ch " . "WHERE ch.channel_account_id = ac.account_id and ch.channel_removed = 0 ) as `channels` " . "FROM account as ac where true {$serviceclass} {$order} limit %d offset %d ", intval(ACCOUNT_BLOCKED), db_concat('ch.channel_address', ' '), intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
     //	function _setup_users($e){
     //		$accounts = Array(
     //			t('Normal Account'),
     //			t('Soapbox Account'),
     //			t('Community/Celebrity Account'),
     //			t('Automatic Friend Account')
     //		);
     //		$e['page_flags'] = $accounts[$e['page-flags']];
     //		$e['register_date'] = relative_date($e['register_date']);
     //		$e['login_date'] = relative_date($e['login_date']);
     //		$e['lastitem_date'] = relative_date($e['lastitem_date']);
     //		return $e;
     //	}
     //	$users = array_map("_setup_users", $users);
     $t = get_markup_template('admin_users.tpl');
     $o = replace_macros($t, array('$title' => t('Administration'), '$page' => t('Users'), '$submit' => t('Submit'), '$select_all' => t('select all'), '$h_pending' => t('User registrations waiting for confirm'), '$th_pending' => array(t('Request date'), t('Email')), '$no_pending' => t('No registrations.'), '$approve' => t('Approve'), '$deny' => t('Deny'), '$delete' => t('Delete'), '$block' => t('Block'), '$unblock' => t('Unblock'), '$h_users' => t('Users'), '$th_users' => array(t('ID'), t('Email'), t('All Channels'), t('Register date'), t('Last login'), t('Expires'), t('Service Class')), '$confirm_delete_multi' => t('Selected accounts will be deleted!\\n\\nEverything these accounts had posted on this site will be permanently deleted!\\n\\nAre you sure?'), '$confirm_delete' => t('The account {0} will be deleted!\\n\\nEverything this account has posted on this site will be permanently deleted!\\n\\nAre you sure?'), '$form_security_token' => get_form_security_token("admin_users"), '$baseurl' => z_root(), '$pending' => $pending, '$users' => $users));
     $o .= paginate($a);
     return $o;
 }