devilbox/.devilbox/www/htdocs/db_mysql.php

115 lines
3.0 KiB
PHP
Raw Normal View History

2016-11-06 12:36:07 +00:00
<?php require '../config.php'; ?>
<?php loadClass('Helper')->authPage(); ?>
2017-05-15 06:56:17 +00:00
<?php
// Also required for JS calls (see bottom of this page)
$len_table = 4;
$len_size = 9;
?>
2016-10-09 16:47:49 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
2017-05-15 06:56:17 +00:00
<?php echo loadClass('Html')->getHead(); ?>
2016-10-09 16:47:49 +00:00
</head>
<body>
2017-05-15 06:56:17 +00:00
<?php echo loadClass('Html')->getNavbar(); ?>
2016-10-09 16:47:49 +00:00
<div class="container">
2016-11-15 18:39:11 +00:00
<h1>MySQL Databases</h1>
2016-10-22 17:07:09 +00:00
<br/>
<br/>
2016-10-09 16:47:49 +00:00
<div class="row">
<div class="col-md-12">
2016-10-22 15:38:21 +00:00
2017-05-15 06:56:17 +00:00
<?php if (!loadClass('Mysql')->isAvailable()): ?>
2017-05-08 07:43:43 +00:00
<p>MySQL container is not running.</p>
<?php else: ?>
<table class="table table-striped ">
<thead class="thead-inverse ">
2016-10-09 16:47:49 +00:00
<tr>
2017-05-08 07:43:43 +00:00
<th>Name</th>
<th>Charset</th>
<th>Collation</th>
<th>Tables</th>
<th>Size</th>
</th>
</thead>
<tbody>
2017-05-15 06:56:17 +00:00
<?php foreach (loadClass('Mysql')->getDatabases() as $name => $keys): ?>
2017-05-08 07:43:43 +00:00
<tr>
<td><?php echo $name;?></td>
<td><?php echo $keys['charset'];?></td>
<td><?php echo $keys['collation'];?></td>
<td><code><span class="table" id="table-<?php echo $name;?>"><?php echo str_repeat('&nbsp;', $len_table);?></span></code></td>
<td><code><span class="size" id="size-<?php echo $name;?>"><?php echo str_repeat('&nbsp;', $len_size);?></span></code></td>
</tr>
<input type="hidden" name="database[]" class="database" value="<?php echo $name;?>" />
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
2016-10-22 14:39:08 +00:00
2016-10-09 16:47:49 +00:00
</div>
</div>
</div><!-- /.container -->
2017-05-15 06:56:17 +00:00
<?php echo loadClass('Html')->getFooter(); ?>
2016-10-10 11:06:47 +00:00
<script>
// self executing function here
(function() {
// your page initialization code here
// the DOM will be available here
2016-11-15 18:39:11 +00:00
function updateData(database) {
2016-10-10 11:06:47 +00:00
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
2016-11-15 18:39:11 +00:00
var res = null;
var size = 0;
var tables = 0;
var i;
if (this.readyState == 4 && this.status == 200) {
2016-11-15 18:39:11 +00:00
res = JSON.parse(this.response);
2016-11-15 18:39:11 +00:00
// Normalize size output
size = res.size == 0 ? '0sss MB' : res.size + ' MB';
if (size.length < <?php echo $len_size;?>) {
for (i = size.length; i < <?php echo $len_size;?>; ++i) {
size = '&nbsp;' + size;
}
}
2016-11-15 18:39:11 +00:00
size = size.replace('sss', '&nbsp;&nbsp;&nbsp;');
2016-11-15 18:39:11 +00:00
// Normalize tables output
tables = res.table;
if (tables.length < <?php echo $len_table;?>) {
for (i = tables.length; i < <?php echo $len_table;?>; ++i) {
tables = '&nbsp;' + tables;
}
}
2016-11-15 18:39:11 +00:00
document.getElementById('size-' + database).innerHTML = size;
document.getElementById('table-' + database).innerHTML = tables;
2016-10-10 11:06:47 +00:00
}
};
2016-11-15 18:39:11 +00:00
xhttp.open('GET', '_ajax_callback.php?type=mysql&database=' + database, true);
2016-10-10 11:06:47 +00:00
xhttp.send();
}
var databases = document.getElementsByName('database[]');
2016-10-10 11:06:47 +00:00
var database;
2016-10-10 11:06:47 +00:00
for (i = 0; i < databases.length; i++) {
database = databases[i].value;
2016-11-15 18:39:11 +00:00
updateData(database);
2016-10-10 11:06:47 +00:00
}
})();
</script>
2016-10-09 16:47:49 +00:00
</body>
</html>