generateSecretKey(); $g2faUrl = $google2fa->getQRCodeUrl( 'KontrolVM', $_SESSION["username"], $mfasecret ); $writer = new Writer(new GDLibRenderer(250)); $qrcode_image = base64_encode($writer->writeString($g2faUrl)); if($_SERVER["REQUEST_METHOD"] == "POST") { $token = $_POST["csrf_token"]; if(validateCSRFToken($token)) { if(isset($_POST['save_account'])) { $username = $_POST['username']; $email = $_POST['email']; if($chkRole == '2') { $role = '2'; } else { $role = $_POST['role']; } if($role == '9' AND $chkRole != '9') { header("Location: home.php?s=99"); exit; } if($staff_id == '1') { $status = '1'; } else { if(isset($_POST["status"])) { $status = '1'; } else { $status = '0'; } } if(isset($_POST["password-change"])) { $password1 = $_POST['new-password']; $password2 = $_POST['confirm-password']; } else { $password1 = NULL; $password2 = NULL; } $result = updateStaff($loggedin_id,$staff_id,$username,$email,$status,$role,$password1,$password2); if($result === true) { if($loggedin_id == $_POST["id"]) { $_SESSION["username"] = $username; } header("Location: account.php?id=". (int)$staff_id. "&s=1"); } else { $error = $result; } } if(isset($_POST["mfa-verify"]) AND isset($_POST["enable_mfa"])) { $mfacode = $_POST["mfa-verify"]; $mfasecret = $_POST["mfa_secret"]; $result = enableMFA($loggedin_id,$staff_id,$mfasecret,$mfacode); if($result === true) { header("Location: account.php?id=". (int)$staff_id. "&s=2"); } else { $error = "MFA failed to enable."; } } if(!isset($_POST["mfastate"]) AND isset($_POST["disable_mfa"])) { $result = disableMFA($loggedin_id,$staff_id); if($result === true) { header("Location: account.php?id=". (int)$staff_id. "&s=3"); } else { $error = "MFA failed to disable."; } } if(isset($_POST['delete_account'])) { if($_SESSION["staff_id"] == $_POST["id"]) { $error = "User delete failed: You can't deleted yourself."; } else { if(isset($_POST['confirm'])) { $confirm = $_POST['confirm']; $result = deleteUser($loggedin_id,$_POST["id"],$confirm); if($result === true) { header("Location: users.php?s=2"); } else { $error = $result; } } else { $error = "User delete failed: Please make sure you checked the confirmation box."; } } } } else { $error = "Invalid CSRF token."; } } if($staff) { if($staff_id == '1') { $state = " checked disabled"; } else { if($staff['staff_active'] == "1") { $state = " checked"; } else { $state = ""; } } $role = $staff['staff_role']; if($role == '9' AND $chkRole != '9') { header("Location: home.php?s=99"); exit; } ?>
DELETE ACCOUNT: |