93 lines
7.0 KiB
PHP
93 lines
7.0 KiB
PHP
<div class="dbm-content-header">
|
|
<div class="dbm-breadcrumb">
|
|
<a href="<?php echo Config::get('URL'); ?>dbuser/index">Users</a>
|
|
<span class="separator">/</span>
|
|
<span><?php echo htmlspecialchars($this->user->User); ?>@<?php echo htmlspecialchars($this->user->Host); ?></span>
|
|
</div>
|
|
<div class="dbm-title">
|
|
<h1>Edit User</h1>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="dbm-content-body">
|
|
<form method="post" action="<?php echo Config::get('URL'); ?>dbuser/edit/<?php echo urlencode($this->user->User); ?>/<?php echo urlencode($this->user->Host); ?>">
|
|
<div class="dbm-card" style="margin-bottom: 20px;">
|
|
<div class="dbm-card-header">
|
|
<h3>User Details</h3>
|
|
</div>
|
|
<div class="dbm-card-body">
|
|
<div class="dbm-form-group">
|
|
<label class="dbm-form-label">Username</label>
|
|
<input type="text" class="dbm-form-input" value="<?php echo htmlspecialchars($this->user->User); ?>" disabled>
|
|
</div>
|
|
<div class="dbm-form-group">
|
|
<label class="dbm-form-label">Host</label>
|
|
<input type="text" class="dbm-form-input" value="<?php echo htmlspecialchars($this->user->Host); ?>" disabled>
|
|
</div>
|
|
<div class="dbm-form-group">
|
|
<label class="dbm-form-label">New Password</label>
|
|
<input type="password" name="password" class="dbm-form-input" placeholder="Leave empty to keep current password">
|
|
<small style="color: var(--dbm-text-muted); font-size: 11px; display: block; margin-top: 4px;">Only fill this if you want to change the password</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="dbm-card" style="margin-bottom: 20px;">
|
|
<div class="dbm-card-header">
|
|
<h3>Global Privileges</h3>
|
|
</div>
|
|
<div class="dbm-card-body">
|
|
<?php
|
|
$all_privileges = ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'ALTER', 'INDEX', 'REFERENCES', 'CREATE TEMPORARY TABLES', 'LOCK TABLES', 'EXECUTE', 'CREATE VIEW', 'SHOW VIEW', 'CREATE ROUTINE', 'ALTER ROUTINE', 'EVENT', 'TRIGGER'];
|
|
$current_grants = implode(' ', $this->privileges);
|
|
$has_all = stripos($current_grants, 'ALL PRIVILEGES') !== false;
|
|
?>
|
|
<div style="margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--dbm-border);">
|
|
<label style="display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--dbm-text);">
|
|
<input type="checkbox" name="privileges[]" value="ALL PRIVILEGES" id="all-privs-check"
|
|
<?php echo $has_all ? 'checked' : ''; ?>
|
|
onchange="document.querySelectorAll('.priv-checkbox').forEach(cb => { cb.checked = this.checked; cb.disabled = this.checked; })">
|
|
ALL PRIVILEGES (*)
|
|
</label>
|
|
<small style="color: var(--dbm-text-muted); font-size: 11px; margin-left: 22px;">Grant all privileges on all databases</small>
|
|
</div>
|
|
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px;">
|
|
<?php foreach ($all_privileges as $priv): ?>
|
|
<label style="display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; color: var(--dbm-text-secondary);">
|
|
<input type="checkbox" name="privileges[]" value="<?php echo $priv; ?>" class="priv-checkbox"
|
|
<?php echo ($has_all || stripos($current_grants, $priv) !== false) ? 'checked' : ''; ?>
|
|
<?php echo $has_all ? 'disabled' : ''; ?>>
|
|
<?php echo $priv; ?>
|
|
</label>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="dbm-card">
|
|
<div class="dbm-card-header">
|
|
<h3>Current Grants</h3>
|
|
</div>
|
|
<div class="dbm-card-body">
|
|
<?php if (!empty($this->privileges)): ?>
|
|
<?php foreach ($this->privileges as $grant): ?>
|
|
<div style="font-family: monospace; font-size: 11px; padding: 8px; background: var(--dbm-bg-secondary); border-radius: var(--dbm-radius); margin-bottom: 6px; word-break: break-all;">
|
|
<?php echo htmlspecialchars($grant); ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<p style="color: var(--dbm-text-muted); font-size: 12px; margin: 0;">No grants found</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div style="margin-top: 20px; display: flex; gap: 8px;">
|
|
<button type="submit" name="submit_edit_user" class="dbm-btn dbm-btn-success">
|
|
<i data-lucide="check"></i>
|
|
Save Changes
|
|
</button>
|
|
<a href="<?php echo Config::get('URL'); ?>dbuser/index" class="dbm-btn dbm-btn-secondary">Cancel</a>
|
|
</div>
|
|
</form>
|
|
</div>
|