mirror of
https://github.com/cytopia/devilbox.git
synced 2025-01-18 10:46:23 +00:00
Improve local intranet for large number of projects/dbs
This commit is contained in:
parent
4a1902c1f9
commit
9f756c3906
@ -222,6 +222,7 @@ services:
|
||||
|
||||
# Runtime settings
|
||||
- MYSQL_GENERAL_LOG=${MYSQL_GENERAL_LOG}
|
||||
- MYSQL_INNODB_LOG_FILE_SIZE=${MYSQL_INNODB_LOG_FILE_SIZE}
|
||||
- MYSQL_INNODB_BUFFER_POOL_SIZE=${MYSQL_INNODB_BUFFER_POOL_SIZE}
|
||||
- MYSQL_JOIN_BUFFER_SIZE=${MYSQL_JOIN_BUFFER_SIZE}
|
||||
- MYSQL_SORT_BUFFER_SIZE=${MYSQL_SORT_BUFFER_SIZE}
|
||||
@ -229,6 +230,10 @@ services:
|
||||
- MYSQL_SYMBOLIC_LINKS=${MYSQL_SYMBOLIC_LINKS}
|
||||
- MYSQL_SQL_MODE=${MYSQL_SQL_MODE}
|
||||
|
||||
# Used for repairing
|
||||
- MYSQL_INNODB_FORCE_RECOVERY=${MYSQL_INNODB_FORCE_RECOVERY}
|
||||
- MYSQL_MODE=${MYSQL_MODE}
|
||||
|
||||
ports:
|
||||
# [local-machine:]local-port:docker-port
|
||||
- "127.0.0.1:3306:3306"
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?PHP
|
||||
|
||||
$TIME_START = microtime(true);
|
||||
$MY_DIR = dirname(__FILE__);
|
||||
|
||||
|
||||
@ -27,5 +27,10 @@ $MYSQL_HOST_ADDR = gethostbyname($MYSQL_HOST_NAME);
|
||||
$MYSQL_ROOT_PASS = $ENV['MYSQL_ROOT_PASSWORD'];
|
||||
|
||||
|
||||
$MY_MYSQL_ERR = NULL;
|
||||
$MY_MYSQL_LINK = NULL;
|
||||
|
||||
|
||||
require $MY_DIR . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR .'functions.php';
|
||||
|
||||
$MY_MYSQL_LINK = my_mysql_connect($MY_MYSQL_ERR);
|
10
www/htdocs/_ajax_db.php
Normal file
10
www/htdocs/_ajax_db.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
require '../config.php';
|
||||
|
||||
if (isset($_GET['size'])) {
|
||||
echo getDBSize($_GET['size']);
|
||||
} elseif (isset($_GET['table'])) {
|
||||
echo getTableCount($_GET['table']);
|
||||
} else {
|
||||
echo '0';
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
require '../config.php';
|
||||
|
||||
if (isset($_GET['db'])) {
|
||||
echo getDBSize($_GET['db']);
|
||||
} else {
|
||||
echo '0';
|
||||
}
|
8
www/htdocs/_ajax_vhost.php
Normal file
8
www/htdocs/_ajax_vhost.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
require '../config.php';
|
||||
|
||||
if (isset($_GET['valid'])) {
|
||||
echo checkVirtualHost($_GET['valid']);
|
||||
} else {
|
||||
echo '';
|
||||
}
|
@ -274,6 +274,13 @@ span.navbar-brand {
|
||||
}
|
||||
|
||||
|
||||
/* Footer */
|
||||
.footer {
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
|
||||
/* table */
|
||||
.table {
|
||||
@ -304,6 +311,70 @@ span.navbar-brand {
|
||||
border-top: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.table>tbody>tr.success>td,
|
||||
.table>tbody>tr.success>th,
|
||||
.table>tbody>tr>td.success,
|
||||
.table>tbody>tr>th.success,
|
||||
.table>tfoot>tr.success>td,
|
||||
.table>tfoot>tr.success>th,
|
||||
.table>tfoot>tr>td.success,
|
||||
.table>tfoot>tr>th.success,
|
||||
.table>thead>tr.success>td,
|
||||
.table>thead>tr.success>th,
|
||||
.table>thead>tr>td.success,
|
||||
.table>thead>tr>th.success {
|
||||
background-color: #dff0d8;
|
||||
}
|
||||
.table>tbody>tr.danger>td,
|
||||
.table>tbody>tr.danger>th,
|
||||
.table>tbody>tr>td.danger,
|
||||
.table>tbody>tr>th.danger,
|
||||
.table>tfoot>tr.danger>td,
|
||||
.table>tfoot>tr.danger>th,
|
||||
.table>tfoot>tr>td.danger,
|
||||
.table>tfoot>tr>th.danger,
|
||||
.table>thead>tr.danger>td,
|
||||
.table>thead>tr.danger>th,
|
||||
.table>thead>tr>td.danger,
|
||||
.table>thead>tr>th.danger {
|
||||
background-color: #f2dede;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
* Clearings
|
||||
********************************************************************************/
|
||||
|
||||
.btn-group-vertical>.btn-group:after, .btn-toolbar:after, .clearfix:after, .container-fluid:after, .container:after, .dl-horizontal dd:after, .form-horizontal .form-group:after, .modal-footer:after, .modal-header:after, .nav:after, .navbar-collapse:after, .navbar-header:after, .navbar:after, .pager:after, .panel-body:after, .row:after {
|
||||
clear: both;
|
||||
}
|
||||
.btn-group-vertical>.btn-group:after, .btn-group-vertical>.btn-group:before, .btn-toolbar:after, .btn-toolbar:before, .clearfix:after, .clearfix:before, .container-fluid:after, .container-fluid:before, .container:after, .container:before, .dl-horizontal dd:after, .dl-horizontal dd:before, .form-horizontal .form-group:after, .form-horizontal .form-group:before, .modal-footer:after, .modal-footer:before, .modal-header:after, .modal-header:before, .nav:after, .nav:before, .navbar-collapse:after, .navbar-collapse:before, .navbar-header:after, .navbar-header:before, .navbar:after, .navbar:before, .pager:after, .pager:before, .panel-body:after, .panel-body:before, .row:after, .row:before {
|
||||
display: table;
|
||||
content: " ";
|
||||
}
|
||||
:after, :before {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
|
@ -54,6 +54,7 @@
|
||||
<th>Name</th>
|
||||
<th>Charset</th>
|
||||
<th>Collation</th>
|
||||
<th>Tables</th>
|
||||
<th>Size</th>
|
||||
</th>
|
||||
</thead>
|
||||
@ -63,8 +64,10 @@
|
||||
<td><?php echo $name;?></td>
|
||||
<td><?php echo $keys['charset'];?></td>
|
||||
<td><?php echo $keys['collation'];?></td>
|
||||
<td><span class="size" id="<?php echo $name;?>"></span> MB</td>
|
||||
<td><code><span class="table" id="table-<?php echo $name;?>"> </span></code></td>
|
||||
<td><code><span class="size" id="size-<?php echo $name;?>"> </span></code></td>
|
||||
</tr>
|
||||
<input type="hidden" name="database[]" class="database" value="<?php echo $name;?>" />
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -73,7 +76,7 @@
|
||||
|
||||
</div><!-- /.container -->
|
||||
|
||||
|
||||
<?php require '../include/footer.php'; ?>
|
||||
<script>
|
||||
// self executing function here
|
||||
(function() {
|
||||
@ -82,21 +85,59 @@
|
||||
|
||||
function updateSizes(database) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
var fill = '';
|
||||
var res = '';
|
||||
var len;
|
||||
var i;
|
||||
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
document.getElementById(database).innerHTML = this.responseText;
|
||||
console.log(this.responseText);
|
||||
res = (this.responseText) == 0 ? '0sss MB' : this.responseText+' MB';
|
||||
len = res.length;
|
||||
if (len < 8) {
|
||||
for (i=len; i<8; i++) {
|
||||
fill = ' ' + fill;
|
||||
}
|
||||
|
||||
}
|
||||
res = res.replace('sss', ' ');
|
||||
res = fill + res;
|
||||
document.getElementById('size-' + database).innerHTML = res;
|
||||
}
|
||||
};
|
||||
xhttp.open('GET', '_ajax_db_size.php?db=' + database, true);
|
||||
xhttp.open('GET', '_ajax_db.php?size=' + database, true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
var databases = document.getElementsByClassName('size');
|
||||
|
||||
function updateCount(database) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
var fill = '';
|
||||
var i;
|
||||
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
if (this.responseText.length < 4) {
|
||||
for (i=this.responseText.length; i<4; i++) {
|
||||
fill = ' ' + fill;
|
||||
}
|
||||
}
|
||||
document.getElementById('table-' + database).innerHTML = fill + this.responseText;
|
||||
}
|
||||
};
|
||||
xhttp.open('GET', '_ajax_db.php?table=' + database, true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
var databases = document.getElementsByName('database[]');
|
||||
var database;
|
||||
|
||||
for (i = 0; i < databases.length; i++) {
|
||||
database = databases[i].getAttribute('id');
|
||||
database = databases[i].value;
|
||||
updateSizes(database);
|
||||
updateCount(database);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
|
@ -213,6 +213,13 @@ sql_mode = <?php echo getMySQLConfig('sql-mode')."\n";?>
|
||||
|
||||
</div><!-- /.container -->
|
||||
|
||||
|
||||
<?php require '../include/footer.php'; ?>
|
||||
<script>
|
||||
// self executing function here
|
||||
(function() {
|
||||
// your page initialization code here
|
||||
// the DOM will be available here
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -47,5 +47,13 @@
|
||||
|
||||
</div><!-- /.container -->
|
||||
|
||||
<?php require '../include/footer.php'; ?>
|
||||
<script>
|
||||
// self executing function here
|
||||
(function() {
|
||||
// your page initialization code here
|
||||
// the DOM will be available here
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<?php $vHosts = getVhosts(); ?>
|
||||
<?php $vHosts = getVirtualHosts(); ?>
|
||||
<?php if ($vHosts): ?>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
@ -57,43 +57,21 @@
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$totals = 70;
|
||||
$filler = ' ';
|
||||
for ($i=0; $i<$totals; $i++) {
|
||||
$filler = $filler. ' ';
|
||||
}
|
||||
?>
|
||||
<?php foreach ($vHosts as $vHost): ?>
|
||||
<?php
|
||||
$err = array();
|
||||
$ern = 0;
|
||||
|
||||
if (!$vHost['htdocs']) {
|
||||
$err[] = 'Missing <strong>htdocs</strong> directory in: <strong>'.$ENV['HOST_PATH_TO_WWW_DOCROOTS'].'/'.$vHost['name'].'/</strong>';
|
||||
$ern++;
|
||||
}
|
||||
if ($vHost['dns_ok']) {
|
||||
|
||||
if ($vHost['dns_ip'] != '127.0.0.1') {
|
||||
$err[] = 'Error in <strong>/etc/hosts</strong><br/>'.
|
||||
'Found:<br/>'.
|
||||
'<code>'.$vHost['dns_ip'].' '.$vHost['domain'].'</code><br/>'.
|
||||
'But it should be:<br/>'.
|
||||
'<code>127.0.0.1 '.$vHost['domain'].'</code><br/>';
|
||||
$ern++;
|
||||
|
||||
}
|
||||
} else {
|
||||
$err[] = 'Missing entry in <strong>/etc/hosts</strong>:<br/><code>127.0.0.1 '.$vHost['domain'].'</code>';
|
||||
$ern++;
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $vHost['name'];?></td>
|
||||
<td><?php echo $ENV['HOST_PATH_TO_WWW_DOCROOTS'];?>/<?php echo $vHost['name'];?>/htdocs</td>
|
||||
<?php if ($ern): ?>
|
||||
<td colspan="2">
|
||||
<?php echo implode('<br/>', $err); ?>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td>OK</td>
|
||||
<td><a target="_blank" href="<?php echo $vHost['href'];?>"><?php echo $vHost['domain'];?></a></td>
|
||||
<?php endif; ?>
|
||||
<td id="valid-<?php echo $vHost['name'];?>"> </td>
|
||||
<td id="href-<?php echo $vHost['name'];?>"><?php echo $filler;?></td>
|
||||
</tr>
|
||||
<input type="hidden" name="vhost[]" class="vhost" value="<?php echo $vHost['name'];?>" />
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -107,5 +85,50 @@
|
||||
|
||||
</div><!-- /.container -->
|
||||
|
||||
<?php require '../include/footer.php'; ?>
|
||||
<script>
|
||||
// self executing function here
|
||||
(function() {
|
||||
// your page initialization code here
|
||||
// the DOM will be available here
|
||||
|
||||
|
||||
function updateStatus(vhost) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
var error = '';
|
||||
var el_valid;
|
||||
var el_href;
|
||||
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
el_valid = document.getElementById('valid-' + vhost);
|
||||
el_href = document.getElementById('href-' + vhost);
|
||||
error = this.responseText;
|
||||
|
||||
if (error.length) {
|
||||
el_valid.className += ' danger';
|
||||
el_valid.innerHTML = 'ERR';
|
||||
el_href.innerHTML = error;
|
||||
} else {
|
||||
el_valid.className += ' success';
|
||||
el_valid.innerHTML = 'OK';
|
||||
el_href.innerHTML = '<a target="_blank" href="http://'+vhost+'.loc">'+vhost+'.loc</a>';
|
||||
}
|
||||
}
|
||||
};
|
||||
xhttp.open('GET', '_ajax_vhost.php?valid=' + vhost, true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
|
||||
var vhosts = document.getElementsByName('vhost[]');
|
||||
|
||||
for (i = 0; i < vhosts.length; i++) {
|
||||
updateStatus(vhosts[i].value);
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
6
www/include/footer.php
Normal file
6
www/include/footer.php
Normal file
@ -0,0 +1,6 @@
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">Render time: <?php echo round((microtime(true) - $TIME_START), 2); ?> sec</p>
|
||||
</div>
|
||||
</footer>
|
||||
<?php my_mysqli_close($GLOBALS['MY_MYSQL_LINK']); ?>
|
@ -1,6 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Executes shell commands on the PHP-FPM Host
|
||||
*
|
||||
* @param string $cmd [description]
|
||||
* @param string $output [description]
|
||||
* @return integer
|
||||
*/
|
||||
function my_exec($cmd, &$output = '')
|
||||
{
|
||||
// Clean output
|
||||
@ -9,9 +16,88 @@ function my_exec($cmd, &$output = '')
|
||||
return $exit_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to database
|
||||
*
|
||||
* @param [type] $err [description]
|
||||
* @param [type] $host [description]
|
||||
* @param [type] $pass [description]
|
||||
* @param [type] $user [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function my_mysql_connect(&$err, $host = NULL, $pass = NULL, $user = NULL)
|
||||
{
|
||||
if ($host === NULL) {
|
||||
$host = $GLOBALS['MYSQL_HOST_ADDR'];
|
||||
}
|
||||
if ($pass === NULL) {
|
||||
$pass = $GLOBALS['MYSQL_ROOT_PASS'];
|
||||
}
|
||||
if ($user === NULL) {
|
||||
$user = 'root';
|
||||
}
|
||||
|
||||
try {
|
||||
$link = mysqli_connect($host, $user, $pass);
|
||||
} catch (Exception $e) {
|
||||
$err = $e->getMessage().': '.mysqli_connect_error();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// if (!($link = @mysqli_connect($host, $user, $pass))) {
|
||||
// $err = mysqli_connect_error();
|
||||
// return FALSE;
|
||||
// }
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close Database connection
|
||||
*
|
||||
* @param [type] $link [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function my_mysqli_close($link) {
|
||||
return mysqli_close($link);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query Database
|
||||
*
|
||||
* @param [type] $err [description]
|
||||
* @param [type] $link [description]
|
||||
* @param [type] $query [description]
|
||||
* @param [type] $callback [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function my_mysqli_select(&$err, $link, $query, $callback = NULL)
|
||||
{
|
||||
if (!($result = mysqli_query($link, $query))) {
|
||||
$err = mysqli_error($link);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
|
||||
if ($callback) {
|
||||
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$callback($row, $data);
|
||||
}
|
||||
} else {
|
||||
$data[] = $row;
|
||||
}
|
||||
mysqli_free_result($result);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* G E T D A T A
|
||||
* M Y S Q L F U N C T I O N S
|
||||
*
|
||||
********************************************************************************/
|
||||
|
||||
@ -20,9 +106,13 @@ function my_exec($cmd, &$output = '')
|
||||
* @return mixed Array of name => size
|
||||
*/
|
||||
function getDatabases() {
|
||||
global $MYSQL_HOST_ADDR;
|
||||
global $MYSQL_ROOT_PASS;
|
||||
$conn = mysqli_connect($MYSQL_HOST_ADDR, 'root', $MYSQL_ROOT_PASS);
|
||||
$error;
|
||||
$callback = function ($row, &$data) {
|
||||
$data[$row['database']] = array(
|
||||
'charset' => $row['charset'],
|
||||
'collation' => $row['collation']
|
||||
);
|
||||
};
|
||||
|
||||
$sql = "SELECT
|
||||
S.SCHEMA_NAME AS 'database',
|
||||
@ -35,46 +125,160 @@ function getDatabases() {
|
||||
S.SCHEMA_NAME != 'performance_schema' AND
|
||||
S.SCHEMA_NAME != 'information_schema'";
|
||||
|
||||
$result = mysqli_query($conn, $sql);
|
||||
$data = array();
|
||||
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$data[$row['database']] = array(
|
||||
'charset' => $row['charset'],
|
||||
'collation' => $row['collation'],
|
||||
//'size' => $row['size'],
|
||||
);
|
||||
}
|
||||
mysqli_close($conn);
|
||||
return $data;
|
||||
return my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Database size in Megabytes
|
||||
* @param [type] $db_name [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function getDBSize($db_name) {
|
||||
global $MYSQL_HOST_ADDR;
|
||||
global $MYSQL_ROOT_PASS;
|
||||
$conn = mysqli_connect($MYSQL_HOST_ADDR, 'root', $MYSQL_ROOT_PASS);
|
||||
$error;
|
||||
$callback = function ($row, &$data) {
|
||||
$data = $row['size'];
|
||||
};
|
||||
|
||||
$sql = "SELECT
|
||||
SUM( T.data_length + T.index_length ) / 1048576 AS 'size'
|
||||
ROUND( SUM((T.data_length+T.index_length)/1048576), 2 ) AS 'size'
|
||||
FROM
|
||||
information_schema.TABLES AS T
|
||||
WHERE
|
||||
T.TABLE_SCHEMA = '".$db_name."';";
|
||||
|
||||
$result = mysqli_query($conn, $sql);
|
||||
$data = array();
|
||||
$size = 0;
|
||||
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
|
||||
$size = $row['size'];
|
||||
}
|
||||
mysqli_close($conn);
|
||||
return $size ? $size : '0';
|
||||
$size = my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback);
|
||||
return $size ? $size : 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Tables per Database
|
||||
* @param [type] $db_name [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function getTableCount($db_name) {
|
||||
$error;
|
||||
$callback = function ($row, &$data) {
|
||||
$data = $row['count'];
|
||||
};
|
||||
|
||||
$sql = "SELECT
|
||||
COUNT(*) AS 'count'
|
||||
FROM
|
||||
information_schema.TABLES AS T
|
||||
WHERE
|
||||
T.TABLE_SCHEMA = '".$db_name."';";
|
||||
|
||||
$count = my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback);
|
||||
return $count ? $count : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read out MySQL Server variables
|
||||
*
|
||||
* @param [type] $key [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
function getMySQLConfig($key) {
|
||||
$key = str_replace('-', '_', $key);
|
||||
|
||||
$callback = function ($row, &$data) use ($key) {
|
||||
$data = isset($row['Value']) ? $row['Value'] : FALSE;
|
||||
};
|
||||
|
||||
$sql = 'SHOW VARIABLES WHERE Variable_Name = "'.$key.'";';
|
||||
$val = my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback);
|
||||
|
||||
if (!is_array($val)) {
|
||||
return $val;
|
||||
} else if (is_array($val) && $val) {
|
||||
return print_r($val, TRUE);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function is_valid_dir($path) {
|
||||
return (is_dir($path) || (is_link($path) && is_dir(readlink($path))));
|
||||
}
|
||||
|
||||
function getVirtualHosts()
|
||||
{
|
||||
$docRoot = '/shared/httpd';
|
||||
$vhosts = array();
|
||||
|
||||
if ($handle = opendir($docRoot)) {
|
||||
while (false !== ($directory = readdir($handle))) {
|
||||
if (is_valid_dir($docRoot . DIRECTORY_SEPARATOR . $directory) && $directory != '.' && $directory != '..') {
|
||||
|
||||
$vhosts[] = array(
|
||||
'name' => $directory,
|
||||
'domain' => $directory.'.loc',
|
||||
'href' => 'http://' . $directory.'.loc'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $vhosts;
|
||||
}
|
||||
function checkVirtualHost($vhost)
|
||||
{
|
||||
global $ENV;
|
||||
|
||||
$docRoot = '/shared/httpd';
|
||||
$htdocs = $docRoot.DIRECTORY_SEPARATOR.$vhost.DIRECTORY_SEPARATOR.'htdocs';
|
||||
$domain = $vhost.'.loc';
|
||||
$url = 'http://'.$domain;
|
||||
$error = array();
|
||||
|
||||
|
||||
// 1. Check htdocs folder
|
||||
if (!is_valid_dir($htdocs)) {
|
||||
$error[] = 'Missing <strong>htdocs</strong> directory in: <strong>'.$ENV['HOST_PATH_TO_WWW_DOCROOTS'].'/'.$vhost.'/</strong>';
|
||||
}
|
||||
|
||||
|
||||
// 2. Check /etc/resolv DNS entry
|
||||
$output;
|
||||
if (my_exec('getent hosts '.$domain, $output) !== 0) {
|
||||
$error[] = 'Missing entry in <strong>/etc/hosts</strong>:<br/><code>127.0.0.1 '.$domain.'</code>';
|
||||
}
|
||||
|
||||
// 3. Check correct /etc/resolv entry
|
||||
$dns_ip = '127.0.0.1';
|
||||
if (isset($output[0])) {
|
||||
$tmp = explode(' ', $output[0]);
|
||||
if (isset($tmp[0])) {
|
||||
$dns_ip = $tmp[0];
|
||||
}
|
||||
}
|
||||
if ($dns_ip != '127.0.0.1') {
|
||||
$error[] = 'Error in <strong>/etc/hosts</strong><br/>'.
|
||||
'Found:<br/>'.
|
||||
'<code>'.$dns_ip.' '.$domain.'</code><br/>'.
|
||||
'But it should be:<br/>'.
|
||||
'<code>127.0.0.1 '.$domain.'</code><br/>';
|
||||
}
|
||||
|
||||
if (is_array($error) && count($error)) {
|
||||
return implode('<br/>', $error);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all VirtualHosts
|
||||
* @return [type] [description]
|
||||
@ -120,6 +324,9 @@ function getVhosts() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* G E T V E R S I O N
|
||||
@ -153,24 +360,6 @@ function getPHPVersion() {
|
||||
|
||||
|
||||
|
||||
function getMySQLConfig($key) {
|
||||
global $MYSQL_HOST_ADDR;
|
||||
global $MYSQL_ROOT_PASS;
|
||||
|
||||
$link = @mysqli_connect($MYSQL_HOST_ADDR, 'root', $MYSQL_ROOT_PASS);
|
||||
|
||||
if (!$link) {
|
||||
return 'Cannot conncet to MySQL Database: '.mysqli_connect_error();
|
||||
}
|
||||
$key = str_replace('-', '_', $key);
|
||||
$query = 'SHOW VARIABLES WHERE Variable_Name = "'.$key.'";';
|
||||
$result = mysqli_query($link, $query);
|
||||
$data = mysqli_fetch_array($result);
|
||||
if (isset($data[1])) {
|
||||
return $data[1];
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user