Initial commit
This commit is contained in:
105
application/view/_templates/dbmanager_footer.php
Normal file
105
application/view/_templates/dbmanager_footer.php
Normal file
@@ -0,0 +1,105 @@
|
||||
</main>
|
||||
</div><!-- end dbm-main -->
|
||||
|
||||
<!-- SQL Console (Full Width at Bottom) -->
|
||||
<div class="dbm-console expanded">
|
||||
<div class="dbm-console-header">
|
||||
<div class="dbm-console-title">
|
||||
<i data-lucide="terminal" class="icon"></i>
|
||||
SQL Console
|
||||
</div>
|
||||
<i data-lucide="chevron-up" class="dbm-console-toggle"></i>
|
||||
</div>
|
||||
|
||||
<div class="dbm-console-body">
|
||||
<form id="sql-form" method="post" action="<?php echo Config::get('URL'); ?>sql/execute">
|
||||
<?php $current_database = isset($this->database_name) ? $this->database_name : Config::get('DB_NAME'); ?>
|
||||
<input type="hidden" name="database_name" value="<?php echo htmlspecialchars($current_database); ?>">
|
||||
|
||||
<div class="dbm-sql-editor">
|
||||
<div id="sql-highlight" class="dbm-sql-highlight"></div>
|
||||
<textarea name="sql_query" id="sql_query" placeholder="SELECT * FROM table_name LIMIT 10;
|
||||
|
||||
-- Write your SQL query here
|
||||
-- Press Execute or Ctrl+Enter to run"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="dbm-sql-actions">
|
||||
<button type="submit" class="dbm-btn dbm-btn-success">
|
||||
<i data-lucide="play"></i>
|
||||
Execute
|
||||
</button>
|
||||
<button type="button" class="dbm-btn dbm-btn-secondary" onclick="document.getElementById('sql_query').value = ''; document.getElementById('sql-highlight').innerHTML = '';">
|
||||
Clear
|
||||
</button>
|
||||
<select class="db-select" onchange="document.querySelector('input[name=database_name]').value = this.value;">
|
||||
<?php foreach (DatabaseModel::getAllDatabases() as $db): ?>
|
||||
<option value="<?php echo htmlspecialchars($db); ?>" <?php echo $db === $current_database ? 'selected' : ''; ?>>
|
||||
<?php echo htmlspecialchars($db); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div id="sql-result" class="dbm-sql-result">
|
||||
<?php
|
||||
// Check for session result
|
||||
$result = Session::get('sql_result');
|
||||
if ($result) {
|
||||
Session::set('sql_result', null);
|
||||
|
||||
if ($result['success']) {
|
||||
echo '<div class="dbm-sql-result success">';
|
||||
echo '<div class="dbm-sql-result-header">';
|
||||
echo '<i data-lucide="check-circle"></i>';
|
||||
echo htmlspecialchars($result['message']);
|
||||
echo '<span style="margin-left: auto; color: var(--text-muted); font-size: 12px;">' . $result['execution_time'] . 'ms</span>';
|
||||
echo '</div>';
|
||||
|
||||
if (!empty($result['result'])) {
|
||||
echo '<div class="dbm-sql-result-body"><div class="dbm-table-wrapper"><table class="dbm-table"><thead><tr>';
|
||||
foreach (array_keys($result['result'][0]) as $col) {
|
||||
echo '<th>' . htmlspecialchars($col) . '</th>';
|
||||
}
|
||||
echo '</tr></thead><tbody>';
|
||||
foreach ($result['result'] as $row) {
|
||||
echo '<tr>';
|
||||
foreach ($row as $value) {
|
||||
echo '<td>' . ($value === null ? '<span class="null-value">NULL</span>' : htmlspecialchars(substr($value, 0, 100))) . '</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tbody></table></div></div>';
|
||||
}
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<div class="dbm-sql-result error">';
|
||||
echo '<div class="dbm-sql-result-header">';
|
||||
echo '<i data-lucide="x-circle"></i>';
|
||||
echo htmlspecialchars($result['message']);
|
||||
echo '</div>';
|
||||
if (!empty($result['error'])) {
|
||||
echo '<div class="dbm-sql-result-body" style="padding: 16px; font-family: monospace; font-size: 13px; color: var(--accent-red);">' . htmlspecialchars($result['error']) . '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- end dbm-wrapper -->
|
||||
|
||||
</div><!-- end wrapper -->
|
||||
|
||||
<script src="<?php echo Config::get('URL'); ?>js/dbmanager.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
lucide.createIcons();
|
||||
DBManager.init('<?php echo Config::get('URL'); ?>');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
107
application/view/_templates/dbmanager_header.php
Normal file
107
application/view/_templates/dbmanager_header.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Database Manager - HUGE</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" href="data:;base64,=">
|
||||
<link rel="stylesheet" href="<?php echo Config::get('URL'); ?>css/style.css" />
|
||||
<link rel="stylesheet" href="<?php echo Config::get('URL'); ?>css/dbmanager.css" />
|
||||
<script src="https://unpkg.com/lucide@latest"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper dbm-page-wrapper">
|
||||
<?php
|
||||
$uri = trim($_SERVER['REQUEST_URI'], '/');
|
||||
$uri_parts = explode('/', $uri);
|
||||
$current_controller = isset($uri_parts[0]) ? strtolower($uri_parts[0]) : 'database';
|
||||
$is_db_page = in_array($current_controller, ['database', 'table', 'sql']);
|
||||
$is_user_page = ($current_controller === 'dbuser');
|
||||
?>
|
||||
<ul class="navigation">
|
||||
<li><a href="<?php echo Config::get('URL'); ?>index/index">Home</a></li>
|
||||
<li class="<?php echo $is_db_page ? 'active' : ''; ?>"><a href="<?php echo Config::get('URL'); ?>database/index">Database</a></li>
|
||||
<li class="<?php echo $is_user_page ? 'active' : ''; ?>"><a href="<?php echo Config::get('URL'); ?>dbuser/index">Users</a></li>
|
||||
</ul>
|
||||
|
||||
<ul class="navigation right">
|
||||
<li><a href="<?php echo Config::get('URL'); ?>admin/">Admin</a></li>
|
||||
<li><a href="<?php echo Config::get('URL'); ?>login/logout">Logout</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="dbm-wrapper">
|
||||
<div class="dbm-main">
|
||||
<aside class="dbm-sidebar">
|
||||
<div class="dbm-sidebar-header">
|
||||
<i data-lucide="database" class="icon"></i>
|
||||
<h3>Databases</h3>
|
||||
</div>
|
||||
|
||||
<nav class="dbm-tree">
|
||||
<?php
|
||||
$all_databases = DatabaseModel::getAllDatabases();
|
||||
$current_database = isset($this->database_name) ? $this->database_name : Config::get('DB_NAME');
|
||||
$current_table = isset($this->table_name) ? $this->table_name : null;
|
||||
|
||||
foreach ($all_databases as $db):
|
||||
$is_current_db = ($db === $current_database);
|
||||
$tables = $is_current_db ? DatabaseModel::getTablesInDatabase($db) : [];
|
||||
?>
|
||||
<div class="tree-item <?php echo $is_current_db ? 'expanded' : ''; ?>" data-db="<?php echo htmlspecialchars($db); ?>">
|
||||
<div class="tree-header <?php echo $is_current_db ? 'active' : ''; ?>" data-href="<?php echo Config::get('URL'); ?>database/show/<?php echo urlencode($db); ?>">
|
||||
<span class="tree-toggle">
|
||||
<i data-lucide="chevron-right"></i>
|
||||
</span>
|
||||
<span class="tree-icon database">
|
||||
<i data-lucide="database"></i>
|
||||
</span>
|
||||
<span class="tree-label"><?php echo htmlspecialchars($db); ?></span>
|
||||
<?php if (!empty($tables)): ?>
|
||||
<span class="tree-badge"><?php echo count($tables); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="tree-children" <?php echo $is_current_db ? 'data-loaded="true"' : ''; ?>>
|
||||
<?php if ($is_current_db && !empty($tables)): ?>
|
||||
<?php foreach ($tables as $table):
|
||||
$is_current_table = ($table === $current_table);
|
||||
$columns = $is_current_table ? TableModel::getTableColumns($db, $table) : [];
|
||||
?>
|
||||
<div class="tree-item <?php echo $is_current_table ? 'expanded' : ''; ?>" data-table="<?php echo htmlspecialchars($table); ?>">
|
||||
<div class="tree-header <?php echo $is_current_table ? 'active' : ''; ?>" data-href="<?php echo Config::get('URL'); ?>table/show/<?php echo urlencode($db); ?>/<?php echo urlencode($table); ?>">
|
||||
<span class="tree-toggle">
|
||||
<i data-lucide="chevron-right"></i>
|
||||
</span>
|
||||
<span class="tree-icon table">
|
||||
<i data-lucide="table"></i>
|
||||
</span>
|
||||
<span class="tree-label"><?php echo htmlspecialchars($table); ?></span>
|
||||
</div>
|
||||
<div class="tree-children">
|
||||
<?php if ($is_current_table && !empty($columns)): ?>
|
||||
<?php foreach ($columns as $col): ?>
|
||||
<div class="tree-item">
|
||||
<div class="tree-header">
|
||||
<span class="tree-icon <?php echo $col['Key'] === 'PRI' ? 'key' : 'column'; ?>">
|
||||
<?php if ($col['Key'] === 'PRI'): ?>
|
||||
<i data-lucide="key-round"></i>
|
||||
<?php else: ?>
|
||||
<i data-lucide="columns-2"></i>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<span class="tree-label"><?php echo htmlspecialchars($col['Field']); ?></span>
|
||||
<span class="tree-badge"><?php echo htmlspecialchars($col['Type']); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
<main class="dbm-content">
|
||||
@@ -80,6 +80,11 @@
|
||||
</ul>
|
||||
</li>
|
||||
<?php if (Session::get("user_account_type") == 7) : ?>
|
||||
<li <?php if (View::checkForActiveControllers($filename, ['database', 'table', 'sql', 'dbuser'])) {
|
||||
echo ' class="active" ';
|
||||
} ?> >
|
||||
<a href="<?php echo Config::get('URL'); ?>database/index">Database</a>
|
||||
</li>
|
||||
<li <?php if (View::checkForActiveController($filename, "admin")) {
|
||||
echo ' class="active" ';
|
||||
} ?> >
|
||||
|
||||
Reference in New Issue
Block a user