Initial commit
This commit is contained in:
68
application/view/dbuser/create.php
Normal file
68
application/view/dbuser/create.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<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>Create User</span>
|
||||
</div>
|
||||
<div class="dbm-title">
|
||||
<h1>Create New User</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dbm-content-body">
|
||||
<div class="dbm-card">
|
||||
<div class="dbm-card-body">
|
||||
<form method="post" action="<?php echo Config::get('URL'); ?>dbuser/create">
|
||||
<div class="dbm-form-group">
|
||||
<label class="dbm-form-label">Username</label>
|
||||
<input type="text" name="username" class="dbm-form-input" required pattern="[a-zA-Z0-9_]+" placeholder="username">
|
||||
</div>
|
||||
<div class="dbm-form-group">
|
||||
<label class="dbm-form-label">Password</label>
|
||||
<input type="password" name="password" class="dbm-form-input" required placeholder="password">
|
||||
</div>
|
||||
<div class="dbm-form-group">
|
||||
<label class="dbm-form-label">Host</label>
|
||||
<select name="host" class="dbm-form-select">
|
||||
<option value="localhost">localhost</option>
|
||||
<option value="%">% (any host)</option>
|
||||
<option value="127.0.0.1">127.0.0.1</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="dbm-form-group">
|
||||
<label class="dbm-form-label">Privileges</label>
|
||||
<div style="margin-top: 8px; padding: 12px; background: var(--dbm-bg-secondary); border-radius: var(--dbm-radius);">
|
||||
<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"
|
||||
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
|
||||
$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'];
|
||||
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 $priv; ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 20px; display: flex; gap: 8px;">
|
||||
<button type="submit" name="submit_create_user" class="dbm-btn dbm-btn-success">
|
||||
<i data-lucide="plus"></i>
|
||||
Create User
|
||||
</button>
|
||||
<a href="<?php echo Config::get('URL'); ?>dbuser/index" class="dbm-btn dbm-btn-secondary">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
92
application/view/dbuser/edit.php
Normal file
92
application/view/dbuser/edit.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<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>
|
||||
101
application/view/dbuser/index.php
Normal file
101
application/view/dbuser/index.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<div class="dbm-content-header">
|
||||
<div class="dbm-breadcrumb">
|
||||
<span>Users</span>
|
||||
</div>
|
||||
<div class="dbm-title">
|
||||
<h1>MySQL Users</h1>
|
||||
<span class="badge"><?php echo count($this->users); ?> users</span>
|
||||
</div>
|
||||
<div class="dbm-actions">
|
||||
<button type="button" class="dbm-btn dbm-btn-success" onclick="document.getElementById('create-user-modal').style.display='flex'">
|
||||
<i data-lucide="plus"></i>
|
||||
Create User
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dbm-content-body">
|
||||
<div class="dbm-card" style="margin-bottom: 16px;">
|
||||
<div class="dbm-card-body" style="padding: 12px 16px;">
|
||||
<span style="color: var(--dbm-text-muted); font-size: 12px;">Connected as:</span>
|
||||
<strong style="margin-left: 6px; color: var(--dbm-text);"><?php echo htmlspecialchars($this->current_user); ?></strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dbm-table-wrapper">
|
||||
<table class="dbm-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Host</th>
|
||||
<th style="width: 200px;">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($this->users)): ?>
|
||||
<?php foreach ($this->users as $user): ?>
|
||||
<tr>
|
||||
<td style="font-weight: 500; color: var(--dbm-text);">
|
||||
<i data-lucide="user" style="width: 12px; height: 12px; margin-right: 6px; color: var(--dbm-text-muted);"></i>
|
||||
<?php echo htmlspecialchars($user->User); ?>
|
||||
<?php if ($user->User === $this->current_user): ?>
|
||||
<span class="badge" style="margin-left: 6px; font-size: 9px;">current</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><span class="type-column"><?php echo htmlspecialchars($user->Host); ?></span></td>
|
||||
<td>
|
||||
<a href="<?php echo Config::get('URL'); ?>dbuser/edit/<?php echo urlencode($user->User); ?>/<?php echo urlencode($user->Host); ?>" class="dbm-btn dbm-btn-sm dbm-btn-secondary">
|
||||
<i data-lucide="pencil" style="width: 11px; height: 11px;"></i>
|
||||
Edit
|
||||
</a>
|
||||
<?php if ($user->User !== $this->current_user): ?>
|
||||
<a href="<?php echo Config::get('URL'); ?>dbuser/delete/<?php echo urlencode($user->User); ?>/<?php echo urlencode($user->Host); ?>"
|
||||
class="dbm-btn dbm-btn-sm dbm-btn-danger"
|
||||
data-confirm="Delete user '<?php echo htmlspecialchars($user->User); ?>'@'<?php echo htmlspecialchars($user->Host); ?>'? This cannot be undone!">
|
||||
<i data-lucide="trash-2" style="width: 11px; height: 11px;"></i>
|
||||
Delete
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="3" style="text-align: center; padding: 40px; color: var(--dbm-text-muted);">
|
||||
No users found
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="create-user-modal" class="dbm-modal" style="display: none;">
|
||||
<div class="dbm-modal-content">
|
||||
<div class="dbm-modal-header">
|
||||
<h3>Create New User</h3>
|
||||
<button type="button" class="dbm-modal-close" onclick="this.closest('.dbm-modal').style.display='none'">×</button>
|
||||
</div>
|
||||
<form method="post" action="<?php echo Config::get('URL'); ?>dbuser/create">
|
||||
<div class="dbm-modal-body">
|
||||
<div class="dbm-form-group">
|
||||
<label class="dbm-form-label">Username</label>
|
||||
<input type="text" name="username" class="dbm-form-input" required pattern="[a-zA-Z0-9_]+" placeholder="username">
|
||||
</div>
|
||||
<div class="dbm-form-group">
|
||||
<label class="dbm-form-label">Password</label>
|
||||
<input type="password" name="password" class="dbm-form-input" required placeholder="password">
|
||||
</div>
|
||||
<div class="dbm-form-group">
|
||||
<label class="dbm-form-label">Host</label>
|
||||
<input type="text" name="host" class="dbm-form-input" required value="localhost" placeholder="localhost or %">
|
||||
</div>
|
||||
</div>
|
||||
<div class="dbm-modal-footer">
|
||||
<button type="button" class="dbm-btn dbm-btn-secondary" onclick="this.closest('.dbm-modal').style.display='none'">Cancel</button>
|
||||
<button type="submit" name="submit_create_user" class="dbm-btn dbm-btn-success">Create User</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
37
application/view/dbuser/privileges.php
Normal file
37
application/view/dbuser/privileges.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<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>
|
||||
<span class="separator">/</span>
|
||||
<span>Privileges</span>
|
||||
</div>
|
||||
<div class="dbm-title">
|
||||
<h1>User Privileges</h1>
|
||||
</div>
|
||||
<div class="dbm-actions">
|
||||
<a href="<?php echo Config::get('URL'); ?>dbuser/edit/<?php echo urlencode($this->user->User); ?>/<?php echo urlencode($this->user->Host); ?>" class="dbm-btn dbm-btn-secondary">
|
||||
<i data-lucide="pencil"></i>
|
||||
Edit User
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dbm-content-body">
|
||||
<div class="dbm-card">
|
||||
<div class="dbm-card-header">
|
||||
<h3>Grant Statements</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: 10px; background: var(--dbm-bg-secondary); border-radius: var(--dbm-radius); margin-bottom: 8px; word-break: break-all; border: 1px solid var(--dbm-border);">
|
||||
<?php echo htmlspecialchars($grant); ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<p style="color: var(--dbm-text-muted); font-size: 13px; margin: 0;">No privileges found for this user.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user