public function deleteUser($uid, $password, $captcha_response = null)
    {
        $return['error'] = true;

        $block_status = $this->isBlocked();
        if ($block_status == "verify") {
            if ($this->checkCaptcha($captcha_response) == false) {
                $return['message'] = $this->__lang("user_verify_failed");

                return $return;
            }
        }

        if ($block_status == "block") {
            $return['message'] = $this->__lang("user_blocked");

            return $return;
        }

        $validatePassword = $this->validatePassword($password);

        if ($validatePassword['error'] == 1) {
            $this->addAttempt();
            $return['message'] = $validatePassword['message'];

            return $return;
        }

        $user = $this->getBaseUser($uid);

        if (!password_verify($password, $user['password'])) {
            $this->addAttempt();
            $return['message'] = $this->__lang("password_incorrect");

            return $return;
        }

        $query = "DELETE FROM {$this->config->table_users} WHERE id = :uid";
        $query_prepared = $this->dbh->prepare($query);

        if (!$query_prepared->execute(['uid' => $uid])) {
            $return['message'] = $this->__lang("system_error") . " #05";

            return $return;
        }

        $query = "DELETE FROM {$this->config->table_sessions} WHERE uid = :uid";
        $query_prepared = $this->dbh->prepare($query);

        if (!$query_prepared->execute(['uid' => $uid])) {
            $return['message'] = $this->__lang("system_error") . " #06";

            return $return;
        }

        $query = "DELETE FROM {$this->config->table_requests} WHERE uid = :uid";
        $query_prepared = $this->dbh->prepare($query);

        if (!$query_prepared->execute(['uid' => $uid])) {
            $return['message'] = $this->__lang("system_error") . " #07";

            return $return;
        }

        $return['error'] = false;
        $return['message'] = $this->__lang("account_deleted");

        return $return;
    }
public function deleteUser($uid, $password, $captcha_response = null)
    {
        $return['error'] = true;

        $block_status = $this->isBlocked();
        if ($block_status == "verify") {
            if ($this->checkCaptcha($captcha_response) == false) {
                $return['message'] = $this->__lang("user_verify_failed");

                return $return;
            }
        }

        if ($block_status == "block") {
            $return['message'] = $this->__lang("user_blocked");

            return $return;
        }

        $validatePassword = $this->validatePassword($password);

        if ($validatePassword['error'] == 1) {
            $this->addAttempt();
            $return['message'] = $validatePassword['message'];

            return $return;
        }

        $user = $this->getBaseUser($uid);

        if (!password_verify($password, $user['password'])) {
            $this->addAttempt();
            $return['message'] = $this->__lang("password_incorrect");

            return $return;
        }

        $query = "DELETE FROM {$this->config->table_users} WHERE id = :uid";
        $query_prepared = $this->dbh->prepare($query);

        if (!$query_prepared->execute(['uid' => $uid])) {
            $return['message'] = $this->__lang("system_error") . " #05";

            return $return;
        }

        $query = "DELETE FROM {$this->config->table_sessions} WHERE uid = :uid";
        $query_prepared = $this->dbh->prepare($query);

        if (!$query_prepared->execute(['uid' => $uid])) {
            $return['message'] = $this->__lang("system_error") . " #06";

            return $return;
        }

        $query = "DELETE FROM {$this->config->table_requests} WHERE uid = :uid";
        $query_prepared = $this->dbh->prepare($query);

        if (!$query_prepared->execute(['uid' => $uid])) {
            $return['message'] = $this->__lang("system_error") . " #07";

            return $return;
        }

        $return['error'] = false;
        $return['message'] = $this->__lang("account_deleted");

        return $return;
    }
public function deleteUser ( $ uid , $ password , $ captcha_response = null ) { $ return [ 'error' ] = true ; $ block_status = $ this -> isBlocked ( ) ; if ( $ block_status == "verify" ) { if ( $ this -> checkCaptcha ( $ captcha_response ) == false ) { $ return [ 'message' ] = $ this -> __lang ( "user_verify_failed" ) ; return $ return ; } } if ( $ block_status == "block" ) { $ return [ 'message' ] = $ this -> __lang ( "user_blocked" ) ; return $ return ; } $ validatePassword = $ this -> validatePassword ( $ password ) ; if ( $ validatePassword [ 'error' ] == 1 ) { $ this -> addAttempt ( ) ; $ return [ 'message' ] = $ validatePassword [ 'message' ] ; return $ return ; } $ user = $ this -> getBaseUser ( $ uid ) ; if ( ! password_verify ( $ password , $ user [ 'password' ] ) ) { $ this -> addAttempt ( ) ; $ return [ 'message' ] = $ this -> __lang ( "password_incorrect" ) ; return $ return ; } $ query = "DELETE FROM {$this->config->table_users} WHERE id = :uid" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; if ( ! $ query_prepared -> execute ( [ 'uid' => $ uid ] ) ) { $ return [ 'message' ] = $ this -> __lang ( "system_error" ) . " #05" ; return $ return ; } $ query = "DELETE FROM {$this->config->table_sessions} WHERE uid = :uid" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; if ( ! $ query_prepared -> execute ( [ 'uid' => $ uid ] ) ) { $ return [ 'message' ] = $ this -> __lang ( "system_error" ) . " #06" ; return $ return ; } $ query = "DELETE FROM {$this->config->table_requests} WHERE uid = :uid" ; $ query_prepared = $ this -> dbh -> prepare ( $ query ) ; if ( ! $ query_prepared -> execute ( [ 'uid' => $ uid ] ) ) { $ return [ 'message' ] = $ this -> __lang ( "system_error" ) . " #07" ; return $ return ; } $ return [ 'error' ] = false ; $ return [ 'message' ] = $ this -> __lang ( "account_deleted" ) ; return $ return ; }
Allows a user to delete their account
@param int $uid
@param string $password
@param string $captcha_response = null
@return array $return
Allows a user to delete their account