Example #1
0
        }
        if (!empty($error_message)) {
            Viewer::AddData("error_message", $error_message);
        }
        Viewer::AddData("title", I18n::L("Password recovery"));
        Viewer::UseTemplate("password_recovery.tpl");
        $action = "password_recovery";
    }
} elseif ((!RESTRICT_ALL || User::Logged()) && !isset($_GET["recover"])) {
    $id = (int) $_SERVER["QUERY_STRING"];
    $user = User::GetById($id);
    if (!empty($id) && $user) {
        //remove user
        if (isset($_GET["removeuser"])) {
            if (User::$current->IsAdmin() && !empty($user->user_email)) {
                $user->user_password = User::GeneratePassword(8);
                $user->user_email = "";
                $user->user_name = $user->user_name . "_removed";
                if (!User::Update($user)) {
                    $error_message = I18n::L("Cannot update user.");
                    $user = User::GetById($id);
                } else {
                    header("Location:" . PREFIX . "/profile?" . $user->user_id);
                    exit;
                }
            } else {
                header("Location:" . PREFIX . "/profile?" . $user->user_id);
                exit;
            }
        }
        Viewer::AddData("user", $user);