mirror of
https://github.com/cytopia/devilbox.git
synced 2024-12-22 06:07:48 +00:00
REL-0.9 Intranet refactoring
This commit is contained in:
parent
83ab3d8758
commit
f1b88a9c60
@ -10,10 +10,10 @@ if (isset($_GET['database'])) {
|
|||||||
} else if (isset($_GET['type']) && $_GET['type'] == 'postgres') {
|
} else if (isset($_GET['type']) && $_GET['type'] == 'postgres') {
|
||||||
$schema = isset($_GET['schema']) ? $_GET['schema'] : '';
|
$schema = isset($_GET['schema']) ? $_GET['schema'] : '';
|
||||||
echo json_encode(array(
|
echo json_encode(array(
|
||||||
'size' => (string)loadClass('Postgres')->getSchemaSize($_GET['database'], $schema),
|
'size' => (string)loadClass('Pgsql')->getSchemaSize($_GET['database'], $schema),
|
||||||
'table' => (string)loadClass('Postgres')->getTableCount($_GET['database'], $schema)
|
'table' => (string)loadClass('Pgsql')->getTableCount($_GET['database'], $schema)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else if (isset($_GET['vhost'])) {
|
} else if (isset($_GET['vhost'])) {
|
||||||
echo loadClass('Docker')->PHP_checkVirtualHost($_GET['vhost']);
|
echo loadClass('Httpd')->checkVirtualHost($_GET['vhost']);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php $FONT_AWESOME = TRUE; require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(true); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -92,11 +92,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $Postgres = loadClass('Memcd'); ?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -18,8 +17,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<?php if (!\devilbox\Memcd::isAvailable($GLOBALS['MEMCD_HOST_NAME'])): ?>
|
<?php if (!loadClass('Memcd')->isAvailable()): ?>
|
||||||
<p>Memcahed container is not running.</p>
|
<p>Memcached container is not running.</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<table class="table table-striped ">
|
<table class="table table-striped ">
|
||||||
<thead class="thead-inverse ">
|
<thead class="thead-inverse ">
|
||||||
@ -44,7 +43,6 @@
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $MySQL = loadClass('Mysql'); ?>
|
<?php
|
||||||
|
// Also required for JS calls (see bottom of this page)
|
||||||
|
$len_table = 4;
|
||||||
|
$len_size = 9;
|
||||||
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -18,7 +22,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<?php if (!\devilbox\Mysql::isAvailable($GLOBALS['MYSQL_HOST_NAME'])): ?>
|
<?php if (!loadClass('Mysql')->isAvailable()): ?>
|
||||||
<p>MySQL container is not running.</p>
|
<p>MySQL container is not running.</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<table class="table table-striped ">
|
<table class="table table-striped ">
|
||||||
@ -32,11 +36,7 @@
|
|||||||
</th>
|
</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php foreach (loadClass('Mysql')->getDatabases() as $name => $keys): ?>
|
||||||
$len_table = 4;
|
|
||||||
$len_size = 9;
|
|
||||||
?>
|
|
||||||
<?php foreach ($MySQL->getDatabases() as $name => $keys): ?>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $name;?></td>
|
<td><?php echo $name;?></td>
|
||||||
<td><?php echo $keys['charset'];?></td>
|
<td><?php echo $keys['charset'];?></td>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
<script>
|
<script>
|
||||||
// self executing function here
|
// self executing function here
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $Postgres = loadClass('Pgsql'); ?>
|
<?php
|
||||||
|
// Also required for JS calls (see bottom of this page)
|
||||||
|
$len_table = 4;
|
||||||
|
$len_size = 9;
|
||||||
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -18,7 +22,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<?php if (!\devilbox\Pgsql::isAvailable($GLOBALS['PGSQL_HOST_NAME'])): ?>
|
<?php if (!loadClass('Pgsql')->isAvailable()): ?>
|
||||||
<p>PgSQL container is not running.</p>
|
<p>PgSQL container is not running.</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<table class="table table-striped ">
|
<table class="table table-striped ">
|
||||||
@ -32,11 +36,7 @@
|
|||||||
</th>
|
</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php foreach (loadClass('Pgsql')->getDatabases() as $name => $database): ?>
|
||||||
$len_table = 4;
|
|
||||||
$len_size = 9;
|
|
||||||
?>
|
|
||||||
<?php foreach ($Postgres->getDatabases() as $name => $database): ?>
|
|
||||||
<tr class="table-info">
|
<tr class="table-info">
|
||||||
<th>
|
<th>
|
||||||
<?php echo $name;?>
|
<?php echo $name;?>
|
||||||
@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
<script>
|
<script>
|
||||||
// self executing function here
|
// self executing function here
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $Postgres = loadClass('Redis'); ?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -18,7 +17,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<?php if (!\devilbox\Redis::isAvailable($GLOBALS['REDIS_HOST_NAME'])): ?>
|
<?php if (!loadClass('Redis')->isAvailable()): ?>
|
||||||
<p>Redis container is not running.</p>
|
<p>Redis container is not running.</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<table class="table table-striped ">
|
<table class="table table-striped ">
|
||||||
@ -44,7 +43,6 @@
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -17,8 +17,8 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<?php $errors = loadClass('Logger')->getAll(); ?>
|
<?php $errors = loadClass('Logger')->getAll(); ?>
|
||||||
<?php if ($errors === false): ?>
|
<?php if ($errors === false): ?>
|
||||||
<p>Writing to logfile is not possible. Errors will be sent as mail instead. Check the mail section.</p>
|
<p>Writing to logfile is not possible. Errors will be sent as mail instead. Check the mail section.</p>
|
||||||
<?php elseif (count($errors) === 0): ?>
|
<?php elseif (count($errors) === 0): ?>
|
||||||
<p>No errors detected.</div>
|
<p>No errors detected.</div>
|
||||||
@ -28,14 +28,29 @@
|
|||||||
<thead class="thead-inverse">
|
<thead class="thead-inverse">
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
|
<th>date</th>
|
||||||
<th>Errors (<?php echo $total;?>)</th>
|
<th>Errors (<?php echo $total;?>)</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php for ($i=($total-1); $i>=0; --$i): ?>
|
<?php for ($i=($total-1); $i>=0; --$i): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo ($i+1);?></td>
|
<th><?php echo ($i+1);?></th>
|
||||||
<td><code><?php echo $errors[$i];?></code></td>
|
<th><code><?php echo $errors[$i]['date'];?></code></th>
|
||||||
|
<th><code><?php echo $errors[$i]['head'];?></code></th>
|
||||||
|
<?php if (isset($errors[$i]['body'])): ?>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<?php
|
||||||
|
$dump = implode('', $errors[$i]['body']);
|
||||||
|
//$dump = str_replace("=></font> \n", '=></font>', $dump);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<code><?php echo $dump; ?></code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endif; ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endfor; ?>
|
<?php endfor; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -47,6 +62,6 @@
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $Docker = loadClass('Docker'); ?>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
@ -8,28 +7,17 @@
|
|||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* Load required files
|
|
||||||
*************************************************************/
|
|
||||||
loadFile('Php');
|
|
||||||
loadFile('Dns');
|
|
||||||
loadFile('Httpd');
|
|
||||||
loadFile('Mysql');
|
|
||||||
loadFile('Pgsql');
|
|
||||||
loadFile('Redis');
|
|
||||||
loadFile('Memcd');
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
* Get availability
|
* Get availability
|
||||||
*************************************************************/
|
*************************************************************/
|
||||||
$avail_php = \devilbox\Php::isAvailable($GLOBALS['PHP_HOST_NAME']);
|
$avail_php = loadClass('Php')->isAvailable();
|
||||||
$avail_dns = \devilbox\Dns::isAvailable($GLOBALS['DNS_HOST_NAME']);
|
$avail_dns = loadClass('Dns')->isAvailable();
|
||||||
$avail_httpd = \devilbox\Httpd::isAvailable($GLOBALS['HTTPD_HOST_NAME']);
|
$avail_httpd = loadClass('Httpd')->isAvailable();
|
||||||
$avail_mysql = \devilbox\Mysql::isAvailable($GLOBALS['MYSQL_HOST_NAME']);
|
$avail_mysql = loadClass('Mysql')->isAvailable();
|
||||||
$avail_pgsql = \devilbox\Pgsql::isAvailable($GLOBALS['PGSQL_HOST_NAME']);
|
$avail_pgsql = loadClass('Pgsql')->isAvailable();
|
||||||
$avail_redis = \devilbox\Redis::isAvailable($GLOBALS['REDIS_HOST_NAME']);
|
$avail_redis = loadClass('Redis')->isAvailable();
|
||||||
$avail_memcd = \devilbox\Memcd::isAvailable($GLOBALS['MEMCD_HOST_NAME']);
|
$avail_memcd = loadClass('Memcd')->isAvailable();
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
@ -39,23 +27,23 @@ $avail_memcd = \devilbox\Memcd::isAvailable($GLOBALS['MEMCD_HOST_NAME']);
|
|||||||
$connection = array();
|
$connection = array();
|
||||||
$error = null;
|
$error = null;
|
||||||
|
|
||||||
// ---- HTTPD ----
|
// ---- HTTPD (required) ----
|
||||||
$host = $GLOBALS['HTTPD_HOST_NAME'];
|
$host = $GLOBALS['HTTPD_HOST_NAME'];
|
||||||
$succ = \devilbox\Httpd::testConnection($error, $host);
|
$succ = loadClass('Httpd')->canConnect($error, $host);
|
||||||
$connection['Httpd'][$host] = array(
|
$connection['Httpd'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = \devilbox\Httpd::getIpAddress($GLOBALS['HTTPD_HOST_NAME']);
|
$host = loadClass('Httpd')->getIpAddress();
|
||||||
$succ = \devilbox\Httpd::testConnection($error, $host);
|
$succ = loadClass('Httpd')->canConnect($error, $host);
|
||||||
$connection['Httpd'][$host] = array(
|
$connection['Httpd'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = 'random.'.loadClass('Php')->getTldSuffix();
|
$host = 'random.'.loadClass('Httpd')->getTldSuffix();
|
||||||
$succ = \devilbox\Httpd::testConnection($error, $host);
|
$succ = loadClass('Httpd')->canConnect($error, $host);
|
||||||
$connection['Httpd'][$host] = array(
|
$connection['Httpd'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
@ -65,21 +53,21 @@ $connection['Httpd'][$host] = array(
|
|||||||
// ---- MYSQL ----
|
// ---- MYSQL ----
|
||||||
if ($avail_mysql) {
|
if ($avail_mysql) {
|
||||||
$host = $GLOBALS['MYSQL_HOST_NAME'];
|
$host = $GLOBALS['MYSQL_HOST_NAME'];
|
||||||
$succ = \devilbox\Mysql::testConnection($error, $host, 'root', loadClass('Docker')->getEnv('MYSQL_ROOT_PASSWORD'));
|
$succ = loadClass('Mysql')->canConnect($error, $host, array('user' => 'root', 'pass' => loadClass('Helper')->getEnv('MYSQL_ROOT_PASSWORD')));
|
||||||
$connection['MySQL'][$host] = array(
|
$connection['MySQL'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = \devilbox\Mysql::getIpAddress($GLOBALS['MYSQL_HOST_NAME']);
|
$host = loadClass('Mysql')->getIpAddress();
|
||||||
$succ = \devilbox\Mysql::testConnection($error, $host, 'root', loadClass('Docker')->getEnv('MYSQL_ROOT_PASSWORD'));
|
$succ = loadClass('Mysql')->canConnect($error, $host, array('user' => 'root', 'pass' => loadClass('Helper')->getEnv('MYSQL_ROOT_PASSWORD')));
|
||||||
$connection['MySQL'][$host] = array(
|
$connection['MySQL'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = '127.0.0.1';
|
$host = '127.0.0.1';
|
||||||
$succ = \devilbox\Mysql::testConnection($error, $host, 'root', loadClass('Docker')->getEnv('MYSQL_ROOT_PASSWORD'));
|
$succ = loadClass('Mysql')->canConnect($error, $host, array('user' => 'root', 'pass' => loadClass('Helper')->getEnv('MYSQL_ROOT_PASSWORD')));
|
||||||
$connection['MySQL'][$host] = array(
|
$connection['MySQL'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
@ -90,21 +78,21 @@ if ($avail_mysql) {
|
|||||||
// ---- PGSQL ----
|
// ---- PGSQL ----
|
||||||
if ($avail_pgsql) {
|
if ($avail_pgsql) {
|
||||||
$host = $GLOBALS['PGSQL_HOST_NAME'];
|
$host = $GLOBALS['PGSQL_HOST_NAME'];
|
||||||
$succ = \devilbox\Pgsql::testConnection($error, $host, loadClass('Docker')->getEnv('PGSQL_ROOT_USER'), loadClass('Docker')->getEnv('PGSQL_ROOT_PASSWORD'));
|
$succ = loadClass('Pgsql')->canConnect($error, $host, array('user' => loadClass('Helper')->getEnv('PGSQL_ROOT_USER'), 'pass' => loadClass('Helper')->getEnv('PGSQL_ROOT_PASSWORD')));
|
||||||
$connection['PgSQL'][$host] = array(
|
$connection['PgSQL'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = \devilbox\Pgsql::getIpAddress($GLOBALS['PGSQL_HOST_NAME']);
|
$host = loadClass('Pgsql')->getIpAddress();
|
||||||
$succ = \devilbox\Pgsql::testConnection($error, $host, loadClass('Docker')->getEnv('PGSQL_ROOT_USER'), loadClass('Docker')->getEnv('PGSQL_ROOT_PASSWORD'));
|
$succ = loadClass('Pgsql')->canConnect($error, $host, array('user' => loadClass('Helper')->getEnv('PGSQL_ROOT_USER'), 'pass' => loadClass('Helper')->getEnv('PGSQL_ROOT_PASSWORD')));
|
||||||
$connection['PgSQL'][$host] = array(
|
$connection['PgSQL'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = '127.0.0.1';
|
$host = '127.0.0.1';
|
||||||
$succ = \devilbox\Pgsql::testConnection($error, $host, loadClass('Docker')->getEnv('PGSQL_ROOT_USER'), loadClass('Docker')->getEnv('PGSQL_ROOT_PASSWORD'));
|
$succ = loadClass('Pgsql')->canConnect($error, $host, array('user' => loadClass('Helper')->getEnv('PGSQL_ROOT_USER'), 'pass' => loadClass('Helper')->getEnv('PGSQL_ROOT_PASSWORD')));
|
||||||
$connection['PgSQL'][$host] = array(
|
$connection['PgSQL'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
@ -115,21 +103,21 @@ if ($avail_pgsql) {
|
|||||||
// ---- REDIS ----
|
// ---- REDIS ----
|
||||||
if ($avail_redis) {
|
if ($avail_redis) {
|
||||||
$host = $GLOBALS['REDIS_HOST_NAME'];
|
$host = $GLOBALS['REDIS_HOST_NAME'];
|
||||||
$succ = \devilbox\Redis::testConnection($error, $host);
|
$succ = loadClass('Redis')->canConnect($error, $host);
|
||||||
$connection['Redis'][$host] = array(
|
$connection['Redis'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = \devilbox\Redis::getIpAddress($GLOBALS['REDIS_HOST_NAME']);
|
$host = loadClass('Redis')->getIpAddress();
|
||||||
$succ = \devilbox\Redis::testConnection($error, $host);
|
$succ = loadClass('Redis')->canConnect($error, $host);
|
||||||
$connection['Redis'][$host] = array(
|
$connection['Redis'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = '127.0.0.1';
|
$host = '127.0.0.1';
|
||||||
$succ = \devilbox\Redis::testConnection($error, $host);
|
$succ = loadClass('Redis')->canConnect($error, $host);
|
||||||
$connection['Redis'][$host] = array(
|
$connection['Redis'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
@ -140,21 +128,21 @@ if ($avail_redis) {
|
|||||||
// ---- MEMCACHED ----
|
// ---- MEMCACHED ----
|
||||||
if ($avail_memcd) {
|
if ($avail_memcd) {
|
||||||
$host = $GLOBALS['MEMCD_HOST_NAME'];
|
$host = $GLOBALS['MEMCD_HOST_NAME'];
|
||||||
$succ = \devilbox\Memcd::testConnection($error, $host);
|
$succ = loadClass('Memcd')->canConnect($error, $host);
|
||||||
$connection['Memcached'][$host] = array(
|
$connection['Memcached'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = \devilbox\Memcd::getIpAddress($GLOBALS['MEMCD_HOST_NAME']);
|
$host = loadClass('Memcd')->getIpAddress();
|
||||||
$succ = \devilbox\Memcd::testConnection($error, $host);
|
$succ = loadClass('Memcd')->canConnect($error, $host);
|
||||||
$connection['Memcached'][$host] = array(
|
$connection['Memcached'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
'succ' => $succ
|
'succ' => $succ
|
||||||
);
|
);
|
||||||
$host = '127.0.0.1';
|
$host = '127.0.0.1';
|
||||||
$succ = \devilbox\Memcd::testConnection($error, $host);
|
$succ = loadClass('Memcd')->canConnect($error, $host);
|
||||||
$connection['Memcached'][$host] = array(
|
$connection['Memcached'][$host] = array(
|
||||||
'error' => $error,
|
'error' => $error,
|
||||||
'host' => $host,
|
'host' => $host,
|
||||||
@ -162,23 +150,22 @@ if ($avail_memcd) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- BIND ----
|
// ---- BIND (required)----
|
||||||
if ($avail_dns) {
|
$host = $GLOBALS['DNS_HOST_NAME'];
|
||||||
$host = $GLOBALS['DNS_HOST_NAME'];
|
$succ = loadClass('Dns')->canConnect($error, $host);
|
||||||
$succ = \devilbox\Dns::testConnection($error, $host);
|
$connection['Bind'][$host] = array(
|
||||||
$connection['Bind'][$host] = array(
|
'error' => $error,
|
||||||
'error' => $error,
|
'host' => $host,
|
||||||
'host' => $host,
|
'succ' => $succ
|
||||||
'succ' => $succ
|
);
|
||||||
);
|
$host = loadClass('Dns')->getIpAddress();
|
||||||
$host = \devilbox\Dns::getIpAddress($GLOBALS['DNS_HOST_NAME']);
|
$succ = loadClass('Dns')->canConnect($error, $host);
|
||||||
$succ = \devilbox\Dns::testConnection($error, $host);
|
$connection['Bind'][$host] = array(
|
||||||
$connection['Bind'][$host] = array(
|
'error' => $error,
|
||||||
'error' => $error,
|
'host' => $host,
|
||||||
'host' => $host,
|
'succ' => $succ
|
||||||
'succ' => $succ
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
* Test Health
|
* Test Health
|
||||||
@ -197,107 +184,20 @@ foreach ($connection as $docker) {
|
|||||||
$HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
|
$HEALTH_PERCENT = 100 - ceil(100 * $HEALTH_FAILS / $HEALTH_TOTAL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* F U N C T I O N S
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
function getCirle($name) {
|
|
||||||
switch ($name) {
|
|
||||||
case 'dns':
|
|
||||||
$class = 'bg-info';
|
|
||||||
$version = loadClass('Dns')->getVersion();
|
|
||||||
$available = $GLOBALS['avail_'.$name];
|
|
||||||
$name = loadClass('Dns')->getName();
|
|
||||||
break;
|
|
||||||
case 'php':
|
|
||||||
$class = 'bg-info';
|
|
||||||
$version = loadClass('Php')->getVersion();
|
|
||||||
$available = $GLOBALS['avail_'.$name];
|
|
||||||
$name = loadClass('Php')->getName();
|
|
||||||
break;
|
|
||||||
case 'httpd':
|
|
||||||
$class = 'bg-info';
|
|
||||||
$version = loadClass('Httpd')->getVersion();
|
|
||||||
$available = $GLOBALS['avail_'.$name];
|
|
||||||
$name = loadClass('Httpd')->getName();
|
|
||||||
break;
|
|
||||||
case 'mysql':
|
|
||||||
$class = 'bg-warning';
|
|
||||||
$version = loadClass('Mysql')->getVersion();
|
|
||||||
$available = $GLOBALS['avail_'.$name];
|
|
||||||
$name = loadClass('Mysql')->getName();
|
|
||||||
break;
|
|
||||||
case 'pgsql':
|
|
||||||
$class = 'bg-warning';
|
|
||||||
$version = loadClass('Pgsql')->getVersion();
|
|
||||||
$available = $GLOBALS['avail_'.$name];
|
|
||||||
$name = loadClass('Pgsql')->getName();
|
|
||||||
break;
|
|
||||||
case 'redis':
|
|
||||||
$class = 'bg-danger';
|
|
||||||
$version = loadClass('Redis')->getVersion();
|
|
||||||
$available = $GLOBALS['avail_'.$name];
|
|
||||||
$name = loadClass('Redis')->getName();
|
|
||||||
break;
|
|
||||||
case 'memcd':
|
|
||||||
$class = 'bg-danger';
|
|
||||||
$version = loadClass('Memcd')->getVersion();
|
|
||||||
$available = $GLOBALS['avail_'.$name];
|
|
||||||
$name = loadClass('Memcd')->getName();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$available = false;
|
|
||||||
$version = '';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$style = 'color:black;';
|
|
||||||
$version = '('.$version.')';
|
|
||||||
if (!$available) {
|
|
||||||
$class = '';
|
|
||||||
$style = 'background-color:gray;';
|
|
||||||
$version = ' ';
|
|
||||||
}
|
|
||||||
$circle = '<div class="circles">'.
|
|
||||||
'<div>'.
|
|
||||||
'<div class="'.$class.'" style="'.$style.'">'.
|
|
||||||
'<div>'.
|
|
||||||
'<div><br/><strong>'.$name.'</strong><br/><small style="color:#333333">'.$version.'</small></div>'.
|
|
||||||
'</div>'.
|
|
||||||
'</div>'.
|
|
||||||
'</div>'.
|
|
||||||
'</div>';
|
|
||||||
return $circle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* H T M L
|
* H T M L
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php $FONT_AWESOME = TRUE; require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(true); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body style="background: #1f1f1f;">
|
<body style="background: #1f1f1f;">
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -347,13 +247,13 @@ function getCirle($name) {
|
|||||||
<div class="dash-box-body">
|
<div class="dash-box-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||||
<?php echo getCirle('dns'); ?>
|
<?php echo loadClass('Html')->getCirle('dns'); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||||
<?php echo getCirle('php'); ?>
|
<?php echo loadClass('Html')->getCirle('php'); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||||
<?php echo getCirle('httpd'); ?>
|
<?php echo loadClass('Html')->getCirle('httpd'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -366,10 +266,10 @@ function getCirle($name) {
|
|||||||
<div class="dash-box-body">
|
<div class="dash-box-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||||
<?php echo getCirle('mysql'); ?>
|
<?php echo loadClass('Html')->getCirle('mysql'); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||||
<?php echo getCirle('pgsql'); ?>
|
<?php echo loadClass('Html')->getCirle('pgsql'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -382,13 +282,13 @@ function getCirle($name) {
|
|||||||
<div class="dash-box-body">
|
<div class="dash-box-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||||
<?php echo getCirle('redis'); ?>
|
<?php echo loadClass('Html')->getCirle('redis'); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||||
<?php echo getCirle('memcd'); ?>
|
<?php echo loadClass('Html')->getCirle('memcd'); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 col-xs-4" style="margin-bottom:15px;">
|
||||||
<?php echo getCirle('mongodb'); ?>
|
<?php echo loadClass('Html')->getCirle('mongodb'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -425,7 +325,7 @@ function getCirle($name) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>vHost TLD</th>
|
<th>vHost TLD</th>
|
||||||
<td>*.<?php echo loadClass('Php')->getTldSuffix(); ?></td>
|
<td>*.<?php echo loadClass('Httpd')->getTldSuffix(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>DNS</th>
|
<th>DNS</th>
|
||||||
@ -433,39 +333,39 @@ function getCirle($name) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Postfix</th>
|
<th>Postfix</th>
|
||||||
<td><?php echo $Docker->getEnv('ENABLE_MAIL') ? 'Enabled' : '<span class="bg-danger">No</span> Disabled';?></td>
|
<td><?php echo loadClass('Helper')->getEnv('ENABLE_MAIL') ? 'Enabled' : '<span class="bg-danger">No</span> Disabled';?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Xdebug</th>
|
<th>Xdebug</th>
|
||||||
<td>
|
<td>
|
||||||
<?php $Xdebug = ($Docker->getEnv('PHP_XDEBUG_ENABLE') == 0) ? '' : $Docker->getEnv('PHP_XDEBUG_ENABLE'); ?>
|
<?php $Xdebug = (loadClass('Helper')->getEnv('PHP_XDEBUG_ENABLE') == 0) ? '' : loadClass('Helper')->getEnv('PHP_XDEBUG_ENABLE'); ?>
|
||||||
<?php if ($Xdebug == $Docker->PHP_config('xdebug.remote_enable')): ?>
|
<?php if ($Xdebug == loadClass('Php')->getConfig('xdebug.remote_enable')): ?>
|
||||||
<?php echo $Docker->PHP_config('xdebug.remote_enable') == 1 ? 'Yes' : 'No'; ?>
|
<?php echo loadClass('Php')->getConfig('xdebug.remote_enable') == 1 ? 'Yes' : 'No'; ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php echo '<span class="text-danger">not installed</span>.env file setting differs from custom php .ini file</span><br/>'; ?>
|
<?php echo '<span class="text-danger">not installed</span>.env file setting differs from custom php .ini file</span><br/>'; ?>
|
||||||
<?php echo 'Effective setting: '.$Docker->PHP_config('xdebug.remote_enable'); ?>
|
<?php echo 'Effective setting: '.loadClass('Php')->getConfig('xdebug.remote_enable'); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Xdebug Remote</th>
|
<th>Xdebug Remote</th>
|
||||||
<td>
|
<td>
|
||||||
<?php if ($Docker->getEnv('PHP_XDEBUG_REMOTE_HOST') == $Docker->PHP_config('xdebug.remote_host')): ?>
|
<?php if (loadClass('Helper')->getEnv('PHP_XDEBUG_REMOTE_HOST') == loadClass('Php')->getConfig('xdebug.remote_host')): ?>
|
||||||
<?php echo $Docker->PHP_config('xdebug.remote_host'); ?>
|
<?php echo loadClass('Php')->getConfig('xdebug.remote_host'); ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php echo '<span class="text-danger">not installed</span>.env file setting differs from custom php .ini file</span><br/>'; ?>
|
<?php echo '<span class="text-danger">not installed</span>.env file setting differs from custom php .ini file</span><br/>'; ?>
|
||||||
<?php echo 'Effective setting: '.$Docker->PHP_config('xdebug.remote_host'); ?>
|
<?php echo 'Effective setting: '.loadClass('Php')->getConfig('xdebug.remote_host'); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Xdebug Port</th>
|
<th>Xdebug Port</th>
|
||||||
<td>
|
<td>
|
||||||
<?php if ($Docker->getEnv('PHP_XDEBUG_REMOTE_PORT') == $Docker->PHP_config('xdebug.remote_port')): ?>
|
<?php if (loadClass('Helper')->getEnv('PHP_XDEBUG_REMOTE_PORT') == loadClass('Php')->getConfig('xdebug.remote_port')): ?>
|
||||||
<?php echo $Docker->PHP_config('xdebug.remote_port'); ?>
|
<?php echo loadClass('Php')->getConfig('xdebug.remote_port'); ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php echo '<span class="text-danger">not installed</span>.env file setting differs from custom php .ini file</span><br/>'; ?>
|
<?php echo '<span class="text-danger">not installed</span>.env file setting differs from custom php .ini file</span><br/>'; ?>
|
||||||
<?php echo 'Effective setting: '.$Docker->PHP_config('xdebug.remote_port'); ?>
|
<?php echo 'Effective setting: '.loadClass('Php')->getConfig('xdebug.remote_port'); ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -581,46 +481,46 @@ function getCirle($name) {
|
|||||||
<tr>
|
<tr>
|
||||||
<th>php</th>
|
<th>php</th>
|
||||||
<td><?php echo $GLOBALS['PHP_HOST_NAME']; ?></td>
|
<td><?php echo $GLOBALS['PHP_HOST_NAME']; ?></td>
|
||||||
<td><?php echo \devilbox\Php::getIpAddress($GLOBALS['PHP_HOST_NAME']); ?></td>
|
<td><?php echo loadClass('Php')->getIpAddress(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>httpd</th>
|
<th>httpd</th>
|
||||||
<td><?php echo $GLOBALS['HTTPD_HOST_NAME']; ?></td>
|
<td><?php echo $GLOBALS['HTTPD_HOST_NAME']; ?></td>
|
||||||
<td><?php echo \devilbox\Httpd::getIpAddress($GLOBALS['HTTPD_HOST_NAME']); ?></td>
|
<td><?php echo loadClass('Httpd')->getIpAddress(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($avail_mysql): ?>
|
<?php if ($avail_mysql): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>mysql</th>
|
<th>mysql</th>
|
||||||
<td><?php echo $GLOBALS['MYSQL_HOST_NAME']; ?></td>
|
<td><?php echo $GLOBALS['MYSQL_HOST_NAME']; ?></td>
|
||||||
<td><?php echo \devilbox\Mysql::getIpAddress($GLOBALS['MYSQL_HOST_NAME']); ?></td>
|
<td><?php echo loadClass('Mysql')->getIpAddress(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_pgsql): ?>
|
<?php if ($avail_pgsql): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>pgsql</th>
|
<th>pgsql</th>
|
||||||
<td><?php echo $GLOBALS['PGSQL_HOST_NAME']; ?></td>
|
<td><?php echo $GLOBALS['PGSQL_HOST_NAME']; ?></td>
|
||||||
<td><?php echo \devilbox\Pgsql::getIpAddress($GLOBALS['PGSQL_HOST_NAME']); ?></td>
|
<td><?php echo loadClass('Pgsql')->getIpAddress(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_redis): ?>
|
<?php if ($avail_redis): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>redis</th>
|
<th>redis</th>
|
||||||
<td><?php echo $GLOBALS['REDIS_HOST_NAME']; ?></td>
|
<td><?php echo $GLOBALS['REDIS_HOST_NAME']; ?></td>
|
||||||
<td><?php echo \devilbox\Redis::getIpAddress($GLOBALS['REDIS_HOST_NAME']); ?></td>
|
<td><?php echo loadClass('Redis')->getIpAddress(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_memcd): ?>
|
<?php if ($avail_memcd): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>memcached</th>
|
<th>memcached</th>
|
||||||
<td><?php echo $GLOBALS['MEMCD_HOST_NAME']; ?></td>
|
<td><?php echo $GLOBALS['MEMCD_HOST_NAME']; ?></td>
|
||||||
<td><?php echo \devilbox\Memcd::getIpAddress($GLOBALS['MEMCD_HOST_NAME']); ?></td>
|
<td><?php echo loadClass('Memcd')->getIpAddress(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_dns): ?>
|
<?php if ($avail_dns): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>bind</th>
|
<th>bind</th>
|
||||||
<td><?php echo $GLOBALS['DNS_HOST_NAME']; ?></td>
|
<td><?php echo $GLOBALS['DNS_HOST_NAME']; ?></td>
|
||||||
<td><?php echo \devilbox\Dns::getIpAddress($GLOBALS['DNS_HOST_NAME']); ?></td>
|
<td><?php echo loadClass('Dns')->getIpAddress(); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -653,34 +553,34 @@ function getCirle($name) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>httpd</th>
|
<th>httpd</th>
|
||||||
<td><?php echo loadClass('Docker')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Docker')->getEnv('HOST_PORT_HTTPD');?></td>
|
<td><?php echo loadClass('Helper')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Helper')->getEnv('HOST_PORT_HTTPD');?></td>
|
||||||
<td>80</td>
|
<td>80</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($avail_mysql): ?>
|
<?php if ($avail_mysql): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>mysql</th>
|
<th>mysql</th>
|
||||||
<td><?php echo loadClass('Docker')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Docker')->getEnv('HOST_PORT_MYSQL');?></td>
|
<td><?php echo loadClass('Helper')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Helper')->getEnv('HOST_PORT_MYSQL');?></td>
|
||||||
<td>3306</td>
|
<td>3306</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_pgsql): ?>
|
<?php if ($avail_pgsql): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>pgsql</th>
|
<th>pgsql</th>
|
||||||
<td><?php echo loadClass('Docker')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Docker')->getEnv('HOST_PORT_PGSQL');?></td>
|
<td><?php echo loadClass('Helper')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Helper')->getEnv('HOST_PORT_PGSQL');?></td>
|
||||||
<td>5432</td>
|
<td>5432</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_redis): ?>
|
<?php if ($avail_redis): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>redis</th>
|
<th>redis</th>
|
||||||
<td><?php echo loadClass('Docker')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Docker')->getEnv('HOST_PORT_REDIS');?></td>
|
<td><?php echo loadClass('Helper')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Helper')->getEnv('HOST_PORT_REDIS');?></td>
|
||||||
<td>6379</td>
|
<td>6379</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_memcd): ?>
|
<?php if ($avail_memcd): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>memcached</th>
|
<th>memcached</th>
|
||||||
<td><?php echo loadClass('Docker')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Docker')->getEnv('HOST_PORT_MEMCACHED');?></td>
|
<td><?php echo loadClass('Helper')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Helper')->getEnv('HOST_PORT_MEMCACHED');?></td>
|
||||||
<td>11211</td>
|
<td>11211</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@ -688,8 +588,8 @@ function getCirle($name) {
|
|||||||
<tr>
|
<tr>
|
||||||
<th>bind</th>
|
<th>bind</th>
|
||||||
<td>
|
<td>
|
||||||
<?php echo loadClass('Docker')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Docker')->getEnv('HOST_PORT_BIND');?>/tcp<br/>
|
<?php echo loadClass('Helper')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Helper')->getEnv('HOST_PORT_BIND');?>/tcp<br/>
|
||||||
<?php echo loadClass('Docker')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Docker')->getEnv('HOST_PORT_BIND');?>/udp
|
<?php echo loadClass('Helper')->getEnv('LOCAL_LISTEN_ADDR').loadClass('Helper')->getEnv('HOST_PORT_BIND');?>/udp
|
||||||
</td>
|
</td>
|
||||||
<td>53/tcp<br/>53/udp</td>
|
<td>53/tcp<br/>53/udp</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -761,25 +661,25 @@ function getCirle($name) {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th>php</th>
|
<th>php</th>
|
||||||
<td><?php echo loadClass('Docker')->getEnv('HOST_PATH_HTTPD_DATADIR'); ?></td>
|
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_HTTPD_DATADIR'); ?></td>
|
||||||
<td>/shared/httpd</td>
|
<td>/shared/httpd</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>httpd</th>
|
<th>httpd</th>
|
||||||
<td><?php echo loadClass('Docker')->getEnv('HOST_PATH_HTTPD_DATADIR'); ?></td>
|
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_HTTPD_DATADIR'); ?></td>
|
||||||
<td>/shared/httpd</td>
|
<td>/shared/httpd</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($avail_mysql): ?>
|
<?php if ($avail_mysql): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>mysql</th>
|
<th>mysql</th>
|
||||||
<td><?php echo loadClass('Docker')->getEnv('HOST_PATH_MYSQL_DATADIR').'/'.loadClass('Docker')->getEnv('MYSQL_SERVER'); ?></td>
|
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_MYSQL_DATADIR').'/'.loadClass('Helper')->getEnv('MYSQL_SERVER'); ?></td>
|
||||||
<td>/var/lib/mysql</td>
|
<td>/var/lib/mysql</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_pgsql): ?>
|
<?php if ($avail_pgsql): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>pgsql</th>
|
<th>pgsql</th>
|
||||||
<td><?php echo loadClass('Docker')->getEnv('HOST_PATH_PGSQL_DATADIR').'/'.loadClass('Docker')->getEnv('PGSQL_SERVER'); ?></td>
|
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_PGSQL_DATADIR').'/'.loadClass('Helper')->getEnv('PGSQL_SERVER'); ?></td>
|
||||||
<td>/var/lib/postgresql/data/pgdata</td>
|
<td>/var/lib/postgresql/data/pgdata</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@ -829,7 +729,7 @@ function getCirle($name) {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th>php</th>
|
<th>php</th>
|
||||||
<td>./cfg/<?php echo loadClass('Docker')->getEnv('PHP_SERVER'); ?></td>
|
<td>./cfg/<?php echo loadClass('Helper')->getEnv('PHP_SERVER'); ?></td>
|
||||||
<td>/etc/php-custom.d</td>
|
<td>/etc/php-custom.d</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -840,7 +740,7 @@ function getCirle($name) {
|
|||||||
<?php if ($avail_mysql): ?>
|
<?php if ($avail_mysql): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>mysql</th>
|
<th>mysql</th>
|
||||||
<td>./cfg/<?php echo loadClass('Docker')->getEnv('MYSQL_SERVER'); ?></td>
|
<td>./cfg/<?php echo loadClass('Helper')->getEnv('MYSQL_SERVER'); ?></td>
|
||||||
<td>/etc/mysql/conf.d</td>
|
<td>/etc/mysql/conf.d</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@ -897,39 +797,39 @@ function getCirle($name) {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th>php</th>
|
<th>php</th>
|
||||||
<td>./log/<?php echo loadClass('Docker')->getEnv('PHP_SERVER'); ?></td>
|
<td>./log/<?php echo loadClass('Helper')->getEnv('PHP_SERVER'); ?></td>
|
||||||
<td>/var/log/php</td>
|
<td>/var/log/php</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>httpd</th>
|
<th>httpd</th>
|
||||||
<td>./log/<?php echo loadClass('Docker')->getEnv('HTTPD_SERVER'); ?></td>
|
<td>./log/<?php echo loadClass('Helper')->getEnv('HTTPD_SERVER'); ?></td>
|
||||||
<td>/var/log/<?php echo loadClass('Docker')->getEnv('HTTPD_SERVER'); ?></td>
|
<td>/var/log/<?php echo loadClass('Helper')->getEnv('HTTPD_SERVER'); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if ($avail_mysql): ?>
|
<?php if ($avail_mysql): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>mysql</th>
|
<th>mysql</th>
|
||||||
<td>./log/<?php echo loadClass('Docker')->getEnv('MYSQL_SERVER'); ?></td>
|
<td>./log/<?php echo loadClass('Helper')->getEnv('MYSQL_SERVER'); ?></td>
|
||||||
<td>/var/log/mysql</td>
|
<td>/var/log/mysql</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_pgsql): ?>
|
<?php if ($avail_pgsql): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>pgsql</th>
|
<th>pgsql</th>
|
||||||
<td>./log/pgsql-<?php echo loadClass('Docker')->getEnv('PGSQL_SERVER'); ?></td>
|
<td>./log/pgsql-<?php echo loadClass('Helper')->getEnv('PGSQL_SERVER'); ?></td>
|
||||||
<td>/var/log/postgresql</td>
|
<td>/var/log/postgresql</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_redis): ?>
|
<?php if ($avail_redis): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>redis</th>
|
<th>redis</th>
|
||||||
<td>./log/redis-<?php echo loadClass('Docker')->getEnv('REDIS_SERVER'); ?></td>
|
<td>./log/redis-<?php echo loadClass('Helper')->getEnv('REDIS_SERVER'); ?></td>
|
||||||
<td>/var/log/redis</td>
|
<td>/var/log/redis</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($avail_memcd): ?>
|
<?php if ($avail_memcd): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>memcached</th>
|
<th>memcached</th>
|
||||||
<td>./log/memcached-<?php echo loadClass('Docker')->getEnv('MEMCACHED_SERVER'); ?></td>
|
<td>./log/memcached-<?php echo loadClass('Helper')->getEnv('MEMCACHED_SERVER'); ?></td>
|
||||||
<td>/var/log/memcached</td>
|
<td>/var/log/memcached</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@ -954,7 +854,7 @@ function getCirle($name) {
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
<script>
|
<script>
|
||||||
// self executing function here
|
// self executing function here
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $Postgres = loadClass('Memcd'); ?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -18,7 +17,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<?php if (!\devilbox\Memcd::isAvailable($GLOBALS['MEMCD_HOST_NAME'])): ?>
|
<?php if (!loadClass('Memcd')->isAvailable()): ?>
|
||||||
<p>Memcahed container is not running.</p>
|
<p>Memcahed container is not running.</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php foreach (loadClass('Memcd')->getInfo() as $srv => $data): ?>
|
<?php foreach (loadClass('Memcd')->getInfo() as $srv => $data): ?>
|
||||||
@ -47,6 +46,6 @@
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $MySQL = loadClass('Mysql'); ?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -18,7 +17,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<?php if (!\devilbox\Mysql::isAvailable($GLOBALS['MYSQL_HOST_NAME'])): ?>
|
<?php if (!loadClass('Mysql')->isAvailable()): ?>
|
||||||
<p>MySQL container is not running.</p>
|
<p>MySQL container is not running.</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p>For reference see here:</p>
|
<p>For reference see here:</p>
|
||||||
@ -51,6 +50,6 @@
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $Postgres = loadClass('Pgsql'); ?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -18,7 +17,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<?php if (!\devilbox\Pgsql::isAvailable($GLOBALS['PGSQL_HOST_NAME'])): ?>
|
<?php if (!loadClass('Pgsql')->isAvailable()): ?>
|
||||||
<p>PgSQL container is not running.</p>
|
<p>PgSQL container is not running.</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
@ -44,6 +43,6 @@
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -21,6 +21,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $Postgres = loadClass('Redis'); ?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -18,7 +17,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
||||||
<?php if (!\devilbox\Redis::isAvailable($GLOBALS['REDIS_HOST_NAME'])): ?>
|
<?php if (!loadClass('Redis')->isAvailable()): ?>
|
||||||
<p>Redis container is not running.</p>
|
<p>Redis container is not running.</p>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
@ -44,6 +43,6 @@
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -78,11 +78,11 @@ $messages = $MyMbox->get($sortOrderArr);
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php $FONT_AWESOME = TRUE; require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(true); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Mail</h1>
|
<h1>Mail</h1>
|
||||||
@ -179,7 +179,7 @@ $messages = $MyMbox->get($sortOrderArr);
|
|||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
$('.subject').each(function() {
|
$('.subject').each(function() {
|
||||||
|
@ -230,7 +230,7 @@ $opcache = OpCacheService::init($options);
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); /* devilbox edit */ ?>
|
||||||
|
|
||||||
|
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
@ -321,7 +321,7 @@ $opcache = OpCacheService::init($options);
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); /* devilbox edit */?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -766,6 +766,6 @@ $opcache = OpCacheService::init($options);
|
|||||||
var filesObj = ReactDOM.render(React.createElement(Files, null), document.getElementById('filelist'));
|
var filesObj = ReactDOM.render(React.createElement(Files, null), document.getElementById('filelist'));
|
||||||
ReactDOM.render(React.createElement(Directives, null), document.getElementById('directives'));
|
ReactDOM.render(React.createElement(Directives, null), document.getElementById('directives'));
|
||||||
</script>
|
</script>
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); /* devilbox edit */?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
File diff suppressed because one or more lines are too long
4
.devilbox/www/htdocs/vendor/jquery/jquery-3.2.1.min.js
vendored
Normal file
4
.devilbox/www/htdocs/vendor/jquery/jquery-3.2.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,13 +1,12 @@
|
|||||||
<?php require '../config.php'; ?>
|
<?php require '../config.php'; ?>
|
||||||
<?php $Docker = loadClass('Docker'); ?>
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<?php require '../include/head.php'; ?>
|
<?php echo loadClass('Html')->getHead(); ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php require '../include/navbar.php'; ?>
|
<?php echo loadClass('Html')->getNavbar(); ?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
@ -17,7 +16,7 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<?php $vHosts = $Docker->PHP_getVirtualHosts(); ?>
|
<?php $vHosts = loadClass('Httpd')->getVirtualHosts(); ?>
|
||||||
<?php if ($vHosts): ?>
|
<?php if ($vHosts): ?>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead class="thead-inverse">
|
<thead class="thead-inverse">
|
||||||
@ -39,7 +38,7 @@
|
|||||||
<?php foreach ($vHosts as $vHost): ?>
|
<?php foreach ($vHosts as $vHost): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $vHost['name'];?></td>
|
<td><?php echo $vHost['name'];?></td>
|
||||||
<td><?php echo $Docker->getEnv('HOST_PATH_HTTPD_DATADIR');?>/<?php echo $vHost['name'];?>/htdocs</td>
|
<td><?php echo loadClass('Helper')->getEnv('HOST_PATH_HTTPD_DATADIR');?>/<?php echo $vHost['name'];?>/htdocs</td>
|
||||||
<td class="text-xs-center text-xs-small" id="valid-<?php echo $vHost['name'];?>"> </td>
|
<td class="text-xs-center text-xs-small" id="valid-<?php echo $vHost['name'];?>"> </td>
|
||||||
<td id="href-<?php echo $vHost['name'];?>"><?php echo $filler;?></td>
|
<td id="href-<?php echo $vHost['name'];?>"><?php echo $filler;?></td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -49,16 +48,16 @@
|
|||||||
</table>
|
</table>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<h4>No projects here.</h4>
|
<h4>No projects here.</h4>
|
||||||
<p>Simply create a directory in <strong><?php echo $Docker->getEnv('HOST_PATH_HTTPD_DATADIR');?></strong> on your host computer (or in <strong>/shared/httpd</strong> inside the php container).</p>
|
<p>Simply create a directory in <strong><?php echo loadClass('Helper')->getEnv('HOST_PATH_HTTPD_DATADIR');?></strong> on your host computer (or in <strong>/shared/httpd</strong> inside the php container).</p>
|
||||||
<p><strong>Example:</strong><br/><?php echo $Docker->getEnv('HOST_PATH_HTTPD_DATADIR');?>/my_project</p>
|
<p><strong>Example:</strong><br/><?php echo loadClass('Helper')->getEnv('HOST_PATH_HTTPD_DATADIR');?>/my_project</p>
|
||||||
<p>It will then be available via <strong>http://my_project.<?php echo loadClass('Php')->getTldSuffix();?></strong></p>
|
<p>It will then be available via <strong>http://my_project.<?php echo loadClass('Httpd')->getTldSuffix();?></strong></p>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div><!-- /.container -->
|
</div><!-- /.container -->
|
||||||
|
|
||||||
<?php require '../include/footer.php'; ?>
|
<?php echo loadClass('Html')->getFooter(); ?>
|
||||||
<script>
|
<script>
|
||||||
// self executing function here
|
// self executing function here
|
||||||
(function() {
|
(function() {
|
||||||
@ -100,7 +99,7 @@
|
|||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
|
|
||||||
// Timeout after XXX seconds and mark it invalid DNS
|
// Timeout after XXX seconds and mark it invalid DNS
|
||||||
xhttp.timeout = <?php echo loadClass('Docker')->getEnv('DNS_CHECK_TIMEOUT');?>000;
|
xhttp.timeout = <?php echo loadClass('Helper')->getEnv('DNS_CHECK_TIMEOUT');?>000;
|
||||||
|
|
||||||
xhttp.onreadystatechange = function(e) {
|
xhttp.onreadystatechange = function(e) {
|
||||||
var el_valid = document.getElementById('valid-' + vhost);
|
var el_valid = document.getElementById('valid-' + vhost);
|
||||||
@ -111,23 +110,24 @@
|
|||||||
clearTimeout(xmlHttpTimeout);
|
clearTimeout(xmlHttpTimeout);
|
||||||
el_valid.className += ' bg-success';
|
el_valid.className += ' bg-success';
|
||||||
el_valid.innerHTML = 'OK';
|
el_valid.innerHTML = 'OK';
|
||||||
el_href.innerHTML = '<a target="_blank" href="http://'+vhost+'.<?php echo loadClass('Php')->getTldSuffix().$Docker->getPort();?>">'+vhost+'.<?php echo loadClass('Php')->getTldSuffix().$Docker->getPort();?></a>';
|
el_href.innerHTML = '<a target="_blank" href="http://'+vhost+'.<?php echo loadClass('Httpd')->getTldSuffix().loadClass('Httpd')->getPort();?>">'+vhost+'.<?php echo loadClass('Httpd')->getTldSuffix().loadClass('Httpd')->getPort();?></a>';
|
||||||
} else {
|
} else {
|
||||||
//console.log(vhost);
|
//console.log(vhost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhttp.open('GET', 'http://'+vhost+'.<?php echo loadClass('Php')->getTldSuffix();?>/devilbox-api/status.json', true);
|
xhttp.open('GET', 'http://'+vhost+'.<?php echo loadClass('Httpd')->getTldSuffix();?>/devilbox-api/status.json', true);
|
||||||
xhttp.send();
|
xhttp.send();
|
||||||
|
|
||||||
// Timeout to abort in 1 second
|
// Timeout to abort in 1 second
|
||||||
var xmlHttpTimeout=setTimeout(ajaxTimeout, <?php echo loadClass('Docker')->getEnv('DNS_CHECK_TIMEOUT');?>000);
|
var xmlHttpTimeout = setTimeout(ajaxTimeout, <?php echo loadClass('Helper')->getEnv('DNS_CHECK_TIMEOUT');?>000);
|
||||||
function ajaxTimeout(e){
|
function ajaxTimeout(e) {
|
||||||
var el_valid = document.getElementById('valid-' + vhost);
|
var el_valid = document.getElementById('valid-' + vhost);
|
||||||
var el_href = document.getElementById('href-' + vhost);
|
var el_href = document.getElementById('href-' + vhost);
|
||||||
var error = this.responseText;
|
var error = this.responseText;
|
||||||
|
|
||||||
el_valid.className += ' bg-danger';
|
el_valid.className += ' bg-danger';
|
||||||
el_valid.innerHTML = 'ERR';
|
el_valid.innerHTML = 'ERR';
|
||||||
el_href.innerHTML = 'No DNS record found: <code>127.0.0.1 '+vhost+'.<?php echo loadClass('Php')->getTldSuffix();?></code>';
|
el_href.innerHTML = 'No DNS record found: <code>127.0.0.1 '+vhost+'.<?php echo loadClass('Httpd')->getTldSuffix();?></code>';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,123 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace devilbox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires devilbox::Logger
|
|
||||||
*/
|
|
||||||
class Dns extends _Base implements _iBase
|
|
||||||
{
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Statics
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dns instance
|
|
||||||
* @var Dns|null
|
|
||||||
*/
|
|
||||||
protected static $instance = null;
|
|
||||||
|
|
||||||
private static $_available = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton Instance getter.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
* @return object|null
|
|
||||||
*/
|
|
||||||
public static function getInstance($host = null, $user = null, $pass = null)
|
|
||||||
{
|
|
||||||
if (!isset(static::$instance)) {
|
|
||||||
static::$instance = new static();
|
|
||||||
}
|
|
||||||
return static::$instance;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @overwrite
|
|
||||||
* @param string $hostname [description]
|
|
||||||
* @return boolean [description]
|
|
||||||
*/
|
|
||||||
public static function isAvailable($hostname)
|
|
||||||
{
|
|
||||||
if (self::$_available === null) {
|
|
||||||
|
|
||||||
$output = '';
|
|
||||||
$exit_code = -1;
|
|
||||||
$cmd = 'dig +time=1 +tries=1 @172.16.238.100 version.bind chaos TXT';
|
|
||||||
exec($cmd, $output, $exit_code);
|
|
||||||
|
|
||||||
self::$_available[$hostname] = ($exit_code != 0) ? false : true;
|
|
||||||
|
|
||||||
}
|
|
||||||
return self::$_available;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to Httpd
|
|
||||||
*
|
|
||||||
* @param string $err Reference to error message
|
|
||||||
* @param string $host Redis hostname
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function testConnection(&$err, $host, $user = '', $pass = '')
|
|
||||||
{
|
|
||||||
return self::isAvailable($host);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Construct/Destructor
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use singleton getInstance() instead.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Interface required functions
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
public function getName($default = 'Bind')
|
|
||||||
{
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVersion()
|
|
||||||
{
|
|
||||||
$output = '';
|
|
||||||
$exit_code = -1;
|
|
||||||
$cmd = 'dig +time=1 +tries=1 @172.16.238.100 version.bind chaos TXT | grep -iE "^version\.bind.*TXT"';
|
|
||||||
|
|
||||||
exec($cmd, $output, $exit_code);
|
|
||||||
|
|
||||||
$version = $this->egrep('/"[0-9.-]+.*"/', isset($output[0]) ? $output[0] : '');
|
|
||||||
$version = $this->egrep('/[0-9.-]+/', $version);
|
|
||||||
$version = $version ? $version : '';
|
|
||||||
return $version;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,350 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace devilbox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires devilbox::Logger
|
|
||||||
* @requires devilbox::Mysql
|
|
||||||
*/
|
|
||||||
class Docker
|
|
||||||
{
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Statics
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* $this Singleton instance
|
|
||||||
* @var Object|null
|
|
||||||
*/
|
|
||||||
protected static $instance = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton Instance getter.
|
|
||||||
*
|
|
||||||
* @return object|null
|
|
||||||
*/
|
|
||||||
public static function getInstance()
|
|
||||||
{
|
|
||||||
if (!isset(static::$instance)) {
|
|
||||||
static::$instance = new static();
|
|
||||||
}
|
|
||||||
return static::$instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Private Variables
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Array of docker environment variables
|
|
||||||
* @var mixed[]
|
|
||||||
*/
|
|
||||||
private $_env = array();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Document root path in PHP docker
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_doc_root = '/shared/httpd';
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Construct/Destructor
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private Constructor, so nobody can call it.
|
|
||||||
* Use singleton getInstance() instead.
|
|
||||||
*/
|
|
||||||
private function __construct()
|
|
||||||
{
|
|
||||||
// Do not call me
|
|
||||||
|
|
||||||
// Translate Docker environmental variables to $ENV
|
|
||||||
exec('env', $output);
|
|
||||||
|
|
||||||
foreach ($output as $var) {
|
|
||||||
$tmp = explode('=', $var);
|
|
||||||
$this->_env[$tmp[0]] = $tmp[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Public functions
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Docker environment variables from docker-compose.yml
|
|
||||||
* @param string $variable Variable name
|
|
||||||
* @return string Variable value
|
|
||||||
*/
|
|
||||||
public function getEnv($variable)
|
|
||||||
{
|
|
||||||
if (!isset($this->_env[$variable])) {
|
|
||||||
loadClass('Logger')->error('Docker environment variable not found: '.$variable);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $this->_env[$variable];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get HTTP port.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getPort()
|
|
||||||
{
|
|
||||||
$port = $this->getEnv('HOST_PORT_HTTPD');
|
|
||||||
|
|
||||||
if ( empty($port) ) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $port == 80 ) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return ":$port";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* PHP Docker functions
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read out PHP Server configuration by variable
|
|
||||||
*
|
|
||||||
* @param string|null $key Config key name
|
|
||||||
* @return string|mixed[]
|
|
||||||
*/
|
|
||||||
public function PHP_config($key = null)
|
|
||||||
{
|
|
||||||
// Get all configs as array
|
|
||||||
if ($key === null) {
|
|
||||||
return ini_get_all();
|
|
||||||
} else {
|
|
||||||
return ini_get($key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an array of custom mounted PHP config files.
|
|
||||||
*
|
|
||||||
* @return string[]
|
|
||||||
*/
|
|
||||||
public function PHP_custom_config_files()
|
|
||||||
{
|
|
||||||
$files = array();
|
|
||||||
|
|
||||||
foreach (scandir('/etc/php-custom.d') as $file) {
|
|
||||||
if (preg_match('/.*\.ini$/', $file) === 1) {
|
|
||||||
$files[] = $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $files;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if mounted MySQL socket is valid inside PHP Docker.
|
|
||||||
*
|
|
||||||
* @param string $error Reference to error message.
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function PHP_has_valid_mysql_socket(&$error)
|
|
||||||
{
|
|
||||||
if (!$this->getEnv('MOUNT_MYSQL_SOCKET_TO_LOCALDISK')) {
|
|
||||||
$error = 'Socket mount not enabled.';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file_exists($this->getEnv('MYSQL_SOCKET_PATH'))) {
|
|
||||||
$error = 'Socket file not found.';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (getMySQLConfigByKey('socket') != $ENV['MYSQL_SOCKET_PATH']) {
|
|
||||||
// $error = 'Mounted from mysql:'.$ENV['MYSQL_SOCKET_PATH']. ', but socket is in mysql:'.getMySQLConfigByKey('socket');
|
|
||||||
// return FALSE;
|
|
||||||
//}
|
|
||||||
|
|
||||||
$error = '';
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all mass virtual Hosts by directories
|
|
||||||
*
|
|
||||||
* @return mixed[]
|
|
||||||
*/
|
|
||||||
public function PHP_getVirtualHosts()
|
|
||||||
{
|
|
||||||
$docRoot = $this->_doc_root;
|
|
||||||
$vhosts = array();
|
|
||||||
|
|
||||||
if ($handle = opendir($docRoot)) {
|
|
||||||
while (false !== ($directory = readdir($handle))) {
|
|
||||||
if ($this->_is_valid_dir($docRoot . DIRECTORY_SEPARATOR . $directory) && $directory != '.' && $directory != '..') {
|
|
||||||
|
|
||||||
$vhosts[] = array(
|
|
||||||
'name' => $directory,
|
|
||||||
'domain' => $directory .'.' . $this->getEnv('TLD_SUFFIX'),
|
|
||||||
'href' => 'http://' . $directory . '.' . $this->getEnv('TLD_SUFFIX')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $vhosts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check single mass virtual host
|
|
||||||
*
|
|
||||||
* @param string $vhost Virtual Host name
|
|
||||||
* @return string Errors
|
|
||||||
*/
|
|
||||||
public function PHP_checkVirtualHost($vhost)
|
|
||||||
{
|
|
||||||
$docRoot = $this->_doc_root;
|
|
||||||
$htdocs = $docRoot . DIRECTORY_SEPARATOR . $vhost . DIRECTORY_SEPARATOR . 'htdocs';
|
|
||||||
$domain = $vhost . '.' . $this->getEnv('TLD_SUFFIX');
|
|
||||||
$url = 'http://'.$domain;
|
|
||||||
$error = array();
|
|
||||||
|
|
||||||
|
|
||||||
// 1. Check htdocs folder
|
|
||||||
if (!$this->_is_valid_dir($htdocs)) {
|
|
||||||
$error[] = 'Missing <strong>htdocs</strong> directory in: <strong>'.$this->getEnv('HOST_PATH_HTTPD_DATADIR').'/'.$vhost.'/</strong>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($GLOBALS['ENABLE_VHOST_DNS_CHECK']) {
|
|
||||||
|
|
||||||
// 2. Check /etc/resolv DNS entry
|
|
||||||
$output;
|
|
||||||
if ($this->_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 '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Postgres Docker functions
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read out PostgreSQL Server configuration by variable
|
|
||||||
*
|
|
||||||
* @param string|null $key Config key name
|
|
||||||
* @return string|mixed[]
|
|
||||||
*/
|
|
||||||
public function Postgres_config($key = null)
|
|
||||||
{
|
|
||||||
// Get all configs as array
|
|
||||||
if ($key === null) {
|
|
||||||
$callback = function ($row, &$data) {
|
|
||||||
$key = $row['name'];
|
|
||||||
$val = $row['setting'];
|
|
||||||
$data[$key] = $val;
|
|
||||||
};
|
|
||||||
|
|
||||||
$sql = 'SELECT name, setting FROM pg_settings;';
|
|
||||||
$configs = loadClass('Postgres')->select($sql, $callback);
|
|
||||||
|
|
||||||
return $configs ? $configs : array();
|
|
||||||
|
|
||||||
} else { // Get single config
|
|
||||||
|
|
||||||
$callback = function ($row, &$data) use ($key) {
|
|
||||||
$data = isset($row['setting']) ? $row['setting'] : false;
|
|
||||||
};
|
|
||||||
|
|
||||||
$sql = "SELECT name, setting FROM pg_settings WHERE name = '".$key."';";
|
|
||||||
$val = loadClass('Postgres')->select($sql, $callback);
|
|
||||||
|
|
||||||
return is_array($val) ? '' : $val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Private functions
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the directory exists or
|
|
||||||
* in case of a symlink the target is an
|
|
||||||
* existing directory.
|
|
||||||
*
|
|
||||||
* @param string $path The path.
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
private function _is_valid_dir($path)
|
|
||||||
{
|
|
||||||
return (is_dir($path) || (is_link($path) && is_dir(readlink($path))));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes shell commands on the PHP-FPM Host
|
|
||||||
*
|
|
||||||
* @param string $cmd Command
|
|
||||||
* @param string $output Reference to output
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
private function _exec($cmd, &$output = '')
|
|
||||||
{
|
|
||||||
// Clean output
|
|
||||||
$output = '';
|
|
||||||
exec($cmd, $output, $exit_code);
|
|
||||||
return $exit_code;
|
|
||||||
}
|
|
||||||
}
|
|
174
.devilbox/www/include/lib/Helper.php
Normal file
174
.devilbox/www/include/lib/Helper.php
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
namespace devilbox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires devilbox::Logger
|
||||||
|
*/
|
||||||
|
class Helper
|
||||||
|
{
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Statics
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Environmental variables from PHP docker
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $_env = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hostname to IP addresses
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $_ip_address = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class instance
|
||||||
|
* @var object
|
||||||
|
*/
|
||||||
|
private static $_instance = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic singleton instance getter.
|
||||||
|
* Make sure to overwrite this in your class
|
||||||
|
* for a more complex initialization.
|
||||||
|
*
|
||||||
|
* @param string $hostname Hostname
|
||||||
|
* @param array $data Additional data (if required)
|
||||||
|
* @return object|null
|
||||||
|
*/
|
||||||
|
public static function getInstance()
|
||||||
|
{
|
||||||
|
if (self::$_instance === null) {
|
||||||
|
self::$_instance = new self();
|
||||||
|
}
|
||||||
|
return self::$_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Private constructor for singleton
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT CALL ME!
|
||||||
|
* Use singleton getInstance() instead.
|
||||||
|
*/
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Public Helper Functions
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Docker environment variables from docker-compose.yml
|
||||||
|
* Only values from php docker can be retrieved here, so make
|
||||||
|
* sure they are passed to it.
|
||||||
|
*
|
||||||
|
* Values are cached in static context.
|
||||||
|
*
|
||||||
|
* @param string $variable Variable name
|
||||||
|
* @return string Variable value
|
||||||
|
*/
|
||||||
|
public function getEnv($variable)
|
||||||
|
{
|
||||||
|
if (self::$_env === null) {
|
||||||
|
|
||||||
|
$output = array();
|
||||||
|
|
||||||
|
// Translate PHP Docker environmental variables to $ENV
|
||||||
|
exec('env', $output);
|
||||||
|
|
||||||
|
foreach ($output as $var) {
|
||||||
|
$tmp = explode('=', $var);
|
||||||
|
self::$_env[$tmp[0]] = $tmp[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!isset(self::$_env[$variable])) {
|
||||||
|
loadClass('Logger')->error('Environment variable not found: \''.$variable.'\'');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return self::$_env[$variable];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the IP address of the container.
|
||||||
|
*
|
||||||
|
* @return string|boolean IP address or false
|
||||||
|
*/
|
||||||
|
public function getIpAddress($hostname)
|
||||||
|
{
|
||||||
|
// Request was already done before and is cached
|
||||||
|
if (isset(self::$_ip_address[$hostname])) {
|
||||||
|
return self::$_ip_address[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
// New request, generic check
|
||||||
|
$ip = $this->exec('ping -c 1 '.$hostname.'. 2>/dev/null | grep -Eo \'[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\' | head -1');
|
||||||
|
//$ip = gethostbyname($hostname.'');
|
||||||
|
|
||||||
|
if (filter_var($ip, FILTER_VALIDATE_IP) === false) {
|
||||||
|
//loadClass('Logger')->error('Retrieving the IP address of host \''.$hostname.'\' failed: '.$ip);
|
||||||
|
self::$_ip_address[$hostname] = false;
|
||||||
|
} else {
|
||||||
|
self::$_ip_address[$hostname] = $ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$_ip_address[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shorter version to regex select a string.
|
||||||
|
*
|
||||||
|
* @param string $regex Regex
|
||||||
|
* @param string $string String to look in to
|
||||||
|
* @return bool|string Returns false on error otherwise the string
|
||||||
|
*/
|
||||||
|
public function egrep($regex, $string)
|
||||||
|
{
|
||||||
|
$match = array();
|
||||||
|
$error = preg_match($regex, $string, $match);
|
||||||
|
|
||||||
|
if ($error === false) {
|
||||||
|
loadClass('Logger')->error('Error matching regex: \''.$regex. '\' in string: \''.$string.'\'');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($match[0]) ? $match[0] : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes shell commands on the PHP-FPM Host
|
||||||
|
*
|
||||||
|
* @param string $cmd Command
|
||||||
|
* @param integer $exit_code Reference to exit code
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function exec($cmd, &$exit_code = -1)
|
||||||
|
{
|
||||||
|
$output = array();
|
||||||
|
|
||||||
|
exec($cmd, $output, $exit_code);
|
||||||
|
return implode ("\n", $output);
|
||||||
|
}
|
||||||
|
}
|
367
.devilbox/www/include/lib/Html.php
Normal file
367
.devilbox/www/include/lib/Html.php
Normal file
@ -0,0 +1,367 @@
|
|||||||
|
<?php
|
||||||
|
namespace devilbox;
|
||||||
|
|
||||||
|
class Html
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Devilbox Navbar menu
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $_menu = array(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'name' => 'Home',
|
||||||
|
'path' => '/index.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Virtual Hosts',
|
||||||
|
'path' => '/vhosts.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Emails',
|
||||||
|
'path' => '/mail.php'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Databases',
|
||||||
|
'menu' => array(
|
||||||
|
array(
|
||||||
|
'name' => 'MySQL DB',
|
||||||
|
'path' => '/db_mysql.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'PgSQL DB',
|
||||||
|
'path' => '/db_pgsql.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Redis DB',
|
||||||
|
'path' => '/db_redis.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Memcached DB',
|
||||||
|
'path' => '/db_memcd.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Info',
|
||||||
|
'menu' => array(
|
||||||
|
array(
|
||||||
|
'name' => 'PHP Info',
|
||||||
|
'path' => '/info_php.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'MySQL Info',
|
||||||
|
'path' => '/info_mysql.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'PgSQL Info',
|
||||||
|
'path' => '/info_pgsql.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Redis Info',
|
||||||
|
'path' => '/info_redis.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Memcached Info',
|
||||||
|
'path' => '/info_memcd.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Tools',
|
||||||
|
'menu' => array(
|
||||||
|
array(
|
||||||
|
'name' => 'phpMyAdmin',
|
||||||
|
'path' => '__PHPMYADMIN__',
|
||||||
|
'target' => '_blank'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Adminer',
|
||||||
|
'path' => '/vendor/adminer-4.3.1/adminer/index.php'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'Opcache GUI',
|
||||||
|
'path' => '/opcache.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Statics
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $this Singleton instance
|
||||||
|
* @var Object|null
|
||||||
|
*/
|
||||||
|
protected static $_instance = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton Instance getter.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
*/
|
||||||
|
public static function getInstance()
|
||||||
|
{
|
||||||
|
if (self::$_instance === null) {
|
||||||
|
self::$_instance = new self();
|
||||||
|
}
|
||||||
|
return self::$_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Select functions
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
public function getHead($font_awesome = false)
|
||||||
|
{
|
||||||
|
$css_fa = ($font_awesome) ? '<link href="/vendor/font-awesome/font-awesome.min.css" rel="stylesheet">' : '';
|
||||||
|
|
||||||
|
$html = <<<HTML
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
|
||||||
|
<!-- Meta -->
|
||||||
|
<meta name="description" content="The devilbox - your customizable LAMP/LEMP stack.">
|
||||||
|
<meta name="author" content="cytopia">
|
||||||
|
|
||||||
|
<!-- Favicons -->
|
||||||
|
<link rel="apple-touch-icon" sizes="57x57" href="/assets/favicon/apple-icon-57x57.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="60x60" href="/assets/favicon/apple-icon-60x60.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="72x72" href="/assets/favicon/apple-icon-72x72.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="76x76" href="/assets/favicon/apple-icon-76x76.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="114x114" href="/assets/favicon/apple-icon-114x114.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="120x120" href="/assets/favicon/apple-icon-120x120.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="144x144" href="/assets/favicon/apple-icon-144x144.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="152x152" href="/assets/favicon/apple-icon-152x152.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/assets/favicon/apple-icon-180x180.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="192x192" href="/assets/favicon/android-icon-192x192.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon/favicon-32x32.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="96x96" href="/assets/favicon/favicon-96x96.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon/favicon-16x16.png">
|
||||||
|
<link rel="manifest" href="/manifest.json">
|
||||||
|
<meta name="msapplication-TileColor" content="#ffffff">
|
||||||
|
<meta name="msapplication-TileImage" content="/assets/favicon/ms-icon-144x144.png">
|
||||||
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
|
||||||
|
<!-- CSS/JS -->
|
||||||
|
<link href="/vendor/bootstrap/bootstrap.min.css" rel="stylesheet">
|
||||||
|
{$css_fa}
|
||||||
|
<link href="/assets/css/custom.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<title>The DevilBox</title>
|
||||||
|
HTML;
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getNavbar()
|
||||||
|
{
|
||||||
|
$menu = $this->_buildMenu();
|
||||||
|
|
||||||
|
$html = <<<HTML
|
||||||
|
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse">
|
||||||
|
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="/index.php">
|
||||||
|
<img src="/assets/img/logo_30.png" width="30" height="30" class="d-inline-block align-top" alt="">devilbox
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
|
<ul class="navbar-nav mr-auto">
|
||||||
|
|
||||||
|
{$menu}
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<br/>
|
||||||
|
HTML;
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getFooter()
|
||||||
|
{
|
||||||
|
$render_time = round((microtime(true) - $GLOBALS['TIME_START']), 2);
|
||||||
|
$errors = loadClass('Logger')->countErrors();
|
||||||
|
|
||||||
|
$html = <<<HTML
|
||||||
|
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse footer">
|
||||||
|
<div class="container justify-content-end">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li class="nav-item nav-link">Render time: ${render_time} sec</li>
|
||||||
|
<li class="nav-item"><a class="nav-link" target="_blank" href="https://github.com/cytopia/devilbox"><code>Github</code></a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="/credits.php"><code>Credits</code></a></li>
|
||||||
|
<li class="nav-item"><a class="nav-link" href="/debug.php"><code>Debug ({$errors})</code></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<script src="/vendor/jquery/jquery-3.2.1.min.js"></script>
|
||||||
|
<script src="/vendor/tether/tether.min.js"></script>
|
||||||
|
<script src="/vendor/bootstrap/bootstrap.min.js"></script>
|
||||||
|
HTML;
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function getCirle($name)
|
||||||
|
{
|
||||||
|
switch ($name) {
|
||||||
|
case 'dns':
|
||||||
|
$class = 'bg-info';
|
||||||
|
$version = loadClass('Dns')->getVersion();
|
||||||
|
$available = loadClass('Dns')->isAvailable();
|
||||||
|
$name = loadClass('Dns')->getName();
|
||||||
|
break;
|
||||||
|
case 'php':
|
||||||
|
$class = 'bg-info';
|
||||||
|
$version = loadClass('Php')->getVersion();
|
||||||
|
$available = loadClass('Php')->isAvailable();
|
||||||
|
$name = loadClass('Php')->getName();
|
||||||
|
break;
|
||||||
|
case 'httpd':
|
||||||
|
$class = 'bg-info';
|
||||||
|
$version = loadClass('Httpd')->getVersion();
|
||||||
|
$available = loadClass('Httpd')->isAvailable();
|
||||||
|
$name = loadClass('Httpd')->getName();
|
||||||
|
break;
|
||||||
|
case 'mysql':
|
||||||
|
$class = 'bg-warning';
|
||||||
|
$version = loadClass('Mysql')->getVersion();
|
||||||
|
$available = loadClass('Mysql')->isAvailable();
|
||||||
|
$name = loadClass('Mysql')->getName();
|
||||||
|
break;
|
||||||
|
case 'pgsql':
|
||||||
|
$class = 'bg-warning';
|
||||||
|
$version = loadClass('Pgsql')->getVersion();
|
||||||
|
$available = loadClass('Pgsql')->isAvailable();
|
||||||
|
$name = loadClass('Pgsql')->getName();
|
||||||
|
break;
|
||||||
|
case 'redis':
|
||||||
|
$class = 'bg-danger';
|
||||||
|
$version = loadClass('Redis')->getVersion();
|
||||||
|
$available = loadClass('Redis')->isAvailable();
|
||||||
|
$name = loadClass('Redis')->getName();
|
||||||
|
break;
|
||||||
|
case 'memcd':
|
||||||
|
$class = 'bg-danger';
|
||||||
|
$version = loadClass('Memcd')->getVersion();
|
||||||
|
$available = loadClass('Memcd')->isAvailable();
|
||||||
|
$name = loadClass('Memcd')->getName();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$available = false;
|
||||||
|
$version = '';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$style = 'color:black;';
|
||||||
|
$version = '('.$version.')';
|
||||||
|
if (!$available) {
|
||||||
|
$class = '';
|
||||||
|
$style = 'background-color:gray;';
|
||||||
|
$version = ' ';
|
||||||
|
}
|
||||||
|
$circle = '<div class="circles">'.
|
||||||
|
'<div>'.
|
||||||
|
'<div class="'.$class.'" style="'.$style.'">'.
|
||||||
|
'<div>'.
|
||||||
|
'<div><br/><strong>'.$name.'</strong><br/><small style="color:#333333">'.$version.'</small></div>'.
|
||||||
|
'</div>'.
|
||||||
|
'</div>'.
|
||||||
|
'</div>'.
|
||||||
|
'</div>';
|
||||||
|
return $circle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Private functions
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
private function _buildMenu()
|
||||||
|
{
|
||||||
|
|
||||||
|
$path = $_SERVER['PHP_SELF'];
|
||||||
|
$html = '';
|
||||||
|
|
||||||
|
foreach ($this->_menu as $type => $elements) {
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
if (!isset($elements['menu'])) {
|
||||||
|
|
||||||
|
foreach ($elements as $el) {
|
||||||
|
if ($path == $el['path']) {
|
||||||
|
$class = 'active';
|
||||||
|
$span = '<span class="sr-only">(current)</span>';
|
||||||
|
} else {
|
||||||
|
$class = '';
|
||||||
|
$span = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= '<li class="nav-item '.$class.'">';
|
||||||
|
$html .= '<a class="nav-link" href="'.$el['path'].'">'.$el['name'].' '.$span.'</a>';
|
||||||
|
$html .= '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Submenu
|
||||||
|
} else {
|
||||||
|
$name = $elements['name'];
|
||||||
|
$class = '';
|
||||||
|
$id = md5($name);
|
||||||
|
|
||||||
|
|
||||||
|
// Make submenu active
|
||||||
|
foreach ($elements['menu'] as $el) {
|
||||||
|
if (strpos($path, $el['path']) !== false) {
|
||||||
|
$class = 'active';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= '<li class="nav-item dropdown '.$class.'">';
|
||||||
|
$html .= '<a class="nav-link dropdown-toggle" href="#" id="'.$id.'" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">';
|
||||||
|
$html .= $name;
|
||||||
|
$html .= '</a>';
|
||||||
|
$html .= '<div class="dropdown-menu" aria-labelledby="'.$id.'">';
|
||||||
|
|
||||||
|
foreach ($elements['menu'] as $el) {
|
||||||
|
|
||||||
|
// Replace
|
||||||
|
if ($el['path'] == '__PHPMYADMIN__') {
|
||||||
|
$el['path'] = (strpos(loadClass('Php')->getVersion(), '5.4') !== false) ? '/vendor/phpmyadmin-4.0/index.php' : '/vendor/phpmyadmin-4.7/index.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
$target = isset($el['target']) ? 'target="'.$el['target'].'"' : '';
|
||||||
|
$html .= '<a class="dropdown-item" '.$target.' href="'.$el['path'].'">'.$el['name'].'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '</li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
}
|
@ -1,128 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace devilbox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires devilbox::Logger
|
|
||||||
*/
|
|
||||||
class Httpd extends _Base implements _iBase
|
|
||||||
{
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Statics
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Httpd instance
|
|
||||||
* @var Httpd|null
|
|
||||||
*/
|
|
||||||
protected static $instance = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton Instance getter.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
* @return object|null
|
|
||||||
*/
|
|
||||||
public static function getInstance($host = null, $user = null, $pass = null)
|
|
||||||
{
|
|
||||||
if (!isset(static::$instance)) {
|
|
||||||
static::$instance = new static();
|
|
||||||
}
|
|
||||||
return static::$instance;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @overwrite
|
|
||||||
* @param string $hostname [description]
|
|
||||||
* @return boolean [description]
|
|
||||||
*/
|
|
||||||
public static function isAvailable($hostname)
|
|
||||||
{
|
|
||||||
// Always available, otherwise you would not see any browser output.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to Httpd
|
|
||||||
*
|
|
||||||
* @param string $err Reference to error message
|
|
||||||
* @param string $host Redis hostname
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function testConnection(&$err, $host, $user = '', $pass = '')
|
|
||||||
{
|
|
||||||
$err = false;
|
|
||||||
|
|
||||||
// Silence errors and try to connect
|
|
||||||
$url = 'http://'.$host.'/not-existing-page-which-returns-404.php';
|
|
||||||
$ch = curl_init($url);
|
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, true);
|
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
|
||||||
curl_exec($ch);
|
|
||||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
||||||
curl_close($ch);
|
|
||||||
|
|
||||||
if ($http_code == 0) {
|
|
||||||
$err = 'Failed to connect to Httpd host on '.$host;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Construct/Destructor
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use singleton getInstance() instead.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Interface required functions
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
public function getName($default = 'Httpd')
|
|
||||||
{
|
|
||||||
$name = $this->egrep('/[a-zA-Z0-9]+/', $_SERVER['SERVER_SOFTWARE']);
|
|
||||||
if (!$name) {
|
|
||||||
loadClass('Logger')->error('Could not get Httpd name');
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVersion()
|
|
||||||
{
|
|
||||||
$version = $this->egrep('/[.0-9]+/', $_SERVER['SERVER_SOFTWARE']);
|
|
||||||
if (!$version) {
|
|
||||||
loadClass('Logger')->error('Could not get Httpd version');
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
return $version;
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,6 +14,8 @@ namespace devilbox;
|
|||||||
class Logger
|
class Logger
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private $_record_separator = "====================\n";
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Statics
|
* Statics
|
||||||
@ -21,10 +23,10 @@ class Logger
|
|||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mysql instance
|
* Logger instance
|
||||||
* @var Mysql|null
|
* @var Logger|null
|
||||||
*/
|
*/
|
||||||
protected static $instance = null;
|
private static $_instance = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,10 +36,10 @@ class Logger
|
|||||||
*/
|
*/
|
||||||
public static function getInstance()
|
public static function getInstance()
|
||||||
{
|
{
|
||||||
if (!isset(static::$instance)) {
|
if (self::$_instance === null) {
|
||||||
static::$instance = new static();
|
self::$_instance = new self();
|
||||||
}
|
}
|
||||||
return static::$instance;
|
return self::$_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -120,15 +122,30 @@ class Logger
|
|||||||
*/
|
*/
|
||||||
public function error($message)
|
public function error($message)
|
||||||
{
|
{
|
||||||
$mail_body = $message."\r\n";
|
ob_start();
|
||||||
|
$backtrace = debug_backtrace();
|
||||||
|
// Remove current (first) trace from array
|
||||||
|
for ($i=1; $i<count($backtrace); $i++) {
|
||||||
|
$backtrace[$i-1] = $backtrace[$i];
|
||||||
|
}
|
||||||
|
var_dump($backtrace);
|
||||||
|
$body = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
if ($body) {
|
||||||
|
$mail_body = $message."\r\n".$body."\r\n";
|
||||||
|
} else {
|
||||||
|
$mail_body = $message."\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->_fp) {
|
if (!$this->_fp) {
|
||||||
return mail('apache@localhost', 'devilbox error', $mail_body);
|
return mail('apache@localhost', 'devilbox error', $mail_body);
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = date('Y-m-d H:i') . "\n" . $message;
|
$message = date('Y-m-d H:i') . "\n" .
|
||||||
$message = str_replace("\n", '<br/>', $message);
|
$message. "\n" .
|
||||||
$message = $message . "\n";
|
$body . "\n" .
|
||||||
|
$this->_record_separator;
|
||||||
|
|
||||||
if (fwrite($this->_fp, $message) === false) {
|
if (fwrite($this->_fp, $message) === false) {
|
||||||
return mail('apache@localhost', 'devilbox error', $mail_body);
|
return mail('apache@localhost', 'devilbox error', $mail_body);
|
||||||
@ -145,14 +162,33 @@ class Logger
|
|||||||
{
|
{
|
||||||
$lines = array();
|
$lines = array();
|
||||||
|
|
||||||
if ($this->_fp) {
|
$pos = 0;
|
||||||
rewind($this->_fp);
|
$num = 0;
|
||||||
while (($buffer = fgets($this->_fp)) !== false) {
|
|
||||||
$lines[] = $buffer;
|
$handle = fopen($this->_logfile, 'r');
|
||||||
|
if ($handle) {
|
||||||
|
while (($buffer = fgets($handle)) !== false) {
|
||||||
|
if ($pos == 0) {
|
||||||
|
$lines[$num]['date'] = $buffer;
|
||||||
|
$pos++;
|
||||||
|
} else if ($pos == 1) {
|
||||||
|
$lines[$num]['head'] = $buffer;
|
||||||
|
$pos++;
|
||||||
|
} else {
|
||||||
|
// New entry
|
||||||
|
if (substr_count($buffer, $this->_record_separator)) {
|
||||||
|
$num++;
|
||||||
|
$pos = 0;
|
||||||
|
continue;
|
||||||
|
// Still current entry, but body part
|
||||||
|
} else {
|
||||||
|
$lines[$num]['body'][] = $buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $lines;
|
|
||||||
}
|
}
|
||||||
return false;
|
fclose($handle);
|
||||||
|
return $lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function countErrors()
|
public function countErrors()
|
||||||
@ -160,8 +196,10 @@ class Logger
|
|||||||
$count = 0;
|
$count = 0;
|
||||||
$handle = fopen($this->_logfile, 'r');
|
$handle = fopen($this->_logfile, 'r');
|
||||||
while (!feof($handle)) {
|
while (!feof($handle)) {
|
||||||
$line = fgets($handle, 4096);
|
$line = fgets($handle);
|
||||||
$count = $count + substr_count($line, PHP_EOL);
|
if (substr_count($line, $this->_record_separator)) {
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
return $count;
|
return $count;
|
||||||
|
@ -1,204 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace devilbox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires devilbox::Logger
|
|
||||||
*/
|
|
||||||
class Php extends _Base implements _iBase
|
|
||||||
{
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Statics
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Httpd instance
|
|
||||||
* @var Httpd|null
|
|
||||||
*/
|
|
||||||
protected static $instance = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton Instance getter.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
* @return object|null
|
|
||||||
*/
|
|
||||||
public static function getInstance($host = null, $user = null, $pass = null)
|
|
||||||
{
|
|
||||||
if (!isset(static::$instance)) {
|
|
||||||
static::$instance = new static();
|
|
||||||
}
|
|
||||||
return static::$instance;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @overwrite
|
|
||||||
* @param string $hostname [description]
|
|
||||||
* @return boolean [description]
|
|
||||||
*/
|
|
||||||
public static function isAvailable($hostname)
|
|
||||||
{
|
|
||||||
// Always available, otherwise you would not see any browser output.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to PHP
|
|
||||||
*
|
|
||||||
* @param string $err Reference to error message
|
|
||||||
* @param string $host Redis hostname
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function testConnection(&$err, $host, $user = '', $pass = '')
|
|
||||||
{
|
|
||||||
// Connection is always working, otherwise you would not see any browser output.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Construct/Destructor
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use singleton getInstance() instead.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* PHP Select functions
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
public function getUid()
|
|
||||||
{
|
|
||||||
$output = null;
|
|
||||||
$return = $this->_exec('id', $output);
|
|
||||||
|
|
||||||
$uid = $this->egrep('/uid=[0-9]+/', isset($output[0]) ? $output[0] : '');
|
|
||||||
$uid = $this->egrep('/[0-9]+/', $uid);
|
|
||||||
return $uid;
|
|
||||||
}
|
|
||||||
public function getGid()
|
|
||||||
{
|
|
||||||
$output = null;
|
|
||||||
$return = $this->_exec('id', $output);
|
|
||||||
|
|
||||||
$uid = $this->egrep('/gid=[0-9]+/', isset($output[0]) ? $output[0] : '');
|
|
||||||
$uid = $this->egrep('/[0-9]+/', $uid);
|
|
||||||
return $uid;
|
|
||||||
}
|
|
||||||
public function getGitVersion()
|
|
||||||
{
|
|
||||||
$output = null;
|
|
||||||
$return = $this->_exec('git --version', $output);
|
|
||||||
|
|
||||||
return $this->egrep('/[0-9.]+/', isset($output[0]) ? $output[0] : '');
|
|
||||||
}
|
|
||||||
public function getComposerVersion()
|
|
||||||
{
|
|
||||||
$output = null;
|
|
||||||
$return = $this->_exec('composer --version', $output);
|
|
||||||
|
|
||||||
return $this->egrep('/[0-9.]+/', isset($output[0]) ? $output[0] : '');
|
|
||||||
}
|
|
||||||
public function getDrushVersion()
|
|
||||||
{
|
|
||||||
$output = null;
|
|
||||||
$return = $this->_exec('drush --version', $output);
|
|
||||||
|
|
||||||
return $this->egrep('/[0-9.]+/', isset($output[0]) ? $output[0] : '');
|
|
||||||
}
|
|
||||||
public function getDrushConsoleVersion()
|
|
||||||
{
|
|
||||||
$output = null;
|
|
||||||
$return = $this->_exec('drush-console --version', $output);
|
|
||||||
|
|
||||||
return $this->egrep('/[0-9.]+/', isset($output[0]) ? $output[0] : '');
|
|
||||||
}
|
|
||||||
public function getNodeVersion()
|
|
||||||
{
|
|
||||||
$output = null;
|
|
||||||
$return = $this->_exec('node --version', $output);
|
|
||||||
|
|
||||||
return $this->egrep('/[0-9.]+/', isset($output[0]) ? $output[0] : '');
|
|
||||||
}
|
|
||||||
public function getNpmVersion()
|
|
||||||
{
|
|
||||||
$output = null;
|
|
||||||
$return = $this->_exec('npm --version', $output);
|
|
||||||
|
|
||||||
return $this->egrep('/[0-9.]+/', isset($output[0]) ? $output[0] : '');
|
|
||||||
}
|
|
||||||
public function getTldSuffix()
|
|
||||||
{
|
|
||||||
return getenv('TLD_SUFFIX');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Interface required functions
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
public function getName($default = 'PHP')
|
|
||||||
{
|
|
||||||
if (defined('HHVM_VERSION')) {
|
|
||||||
return 'HHVM';
|
|
||||||
}
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVersion()
|
|
||||||
{
|
|
||||||
if (defined('HHVM_VERSION')) {
|
|
||||||
return HHVM_VERSION . ' php-'.str_replace('-hhvm', '', phpversion());
|
|
||||||
} else {
|
|
||||||
return phpversion();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Private functions
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes shell commands on the PHP-FPM Host
|
|
||||||
*
|
|
||||||
* @param string $cmd Command
|
|
||||||
* @param string $output Reference to output
|
|
||||||
* @return integer
|
|
||||||
*/
|
|
||||||
private function _exec($cmd, &$output = '')
|
|
||||||
{
|
|
||||||
// Clean output
|
|
||||||
$output = '';
|
|
||||||
exec($cmd, $output, $exit_code);
|
|
||||||
return $exit_code;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,171 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace devilbox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @requires devilbox::Logger
|
|
||||||
*/
|
|
||||||
class _Base
|
|
||||||
{
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Statics
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/** TODO: isAvailable (make instance) */
|
|
||||||
|
|
||||||
private static $_available = array();
|
|
||||||
private static $_hostname = array();
|
|
||||||
|
|
||||||
public static function isAvailable($hostname)
|
|
||||||
{
|
|
||||||
if (!isset(self::$_available[$hostname])) {
|
|
||||||
$ip = self::getIpAddress($hostname);
|
|
||||||
self::$_available[$hostname] = ($ip == $hostname) ? false : true;
|
|
||||||
}
|
|
||||||
return self::$_available[$hostname];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getIpAddress($hostname)
|
|
||||||
{
|
|
||||||
if (!isset(self::$_hostname[$hostname])) {
|
|
||||||
self::$_hostname[$hostname] = gethostbyname($hostname);
|
|
||||||
}
|
|
||||||
return self::$_hostname[$hostname];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Instance
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connection error string
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_connect_error = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connection error code
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
private $_connect_errno = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Error string
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $_error = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Error code
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
private $_errno = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shorter version to regex select a string.
|
|
||||||
*
|
|
||||||
* @param string $regex Regex
|
|
||||||
* @param string $string String to look in to
|
|
||||||
* @return bool|string Returns false on error otherwise the string
|
|
||||||
*/
|
|
||||||
public function egrep($regex, $string)
|
|
||||||
{
|
|
||||||
$match = array();
|
|
||||||
$error = preg_match($regex, $string, $match);
|
|
||||||
|
|
||||||
if ($error === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return isset($match[0]) ? $match[0] : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Connection Error Message.
|
|
||||||
*
|
|
||||||
* @param string $error Error Message
|
|
||||||
*/
|
|
||||||
public function setConnectError($error)
|
|
||||||
{
|
|
||||||
$this->_connect_error = $error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Connection Error Code.
|
|
||||||
*
|
|
||||||
* @param integer $errno Error Code
|
|
||||||
*/
|
|
||||||
public function setConnectErrno($errno)
|
|
||||||
{
|
|
||||||
$this->_connect_erro = $errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Error Message.
|
|
||||||
*
|
|
||||||
* @param string $error Error message
|
|
||||||
*/
|
|
||||||
public function setError($error)
|
|
||||||
{
|
|
||||||
$this->_error = $error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set Error Code.
|
|
||||||
*
|
|
||||||
* @param integer $errno Error Code
|
|
||||||
*/
|
|
||||||
public function setErrno($errno)
|
|
||||||
{
|
|
||||||
$this->_erro = $errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return connection error message.
|
|
||||||
*
|
|
||||||
* @return string Error message
|
|
||||||
*/
|
|
||||||
public function getConnectError()
|
|
||||||
{
|
|
||||||
return $this->_connect_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return connection errno code.
|
|
||||||
*
|
|
||||||
* @return integer Error code
|
|
||||||
*/
|
|
||||||
public function getConnectErrno()
|
|
||||||
{
|
|
||||||
return $this->_connect_errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return error message.
|
|
||||||
*
|
|
||||||
* @return string Error message
|
|
||||||
*/
|
|
||||||
public function getError()
|
|
||||||
{
|
|
||||||
return $this->_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return errno code.
|
|
||||||
*
|
|
||||||
* @return integer Error code
|
|
||||||
*/
|
|
||||||
public function getErrno()
|
|
||||||
{
|
|
||||||
return $this->_errno;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace devilbox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface
|
|
||||||
*/
|
|
||||||
interface _iBase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get singleton instance
|
|
||||||
* @return Object
|
|
||||||
*/
|
|
||||||
public static function getInstance($host, $user, $pass);
|
|
||||||
|
|
||||||
public static function isAvailable($hostname);
|
|
||||||
public static function testConnection(&$err, $host, $user, $pass);
|
|
||||||
public static function getIpAddress($hostname);
|
|
||||||
|
|
||||||
|
|
||||||
public function getName($default);
|
|
||||||
public function getVersion();
|
|
||||||
}
|
|
246
.devilbox/www/include/lib/container/BaseClass.php
Normal file
246
.devilbox/www/include/lib/container/BaseClass.php
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
<?php
|
||||||
|
namespace devilbox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires devilbox::Logger
|
||||||
|
*/
|
||||||
|
class BaseClass
|
||||||
|
{
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Statics
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class instance
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $_instance = array();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic singleton instance getter.
|
||||||
|
* Make sure to overwrite this in your class
|
||||||
|
* for a more complex initialization.
|
||||||
|
*
|
||||||
|
* @param string $hostname Hostname
|
||||||
|
* @param array $data Additional data (if required)
|
||||||
|
* @return object|null
|
||||||
|
*/
|
||||||
|
public static function getInstance($hostname, $data = array())
|
||||||
|
{
|
||||||
|
if (!isset(self::$_instance[$hostname])) {
|
||||||
|
self::$_instance[$hostname] = new static($hostname, $data);
|
||||||
|
}
|
||||||
|
return self::$_instance[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Instance
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hostname
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_hostname = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Container is running
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $_available = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection error string
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_connect_error = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection error code
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $_connect_errno = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error string
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_error = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error code
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
private $_errno = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Private constructor for singleton
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT CALL ME!
|
||||||
|
* Use singleton getInstance() instead.
|
||||||
|
*
|
||||||
|
* @param string $user Username
|
||||||
|
* @param string $pass Password
|
||||||
|
* @param string $host Host
|
||||||
|
*/
|
||||||
|
public function __construct($hostname, $data = array())
|
||||||
|
{
|
||||||
|
$this->_hostname = $hostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Public Default Interface Implementations
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this container is available.
|
||||||
|
* Note, this is a very basic check to see if its IP address
|
||||||
|
* can be resolved. Implement a better check in the actual class
|
||||||
|
* if it is required.
|
||||||
|
*
|
||||||
|
* @return boolean available
|
||||||
|
*/
|
||||||
|
public function isAvailable()
|
||||||
|
{
|
||||||
|
// Request was already done before and is cached
|
||||||
|
if (isset($this->_available[$this->_hostname])) {
|
||||||
|
return $this->_available[$this->_hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
// New request, check if hostname was set
|
||||||
|
if ($this->_hostname === null) {
|
||||||
|
loadClass('Logger')->error('Hostname has not been initialized. Cannot determine if it is available.');
|
||||||
|
$this->_available = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// New request, generic check
|
||||||
|
$ip = $this->getIpAddress();
|
||||||
|
|
||||||
|
$this->_available[$this->_hostname] = ($ip && $ip != $this->_hostname) ? true : false;
|
||||||
|
|
||||||
|
return $this->_available[$this->_hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the IP address of the container.
|
||||||
|
*
|
||||||
|
* @return string|boolean IP address or false
|
||||||
|
*/
|
||||||
|
public function getIpAddress()
|
||||||
|
{
|
||||||
|
// Check if hostname was set
|
||||||
|
if ($this->_hostname === null) {
|
||||||
|
loadClass('Logger')->error('Hostname has not been initialized. Cannot determine IP address.');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return loadClass('Helper')->getIpAddress($this->_hostname);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Connection Error Getter/Setter
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Connection Error Message.
|
||||||
|
*
|
||||||
|
* @param string $error Error Message
|
||||||
|
*/
|
||||||
|
public function setConnectError($error)
|
||||||
|
{
|
||||||
|
$this->_connect_error = $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Connection Error Code.
|
||||||
|
*
|
||||||
|
* @param integer $errno Error Code
|
||||||
|
*/
|
||||||
|
public function setConnectErrno($errno)
|
||||||
|
{
|
||||||
|
$this->_connect_erro = $errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Error Message.
|
||||||
|
*
|
||||||
|
* @param string $error Error message
|
||||||
|
*/
|
||||||
|
public function setError($error)
|
||||||
|
{
|
||||||
|
$this->_error = $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Error Code.
|
||||||
|
*
|
||||||
|
* @param integer $errno Error Code
|
||||||
|
*/
|
||||||
|
public function setErrno($errno)
|
||||||
|
{
|
||||||
|
$this->_erro = $errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return connection error message.
|
||||||
|
*
|
||||||
|
* @return string Error message
|
||||||
|
*/
|
||||||
|
public function getConnectError()
|
||||||
|
{
|
||||||
|
return $this->_connect_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return connection errno code.
|
||||||
|
*
|
||||||
|
* @return integer Error code
|
||||||
|
*/
|
||||||
|
public function getConnectErrno()
|
||||||
|
{
|
||||||
|
return $this->_connect_errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return error message.
|
||||||
|
*
|
||||||
|
* @return string Error message
|
||||||
|
*/
|
||||||
|
public function getError()
|
||||||
|
{
|
||||||
|
return $this->_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return errno code.
|
||||||
|
*
|
||||||
|
* @return integer Error code
|
||||||
|
*/
|
||||||
|
public function getErrno()
|
||||||
|
{
|
||||||
|
return $this->_errno;
|
||||||
|
}
|
||||||
|
}
|
76
.devilbox/www/include/lib/container/BaseInterface.php
Normal file
76
.devilbox/www/include/lib/container/BaseInterface.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
namespace devilbox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface
|
||||||
|
*
|
||||||
|
* Must be implemented by all devilbox service classes.
|
||||||
|
* @see _Base.php: Most functions will have a default implementationin the mother class
|
||||||
|
*/
|
||||||
|
interface BaseInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get singleton instance
|
||||||
|
*
|
||||||
|
* @param string $hostname Internal Hostname of docker (as described in docker-compose.yml)
|
||||||
|
* @param array $data Additional data required for the container (username, password, db...)
|
||||||
|
* @return object Returns class object
|
||||||
|
*/
|
||||||
|
public static function getInstance($hostname, $data = array());
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor of this type must be implemented by each class.
|
||||||
|
* Note, the constructor MUST set the hostname!
|
||||||
|
*
|
||||||
|
* @param string $hostname Internal Hostname of docker (as described in docker-compose.yml)
|
||||||
|
* @param array $data Additional data required for the container (username, password, db...)
|
||||||
|
*/
|
||||||
|
public function __construct($hostname, $data = array());
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the PHP container can connect to the specified service.
|
||||||
|
* Additional arguments (user, pass, port, etc) can be specified
|
||||||
|
* withing the $data array.
|
||||||
|
*
|
||||||
|
* @param string|bool &$err Connection error string or false
|
||||||
|
* @param string $hostname Hostname to connect to (127.0.0.1, host, IP, ...)
|
||||||
|
* @param array $data Optional data (user, pass, port...)
|
||||||
|
* @return bool Can we connect?
|
||||||
|
*/
|
||||||
|
public function canConnect(&$err, $hostname, $data = array());
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the container is running/available
|
||||||
|
*
|
||||||
|
* @return boolean Running state
|
||||||
|
*/
|
||||||
|
public function isAvailable();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the IP Address of the container
|
||||||
|
*
|
||||||
|
* @return string|boolean IP Address or false if it cannot be determined
|
||||||
|
*/
|
||||||
|
public function getIpAddress();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve name of the service the docker container provides.
|
||||||
|
*
|
||||||
|
* @param string $default Default name if it can't be found
|
||||||
|
* @return string Name
|
||||||
|
*/
|
||||||
|
public function getName($default);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get version string of the service the docker container provides.
|
||||||
|
*
|
||||||
|
* @return string Version string
|
||||||
|
*/
|
||||||
|
public function getVersion();
|
||||||
|
}
|
65
.devilbox/www/include/lib/container/Dns.php
Normal file
65
.devilbox/www/include/lib/container/Dns.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
namespace devilbox;
|
||||||
|
|
||||||
|
class Dns extends BaseClass implements BaseInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Interface required functions
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
private $_version = null;
|
||||||
|
private $_can_connect = array();
|
||||||
|
private $_can_connect_err = array();
|
||||||
|
|
||||||
|
|
||||||
|
public function canConnect(&$err, $hostname, $data = array())
|
||||||
|
{
|
||||||
|
$err = false;
|
||||||
|
|
||||||
|
// Return if already cached
|
||||||
|
if (isset($this->_can_connect[$hostname])) {
|
||||||
|
// Assume error for unset error message
|
||||||
|
$err = isset($this->_can_connect_err[$hostname]) ? $this->_can_connect_err[$hostname] : true;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $this->getVersion();
|
||||||
|
|
||||||
|
if (strlen($version)) {
|
||||||
|
$this->_can_connect[$hostname] = true;
|
||||||
|
} else {
|
||||||
|
$err = 'Could not connect to Bind via hostname: '.$hostname;
|
||||||
|
$this->_can_connect[$hostname] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_can_connect_err[$hostname] = $err;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName($default = 'Bind')
|
||||||
|
{
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVersion()
|
||||||
|
{
|
||||||
|
// Return if already cached
|
||||||
|
if ($this->_version !== null) {
|
||||||
|
return $this->_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cmd = 'dig +time=1 +tries=1 @'.$this->getIpAddress().' version.bind chaos TXT | grep -iE "^version\.bind.*TXT"';
|
||||||
|
|
||||||
|
$output = loadClass('Helper')->exec($cmd);
|
||||||
|
|
||||||
|
$version = loadClass('Helper')->egrep('/"[0-9.-]+.*"/', $output);
|
||||||
|
$version = loadClass('Helper')->egrep('/[0-9.-]+/', $version);
|
||||||
|
|
||||||
|
// Cache and return
|
||||||
|
$this->_version = $version ? $version : '';
|
||||||
|
return $this->_version;
|
||||||
|
}
|
||||||
|
}
|
202
.devilbox/www/include/lib/container/Httpd.php
Normal file
202
.devilbox/www/include/lib/container/Httpd.php
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
<?php
|
||||||
|
namespace devilbox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @requires devilbox::Logger
|
||||||
|
*/
|
||||||
|
class Httpd extends BaseClass implements BaseInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
private $_docRoot = '/shared/httpd';
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Select/Check Functions
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check single mass virtual host
|
||||||
|
*
|
||||||
|
* @param string $vhost Virtual Host name
|
||||||
|
* @return string Errors
|
||||||
|
*/
|
||||||
|
public function checkVirtualHost($vhost)
|
||||||
|
{
|
||||||
|
$htdocs = $this->_docRoot . DIRECTORY_SEPARATOR . $vhost . DIRECTORY_SEPARATOR . 'htdocs';
|
||||||
|
$domain = $vhost . '.' . $this->getTldSuffix();
|
||||||
|
$url = 'http://'.$domain;
|
||||||
|
$error = array();
|
||||||
|
|
||||||
|
// 1. Check htdocs folder
|
||||||
|
if (!$this->_is_valid_dir($htdocs)) {
|
||||||
|
$error[] = 'Missing <strong>htdocs</strong> directory in: <strong>'.loadClass('Helper')->getEnv('HOST_PATH_HTTPD_DATADIR').'/'.$vhost.'/</strong>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($GLOBALS['ENABLE_VHOST_DNS_CHECK']) {
|
||||||
|
|
||||||
|
// 2. Check /etc/resolv DNS entry
|
||||||
|
$output;
|
||||||
|
if (loadClass('Helper')->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 mass virtual Hosts by directories
|
||||||
|
*
|
||||||
|
* @return mixed[]
|
||||||
|
*/
|
||||||
|
public function getVirtualHosts()
|
||||||
|
{
|
||||||
|
$docRoot = $this->_docRoot;
|
||||||
|
$vhosts = array();
|
||||||
|
|
||||||
|
if ($handle = opendir($docRoot)) {
|
||||||
|
while (false !== ($directory = readdir($handle))) {
|
||||||
|
if ($this->_is_valid_dir($docRoot . DIRECTORY_SEPARATOR . $directory) && $directory != '.' && $directory != '..') {
|
||||||
|
|
||||||
|
$vhosts[] = array(
|
||||||
|
'name' => $directory,
|
||||||
|
'domain' => $directory .'.' . $this->getTldSuffix(),
|
||||||
|
'href' => 'http://' . $directory . '.' . $this->getTldSuffix()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $vhosts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getTldSuffix()
|
||||||
|
{
|
||||||
|
return loadClass('Helper')->getEnv('TLD_SUFFIX');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get HTTP port.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPort()
|
||||||
|
{
|
||||||
|
$port = loadClass('Helper')->getEnv('HOST_PORT_HTTPD');
|
||||||
|
|
||||||
|
if ( empty($port) ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $port == 80 ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return ":$port";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Interface required functions
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
private $_can_connect = array();
|
||||||
|
private $_can_connect_err = array();
|
||||||
|
|
||||||
|
public function canConnect(&$err, $hostname, $data = array())
|
||||||
|
{
|
||||||
|
$err = false;
|
||||||
|
|
||||||
|
// Return if already cached
|
||||||
|
if (isset($this->_can_connect[$hostname])) {
|
||||||
|
// Assume error for unset error message
|
||||||
|
$err = isset($this->_can_connect_err[$hostname]) ? $this->_can_connect_err[$hostname] : true;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Silence errors and try to connect
|
||||||
|
$url = 'http://'.$hostname.'/'.$GLOBALS['DEVILBOX_API_PAGE'];
|
||||||
|
$ch = curl_init($url);
|
||||||
|
curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||||
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
||||||
|
curl_exec($ch);
|
||||||
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
if ($http_code == 0) {
|
||||||
|
$err = 'Failed to connect to Httpd host on '.$hostname;
|
||||||
|
$this->_can_connect[$hostname] = false;
|
||||||
|
} else {
|
||||||
|
$this->_can_connect[$hostname] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_can_connect_err[$hostname] = $err;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName($default = 'Httpd')
|
||||||
|
{
|
||||||
|
$name = loadClass('Helper')->egrep('/[a-zA-Z0-9]+/', $_SERVER['SERVER_SOFTWARE']);
|
||||||
|
if (!$name) {
|
||||||
|
loadClass('Logger')->error('Could not get Httpd name');
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVersion()
|
||||||
|
{
|
||||||
|
$version = loadClass('Helper')->egrep('/[.0-9]+/', $_SERVER['SERVER_SOFTWARE']);
|
||||||
|
if (!$version) {
|
||||||
|
loadClass('Logger')->error('Could not get Httpd version');
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
return $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Private functions
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the directory exists or
|
||||||
|
* in case of a symlink the target is an
|
||||||
|
* existing directory.
|
||||||
|
*
|
||||||
|
* @param string $path The path.
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private function _is_valid_dir($path)
|
||||||
|
{
|
||||||
|
return (is_dir($path) || (is_link($path) && is_dir(readlink($path))));
|
||||||
|
}
|
||||||
|
}
|
@ -4,88 +4,8 @@ namespace devilbox;
|
|||||||
/**
|
/**
|
||||||
* @requires devilbox::Logger
|
* @requires devilbox::Logger
|
||||||
*/
|
*/
|
||||||
class Memcd extends _Base implements _iBase
|
class Memcd extends BaseClass implements BaseInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Statics
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memcached instance
|
|
||||||
* @var Memcached|null
|
|
||||||
*/
|
|
||||||
protected static $instance = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton Instance getter.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
* @return object|null
|
|
||||||
*/
|
|
||||||
public static function getInstance($host, $user = null, $pass = null)
|
|
||||||
{
|
|
||||||
if (!isset(static::$instance)) {
|
|
||||||
static::$instance = new static($host);
|
|
||||||
}
|
|
||||||
// If current Memcached instance was unable to connect
|
|
||||||
if (!static::$instance) {
|
|
||||||
//loadClass('Logger')->error('Instance has errors:' . "\r\n" . var_export(static::$instance, true) . "\r\n");
|
|
||||||
}
|
|
||||||
return static::$instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to Memcached
|
|
||||||
*
|
|
||||||
* @param string $err Reference to error message
|
|
||||||
* @param string $host Memcached hostname
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function testConnection(&$err, $host, $user = '', $pass = '')
|
|
||||||
{
|
|
||||||
$err = false;
|
|
||||||
|
|
||||||
// Silence errors and try to connect
|
|
||||||
//error_reporting(-1);
|
|
||||||
$memcd = new \Memcached();
|
|
||||||
$memcd->resetServerList();
|
|
||||||
|
|
||||||
|
|
||||||
if (!$memcd->addServer($host, 11211)) {
|
|
||||||
$memcd->quit();
|
|
||||||
$err = 'Failed to connect to Memcached host on '.$host;
|
|
||||||
error_reporting(-1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stats = $memcd->getStats();
|
|
||||||
if (!isset($stats[$host.':11211'])) {
|
|
||||||
$memcd->quit();
|
|
||||||
$err = 'Failed to connect to Memcached host on '.$host;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!isset($stats[$host.':11211']['pid'])) {
|
|
||||||
$memcd->quit();
|
|
||||||
$err = 'Failed to connect to Memcached host on '.$host;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($stats[$host.':11211']['pid'] < 1) {
|
|
||||||
$memcd->quit();
|
|
||||||
$err = 'Failed to connect to Memcached host on '.$host;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$memcd->quit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Private Variables
|
* Private Variables
|
||||||
@ -102,7 +22,7 @@ class Memcd extends _Base implements _iBase
|
|||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Construct/Destructor
|
* Constructor Overwrite
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
@ -113,8 +33,10 @@ class Memcd extends _Base implements _iBase
|
|||||||
* @param string $pass Password
|
* @param string $pass Password
|
||||||
* @param string $host Host
|
* @param string $host Host
|
||||||
*/
|
*/
|
||||||
public function __construct($host)
|
public function __construct($hostname, $data = array())
|
||||||
{
|
{
|
||||||
|
parent::__construct($hostname, $data);
|
||||||
|
|
||||||
$memcd = new \Memcached('_devilbox');
|
$memcd = new \Memcached('_devilbox');
|
||||||
$list = $memcd->getServerList();
|
$list = $memcd->getServerList();
|
||||||
|
|
||||||
@ -130,32 +52,32 @@ class Memcd extends _Base implements _iBase
|
|||||||
//$memcd->setOption(\Memcached::OPT_CONNECT_TIMEOUT, 100);
|
//$memcd->setOption(\Memcached::OPT_CONNECT_TIMEOUT, 100);
|
||||||
//$memcd->setOption(\Memcached::OPT_RETRY_TIMEOUT, 100);
|
//$memcd->setOption(\Memcached::OPT_RETRY_TIMEOUT, 100);
|
||||||
//$memcd->setOption(\Memcached::OPT_REMOVE_FAILED_SERVERS, true);
|
//$memcd->setOption(\Memcached::OPT_REMOVE_FAILED_SERVERS, true);
|
||||||
$memcd->addServer($host, 11211);
|
$memcd->addServer($hostname, 11211);
|
||||||
}
|
}
|
||||||
|
|
||||||
$err = false;
|
$err = false;
|
||||||
$stats = $memcd->getStats();
|
$stats = $memcd->getStats();
|
||||||
if (!isset($stats[$host.':11211'])) {
|
if (!isset($stats[$hostname.':11211'])) {
|
||||||
$memcd->quit();
|
$memcd->quit();
|
||||||
$err = 'Failed to connect to Memcached host on '.$host;
|
$this->_connect_error = 'Failed to connect to Memcached host on '.$hostname.' (no connection array)';
|
||||||
|
$this->_connect_errno = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (!isset($stats[$host.':11211']['pid'])) {
|
else if (!isset($stats[$hostname.':11211']['pid'])) {
|
||||||
$memcd->quit();
|
$memcd->quit();
|
||||||
$err = 'Failed to connect to Memcached host on '.$host;
|
$this->_connect_error = 'Failed to connect to Memcached host on '.$hostname.' (no pid)';
|
||||||
|
$this->_connect_errno = 2;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if ($stats[$host.':11211']['pid'] < 1) {
|
else if ($stats[$hostname.':11211']['pid'] < 1) {
|
||||||
$memcd->quit();
|
$memcd->quit();
|
||||||
$err = 'Failed to connect to Memcached host on '.$host;
|
$this->_connect_error = 'Failed to connect to Memcached host on '.$hostname.' (invalid pid)';
|
||||||
|
$this->_connect_errno = 3;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ($err === false) {
|
$memcd->set('devilbox-version', $GLOBALS['DEVILBOX_VERSION'].' ('.$GLOBALS['DEVILBOX_DATE'].')');
|
||||||
$memcd->set('devilbox-version', $GLOBALS['DEVILBOX_VERSION'].' ('.$GLOBALS['DEVILBOX_DATE'].')');
|
$this->_memcached = $memcd;
|
||||||
$this->_memcached = $memcd;
|
|
||||||
} else {
|
|
||||||
$this->_connect_error = 'Failed to connect to Memcached host on '.$host;
|
|
||||||
$this->_connect_errno = 1;
|
|
||||||
//loadClass('Logger')->error($this->_connect_error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,9 +90,11 @@ class Memcd extends _Base implements _iBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Memcached Select functions
|
* Select functions
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
@ -205,6 +129,62 @@ class Memcd extends _Base implements _iBase
|
|||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
private $_can_connect = array();
|
||||||
|
private $_can_connect_err = array();
|
||||||
|
|
||||||
|
private $_name = null;
|
||||||
|
private $_version = null;
|
||||||
|
|
||||||
|
public function canConnect(&$err, $hostname, $data = array())
|
||||||
|
{
|
||||||
|
$err = false;
|
||||||
|
|
||||||
|
// Return if already cached
|
||||||
|
if (isset($this->_can_connect[$hostname])) {
|
||||||
|
// Assume error for unset error message
|
||||||
|
$err = isset($this->_can_connect_err[$hostname]) ? $this->_can_connect_err[$hostname] : true;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Silence errors and try to connect
|
||||||
|
//error_reporting(-1);
|
||||||
|
$memcd = new \Memcached();
|
||||||
|
$memcd->resetServerList();
|
||||||
|
|
||||||
|
|
||||||
|
if (!$memcd->addServer($hostname, 11211)) {
|
||||||
|
$memcd->quit();
|
||||||
|
$err = 'Failed to connect to Memcached host on '.$hostname;
|
||||||
|
$this->_can_connect[$hostname] = false;
|
||||||
|
$this->_can_connect_err[$hostname] = $err;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stats = $memcd->getStats();
|
||||||
|
if (!isset($stats[$hostname.':11211'])) {
|
||||||
|
$err = 'Failed to connect to Memcached host on '.$hostname;
|
||||||
|
$this->_can_connect[$hostname] = false;
|
||||||
|
}
|
||||||
|
else if (!isset($stats[$hostname.':11211']['pid'])) {
|
||||||
|
$err = 'Failed to connect to Memcached host on '.$hostname;
|
||||||
|
$this->_can_connect[$hostname] = false;
|
||||||
|
}
|
||||||
|
else if ($stats[$hostname.':11211']['pid'] < 1) {
|
||||||
|
$err = 'Failed to connect to Memcached host on '.$hostname;
|
||||||
|
$this->_can_connect[$hostname] = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->_can_connect[$hostname] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$memcd->quit();
|
||||||
|
|
||||||
|
$this->_can_connect_err[$hostname] = $err;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getName($default = 'Memcached')
|
public function getName($default = 'Memcached')
|
||||||
{
|
{
|
||||||
return $default;
|
return $default;
|
||||||
@ -212,17 +192,27 @@ class Memcd extends _Base implements _iBase
|
|||||||
|
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
$version = '';
|
// Return if already cached
|
||||||
|
if ($this->_version !== null) {
|
||||||
|
return $this->_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return empty if not available
|
||||||
|
if (!$this->isAvailable()) {
|
||||||
|
$this->_version = '';
|
||||||
|
return $this->_version;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->_memcached) {
|
if ($this->_memcached) {
|
||||||
$info = $this->_memcached->getVersion();
|
$info = $this->_memcached->getVersion();
|
||||||
$info = array_values($info);
|
$info = array_values($info);
|
||||||
if (!isset($info[0])) {
|
if (!isset($info[0])) {
|
||||||
loadClass('Logger')->error('Could not get Memcached version');
|
loadClass('Logger')->error('Could not get Memcached version');
|
||||||
|
$this->_version = '';
|
||||||
} else {
|
} else {
|
||||||
$version = $info[0];
|
$this->_version = $info[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $this->_version;
|
||||||
return $version;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,78 +4,18 @@ namespace devilbox;
|
|||||||
/**
|
/**
|
||||||
* @requires devilbox::Logger
|
* @requires devilbox::Logger
|
||||||
*/
|
*/
|
||||||
class Mysql extends _Base implements _iBase
|
class Mysql extends BaseClass implements BaseInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Statics
|
* Variables
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mysql instance
|
* MySQL connection link
|
||||||
* @var Mysql|null
|
* @var null
|
||||||
*/
|
|
||||||
protected static $instance = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton Instance getter.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
* @return object|null
|
|
||||||
*/
|
|
||||||
public static function getInstance($host, $user, $pass)
|
|
||||||
{
|
|
||||||
if (!isset(static::$instance)) {
|
|
||||||
static::$instance = new static($user, $pass, $host);
|
|
||||||
}
|
|
||||||
// If current MySQL instance was unable to connect
|
|
||||||
if ((static::$instance->getConnectError())) {
|
|
||||||
// loadClass('Logger')->error('Instance has errors:' . "\r\n" . var_export(static::$instance, true) . "\r\n");
|
|
||||||
}
|
|
||||||
return static::$instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to database
|
|
||||||
*
|
|
||||||
* @param string $err Reference to error message
|
|
||||||
* @param string $user MySQL username
|
|
||||||
* @param string $pass MySQL password
|
|
||||||
* @param string $host MySQL hostname
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function testConnection(&$err, $host, $user, $pass)
|
|
||||||
{
|
|
||||||
$err = false;
|
|
||||||
|
|
||||||
// Silence errors and try to connect
|
|
||||||
error_reporting(0);
|
|
||||||
$link = mysqli_connect($host, $user, $pass);
|
|
||||||
error_reporting(-1);
|
|
||||||
|
|
||||||
if (mysqli_connect_errno()) {
|
|
||||||
$err = 'Failed to connect: ' .mysqli_connect_error();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
mysqli_close($link);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Private Variables
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MySQL Resource
|
|
||||||
* @var resource|null
|
|
||||||
*/
|
*/
|
||||||
private $_link = null;
|
private $_link = null;
|
||||||
|
|
||||||
@ -83,22 +23,21 @@ class Mysql extends _Base implements _iBase
|
|||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Construct/Destructor
|
* Constructor Overwrite
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
/**
|
public function __construct($hostname, $data = array())
|
||||||
* Use singleton getInstance() instead.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
*/
|
|
||||||
public function __construct($user, $pass, $host)
|
|
||||||
{
|
{
|
||||||
|
parent::__construct($hostname, $data);
|
||||||
|
|
||||||
|
$user = $data['user'];
|
||||||
|
$pass = $data['pass'];
|
||||||
|
|
||||||
|
|
||||||
// Silence errors and try to connect
|
// Silence errors and try to connect
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
$link = mysqli_connect($host, $user, $pass);
|
$link = mysqli_connect($hostname, $user, $pass);
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
|
|
||||||
if (mysqli_connect_errno()) {
|
if (mysqli_connect_errno()) {
|
||||||
@ -110,9 +49,6 @@ class Mysql extends _Base implements _iBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Destructor
|
|
||||||
*/
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
if ($this->_link) {
|
if ($this->_link) {
|
||||||
@ -120,9 +56,10 @@ class Mysql extends _Base implements _iBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* MySQL Select functions
|
* Select Functions
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
@ -285,44 +222,89 @@ class Mysql extends _Base implements _iBase
|
|||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
/**
|
private $_can_connect = array();
|
||||||
* Get MySQL Name.
|
private $_can_connect_err = array();
|
||||||
*
|
|
||||||
* @return string MySQL short name.
|
private $_name = null;
|
||||||
*/
|
private $_version = null;
|
||||||
|
|
||||||
|
public function canConnect(&$err, $hostname, $data = array())
|
||||||
|
{
|
||||||
|
$err = false;
|
||||||
|
|
||||||
|
// Return if already cached
|
||||||
|
if (isset($this->_can_connect[$hostname])) {
|
||||||
|
// Assume error for unset error message
|
||||||
|
$err = isset($this->_can_connect_err[$hostname]) ? $this->_can_connect_err[$hostname] : true;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Silence errors and try to connect
|
||||||
|
error_reporting(0);
|
||||||
|
$link = mysqli_connect($hostname, $data['user'], $data['pass']);
|
||||||
|
error_reporting(-1);
|
||||||
|
|
||||||
|
if (mysqli_connect_errno()) {
|
||||||
|
$err = 'Failed to connect: ' .mysqli_connect_error();
|
||||||
|
$this->_can_connect[$hostname] = false;
|
||||||
|
} else {
|
||||||
|
$this->_can_connect[$hostname] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($link) {
|
||||||
|
mysqli_close($link);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_can_connect_err[$hostname] = $err;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
public function getName($default = 'MySQL')
|
public function getName($default = 'MySQL')
|
||||||
{
|
{
|
||||||
if (!static::isAvailable('mysql')) {
|
// Return if already cached
|
||||||
|
if ($this->_name !== null) {
|
||||||
|
return $this->_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return default if not available
|
||||||
|
if (!$this->isAvailable()) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = $this->egrep('/[a-zA-Z0-9]+/', $this->getConfig('version_comment'));
|
$name = loadClass('Helper')->egrep('/[a-zA-Z0-9]+/', $this->getConfig('version_comment'));
|
||||||
|
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
loadClass('Logger')->error('Could not get MySQL Name');
|
loadClass('Logger')->error('Could not get MySQL Name');
|
||||||
return $default;
|
$this->_name = $default;
|
||||||
|
} else {
|
||||||
|
$this->_name = $name;
|
||||||
}
|
}
|
||||||
return $name;
|
|
||||||
|
return $this->_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get MySQL Version.
|
|
||||||
*
|
|
||||||
* @return string MySQL version.
|
|
||||||
*/
|
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
if (!static::isAvailable('mysql')) {
|
// Return if already cached
|
||||||
return '';
|
if ($this->_version !== null) {
|
||||||
|
return $this->_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
$version = $this->egrep('/[.0-9]+/', $this->getConfig('version'));
|
// Return empty if not available
|
||||||
|
if (!$this->isAvailable()) {
|
||||||
|
$this->_version = '';
|
||||||
|
return $this->_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = loadClass('Helper')->egrep('/[.0-9]+/', $this->getConfig('version'));
|
||||||
|
|
||||||
if (!$version) {
|
if (!$version) {
|
||||||
loadClass('Logger')->error('Could not get MySQL version');
|
loadClass('Logger')->error('Could not get MySQL Version');
|
||||||
return '';
|
$this->_version = '';
|
||||||
|
} else {
|
||||||
|
$this->_version = $version;
|
||||||
}
|
}
|
||||||
return $version;
|
|
||||||
|
return $this->_version;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,78 +4,17 @@ namespace devilbox;
|
|||||||
/**
|
/**
|
||||||
* @requires devilbox::Logger
|
* @requires devilbox::Logger
|
||||||
*/
|
*/
|
||||||
class Pgsql extends _Base implements _iBase
|
class Pgsql extends BaseClass implements BaseInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Statics
|
* Variables
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postgres instance
|
* PgSQL connection link
|
||||||
* @var Postgres|null
|
* @var null
|
||||||
*/
|
|
||||||
protected static $instance = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton Instance getter.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
* @return object|null
|
|
||||||
*/
|
|
||||||
public static function getInstance($host = null, $user = null, $pass = null)
|
|
||||||
{
|
|
||||||
if (!isset(static::$instance)) {
|
|
||||||
static::$instance = new static($user, $pass, $host);
|
|
||||||
}
|
|
||||||
// If current Postgres instance was unable to connect
|
|
||||||
if ((static::$instance->getConnectError())) {
|
|
||||||
//loadClass('Logger')->error('Instance has errors:' . "\r\n" . var_export(static::$instance, true) . "\r\n");
|
|
||||||
}
|
|
||||||
return static::$instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to database
|
|
||||||
*
|
|
||||||
* @param string $err Reference to error message
|
|
||||||
* @param string $user Postgres username
|
|
||||||
* @param string $pass Postgres password
|
|
||||||
* @param string $host Postgres hostname
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function testConnection(&$err, $host, $user, $pass)
|
|
||||||
{
|
|
||||||
$err = false;
|
|
||||||
|
|
||||||
// Silence errors and try to connect
|
|
||||||
error_reporting(0);
|
|
||||||
$link = pg_connect('host='.$host.' user='.$user.' password='.$pass);
|
|
||||||
error_reporting(-1);
|
|
||||||
|
|
||||||
if (!$link || pg_connection_status($link) !== PGSQL_CONNECTION_OK) {
|
|
||||||
$err = 'Failed to connect';
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pg_close($link);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Private Variables
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Postgres Resource
|
|
||||||
* @var resource|null
|
|
||||||
*/
|
*/
|
||||||
private $_link = null;
|
private $_link = null;
|
||||||
|
|
||||||
@ -83,7 +22,7 @@ class Pgsql extends _Base implements _iBase
|
|||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Construct/Destructor
|
* Constructor Overwrite
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
@ -95,19 +34,25 @@ class Pgsql extends _Base implements _iBase
|
|||||||
* @param string $host Host
|
* @param string $host Host
|
||||||
* @param string $database Database name
|
* @param string $database Database name
|
||||||
*/
|
*/
|
||||||
public function __construct($user, $pass, $host, $database = null)
|
public function __construct($hostname, $data = array())
|
||||||
{
|
{
|
||||||
|
parent::__construct($hostname, $data);
|
||||||
|
|
||||||
|
$user = $data['user'];
|
||||||
|
$pass = $data['pass'];
|
||||||
|
$db = isset($data['db']) ? $data['db'] : null;
|
||||||
|
|
||||||
// Silence errors and try to connect
|
// Silence errors and try to connect
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
if ($database !== null) {
|
if ($db !== null) {
|
||||||
$link = pg_connect('host='.$host.' dbname='.$database.' user='.$user.' password='.$pass);
|
$link = pg_connect('host='.$hostname.' dbname='.$db.' user='.$user.' password='.$pass);
|
||||||
} else {
|
} else {
|
||||||
$link = pg_connect('host='.$host.' user='.$user.' password='.$pass);
|
$link = pg_connect('host='.$hostname.' user='.$user.' password='.$pass);
|
||||||
}
|
}
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
|
|
||||||
if (!$link || pg_connection_status($link) !== PGSQL_CONNECTION_OK) {
|
if (!$link || pg_connection_status($link) !== PGSQL_CONNECTION_OK) {
|
||||||
$this->setConnectError('Failed to connect to '.$user.'@'.$host);
|
$this->setConnectError('Failed to connect to '.$user.'@'.$hostname);
|
||||||
$this->setConnectErrno(1);
|
$this->setConnectErrno(1);
|
||||||
//loadClass('Logger')->error($this->_connect_error);
|
//loadClass('Logger')->error($this->_connect_error);
|
||||||
} else {
|
} else {
|
||||||
@ -115,21 +60,22 @@ class Pgsql extends _Base implements _iBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
if ($this->_link) {
|
if ($this->_link) {
|
||||||
@pg_close($this->_link);
|
pg_close($this->_link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* PostgreSQL Select functions
|
* Select functions
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
@ -143,10 +89,9 @@ class Pgsql extends _Base implements _iBase
|
|||||||
public function select($query, $callback = null)
|
public function select($query, $callback = null)
|
||||||
{
|
{
|
||||||
if (!$this->_link) {
|
if (!$this->_link) {
|
||||||
loadClass('Logger')->error('Postgres error, link is no resource in select()');
|
loadClass('Logger')->error('Postgres error, link is no resource in select(): \''.$this->_link.'\'');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($result = pg_query($this->_link, $query))) {
|
if (!($result = pg_query($this->_link, $query))) {
|
||||||
$this->setError('PostgreSQL - error on result: '.pg_result_error($result)."\n" . 'query:'."\n" . $query);
|
$this->setError('PostgreSQL - error on result: '.pg_result_error($result)."\n" . 'query:'."\n" . $query);
|
||||||
$this->setErrno(1);
|
$this->setErrno(1);
|
||||||
@ -170,6 +115,7 @@ class Pgsql extends _Base implements _iBase
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all PostgreSQL Databases.
|
* Get all PostgreSQL Databases.
|
||||||
* @return mixed[] Array of databases
|
* @return mixed[] Array of databases
|
||||||
@ -196,9 +142,17 @@ class Pgsql extends _Base implements _iBase
|
|||||||
|
|
||||||
// Get schemas for each database
|
// Get schemas for each database
|
||||||
foreach ($databases as $name => &$database) {
|
foreach ($databases as $name => &$database) {
|
||||||
$PSQL = new Pgsql('postgres', loadClass('Docker')->getEnv('PGSQL_ROOT_PASSWORD'), $GLOBALS['PGSQL_HOST_NAME'], $name);
|
$PSQL = new Pgsql(
|
||||||
|
$this->getIpAddress(),
|
||||||
|
array(
|
||||||
|
'user' => loadClass('Helper')->getEnv('PGSQL_ROOT_USER'),
|
||||||
|
'pass' => loadClass('Helper')->getEnv('PGSQL_ROOT_PASSWORD'),
|
||||||
|
'db' => $name
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$sql = "SELECT n.nspname AS schemas FROM pg_catalog.pg_namespace AS n WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema';";
|
//$sql = "SELECT n.nspname AS schemas FROM pg_catalog.pg_namespace AS n WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema';";
|
||||||
|
$sql = "SELECT n.nspname AS schemas FROM pg_catalog.pg_namespace AS n;";
|
||||||
$callback = function ($row, &$data) {
|
$callback = function ($row, &$data) {
|
||||||
$data[$row['schemas']] = array();
|
$data[$row['schemas']] = array();
|
||||||
};
|
};
|
||||||
@ -219,7 +173,15 @@ class Pgsql extends _Base implements _iBase
|
|||||||
*/
|
*/
|
||||||
public function getSchemaSize($database, $schema)
|
public function getSchemaSize($database, $schema)
|
||||||
{
|
{
|
||||||
$PSQL = new Pgsql('postgres', loadClass('Docker')->getEnv('PGSQL_ROOT_PASSWORD'), $GLOBALS['PGSQL_HOST_ADDR'], $database);
|
$PSQL = new Pgsql(
|
||||||
|
$this->getIpAddress(),
|
||||||
|
array(
|
||||||
|
'user' => loadClass('Helper')->getEnv('PGSQL_ROOT_USER'),
|
||||||
|
'pass' => loadClass('Helper')->getEnv('PGSQL_ROOT_PASSWORD'),
|
||||||
|
'db' => $database
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$callback = function ($row, &$data) {
|
$callback = function ($row, &$data) {
|
||||||
$data = $row['size'];
|
$data = $row['size'];
|
||||||
|
|
||||||
@ -239,6 +201,7 @@ class Pgsql extends _Base implements _iBase
|
|||||||
return $size ? $size : 0;
|
return $size ? $size : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Number of Tables per Schema
|
* Get Number of Tables per Schema
|
||||||
*
|
*
|
||||||
@ -248,7 +211,15 @@ class Pgsql extends _Base implements _iBase
|
|||||||
*/
|
*/
|
||||||
public function getTableCount($database, $schema)
|
public function getTableCount($database, $schema)
|
||||||
{
|
{
|
||||||
$PSQL = new Pgsql('postgres', loadClass('Docker')->getEnv('PGSQL_ROOT_PASSWORD'), $GLOBALS['PGSQL_HOST_ADDR'], $database);
|
$PSQL = new Pgsql(
|
||||||
|
$this->getIpAddress(),
|
||||||
|
array(
|
||||||
|
'user' => loadClass('Helper')->getEnv('PGSQL_ROOT_USER'),
|
||||||
|
'pass' => loadClass('Helper')->getEnv('PGSQL_ROOT_PASSWORD'),
|
||||||
|
'db' => $database
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$callback = function ($row, &$data) {
|
$callback = function ($row, &$data) {
|
||||||
$data = $row['count'];
|
$data = $row['count'];
|
||||||
};
|
};
|
||||||
@ -268,7 +239,6 @@ class Pgsql extends _Base implements _iBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read out PostgreSQL Server configuration by variable
|
* Read out PostgreSQL Server configuration by variable
|
||||||
*
|
*
|
||||||
@ -310,14 +280,51 @@ class Pgsql extends _Base implements _iBase
|
|||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
/**
|
private $_can_connect = array();
|
||||||
* Get PgSQL Name.
|
private $_can_connect_err = array();
|
||||||
*
|
|
||||||
* @return string PgSQL short name.
|
private $_name = null;
|
||||||
*/
|
private $_version = null;
|
||||||
|
|
||||||
|
public function canConnect(&$err, $hostname, $data = array())
|
||||||
|
{
|
||||||
|
$err = false;
|
||||||
|
|
||||||
|
// Return if already cached
|
||||||
|
if (isset($this->_can_connect[$hostname])) {
|
||||||
|
// Assume error for unset error message
|
||||||
|
$err = isset($this->_can_connect_err[$hostname]) ? $this->_can_connect_err[$hostname] : true;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Silence errors and try to connect
|
||||||
|
error_reporting(0);
|
||||||
|
$link = pg_connect('host='.$hostname.' user='.$data['user'].' password='.$data['pass']);
|
||||||
|
error_reporting(-1);
|
||||||
|
|
||||||
|
if (!$link || pg_connection_status($link) !== PGSQL_CONNECTION_OK) {
|
||||||
|
$err = 'Failed to connect to host: '.$hostname;
|
||||||
|
$this->_can_connect[$hostname] = false;
|
||||||
|
} else {
|
||||||
|
$this->_can_connect[$hostname] = true;
|
||||||
|
}
|
||||||
|
if ($link) {
|
||||||
|
pg_close($link);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->_can_connect_err[$hostname] = $err;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
public function getName($default = 'PostgreSQL')
|
public function getName($default = 'PostgreSQL')
|
||||||
{
|
{
|
||||||
if (!static::isAvailable('pgsql')) {
|
// Return if already cached
|
||||||
|
if ($this->_name !== null) {
|
||||||
|
return $this->_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return default if not available
|
||||||
|
if (!$this->isAvailable()) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,36 +332,44 @@ class Pgsql extends _Base implements _iBase
|
|||||||
$data = $row['version'];
|
$data = $row['version'];
|
||||||
};
|
};
|
||||||
|
|
||||||
$name = $this->egrep('/[a-zA-Z0-9]*/', $this->select('SELECT version();', $callback));
|
$name = loadClass('Helper')->egrep('/[a-zA-Z0-9]*/', $this->select('SELECT version();', $callback));
|
||||||
|
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
loadClass('Logger')->error('Could not get PgSQL Name');
|
loadClass('Logger')->error('Could not get PgSQL Name');
|
||||||
return $default;
|
$this->_name = $default;
|
||||||
|
} else {
|
||||||
|
$this->_name = $name;
|
||||||
}
|
}
|
||||||
return $name;
|
|
||||||
|
return $this->_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get PgSQL Version.
|
|
||||||
*
|
|
||||||
* @return string PgSQL version.
|
|
||||||
*/
|
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
if (!static::isAvailable('pgsql')) {
|
// Return if already cached
|
||||||
return '';
|
if ($this->_version !== null) {
|
||||||
|
return $this->_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return empty if not available
|
||||||
|
if (!$this->isAvailable()) {
|
||||||
|
$this->_version = '';
|
||||||
|
return $this->_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
$callback = function ($row, &$data) {
|
$callback = function ($row, &$data) {
|
||||||
$data = $row['version'];
|
$data = $row['version'];
|
||||||
};
|
};
|
||||||
|
|
||||||
$version = $this->egrep('/[.0-9]+/', $this->select('SELECT version();', $callback));
|
$version = loadClass('Helper')->egrep('/[.0-9]+/', $this->select('SELECT version();', $callback));
|
||||||
|
|
||||||
if (!$version) {
|
if (!$version) {
|
||||||
loadClass('Logger')->error('Could not get PgSQL version');
|
loadClass('Logger')->error('Could not get PgSQL version');
|
||||||
return '';
|
$this->_version = '';
|
||||||
|
} else {
|
||||||
|
$this->_version = $version;
|
||||||
}
|
}
|
||||||
return $version;
|
|
||||||
|
return $this->_version;
|
||||||
}
|
}
|
||||||
}
|
}
|
99
.devilbox/www/include/lib/container/Php.php
Normal file
99
.devilbox/www/include/lib/container/Php.php
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
namespace devilbox;
|
||||||
|
|
||||||
|
class Php extends BaseClass implements BaseInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* PHP Select functions
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
public function getConfig($key = null)
|
||||||
|
{
|
||||||
|
// Get all configs as array
|
||||||
|
if ($key === null) {
|
||||||
|
return ini_get_all();
|
||||||
|
} else {
|
||||||
|
return ini_get($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public function getUid()
|
||||||
|
{
|
||||||
|
$output = loadClass('Helper')->exec('id', $output);
|
||||||
|
|
||||||
|
$uid = loadClass('Helper')->egrep('/uid=[0-9]+/', $output);
|
||||||
|
$uid = loadClass('Helper')->egrep('/[0-9]+/', $uid);
|
||||||
|
return $uid;
|
||||||
|
}
|
||||||
|
public function getGid()
|
||||||
|
{
|
||||||
|
$output = loadClass('Helper')->exec('id', $output);
|
||||||
|
|
||||||
|
$uid = loadClass('Helper')->egrep('/gid=[0-9]+/', $output);
|
||||||
|
$uid = loadClass('Helper')->egrep('/[0-9]+/', $uid);
|
||||||
|
return $uid;
|
||||||
|
}
|
||||||
|
public function getGitVersion()
|
||||||
|
{
|
||||||
|
$output = loadClass('Helper')->exec('git --version', $output);
|
||||||
|
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
|
||||||
|
}
|
||||||
|
public function getComposerVersion()
|
||||||
|
{
|
||||||
|
$output = loadClass('Helper')->exec('composer --version', $output);
|
||||||
|
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
|
||||||
|
}
|
||||||
|
public function getDrushVersion()
|
||||||
|
{
|
||||||
|
$output = loadClass('Helper')->exec('drush --version', $output);
|
||||||
|
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
|
||||||
|
}
|
||||||
|
public function getDrushConsoleVersion()
|
||||||
|
{
|
||||||
|
$output = loadClass('Helper')->exec('drush-console --version', $output);
|
||||||
|
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
|
||||||
|
}
|
||||||
|
public function getNodeVersion()
|
||||||
|
{
|
||||||
|
$output = loadClass('Helper')->exec('node --version', $output);
|
||||||
|
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
|
||||||
|
}
|
||||||
|
public function getNpmVersion()
|
||||||
|
{
|
||||||
|
$output = loadClass('Helper')->exec('npm --version', $output);
|
||||||
|
return loadClass('Helper')->egrep('/[0-9.]+/', $output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************************
|
||||||
|
*
|
||||||
|
* Interface required functions
|
||||||
|
*
|
||||||
|
*********************************************************************************/
|
||||||
|
|
||||||
|
public function canConnect(&$err, $hostname, $data = array())
|
||||||
|
{
|
||||||
|
// PHP can always connect, otherwise you could not see anything.
|
||||||
|
$err = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName($default = 'PHP')
|
||||||
|
{
|
||||||
|
if (defined('HHVM_VERSION')) {
|
||||||
|
return 'HHVM';
|
||||||
|
}
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVersion()
|
||||||
|
{
|
||||||
|
if (defined('HHVM_VERSION')) {
|
||||||
|
return HHVM_VERSION . ' php-'.str_replace('-hhvm', '', phpversion());
|
||||||
|
} else {
|
||||||
|
return phpversion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,68 +4,8 @@ namespace devilbox;
|
|||||||
/**
|
/**
|
||||||
* @requires devilbox::Logger
|
* @requires devilbox::Logger
|
||||||
*/
|
*/
|
||||||
class Redis extends _Base implements _iBase
|
class Redis extends BaseClass implements BaseInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/*********************************************************************************
|
|
||||||
*
|
|
||||||
* Statics
|
|
||||||
*
|
|
||||||
*********************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Redis instance
|
|
||||||
* @var Redis|null
|
|
||||||
*/
|
|
||||||
protected static $instance = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Singleton Instance getter.
|
|
||||||
*
|
|
||||||
* @param string $user Username
|
|
||||||
* @param string $pass Password
|
|
||||||
* @param string $host Host
|
|
||||||
* @return object|null
|
|
||||||
*/
|
|
||||||
public static function getInstance($host, $user = null, $pass = null)
|
|
||||||
{
|
|
||||||
if (!isset(static::$instance)) {
|
|
||||||
static::$instance = new static($host);
|
|
||||||
}
|
|
||||||
// If current Redis instance was unable to connect
|
|
||||||
if (!static::$instance) {
|
|
||||||
//loadClass('Logger')->error('Instance has errors:' . "\r\n" . var_export(static::$instance, true) . "\r\n");
|
|
||||||
}
|
|
||||||
return static::$instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to Redis
|
|
||||||
*
|
|
||||||
* @param string $err Reference to error message
|
|
||||||
* @param string $host Redis hostname
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public static function testConnection(&$err, $host, $user = '', $pass = '')
|
|
||||||
{
|
|
||||||
$err = false;
|
|
||||||
|
|
||||||
// Silence errors and try to connect
|
|
||||||
error_reporting(0);
|
|
||||||
$redis = new \Redis();
|
|
||||||
|
|
||||||
if (!$redis->connect($host, 6379)) {
|
|
||||||
$err = 'Failed to connect to Redis host on '.$host;
|
|
||||||
error_reporting(-1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
error_reporting(-1);
|
|
||||||
$redis->close();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Private Variables
|
* Private Variables
|
||||||
@ -80,10 +20,9 @@ class Redis extends _Base implements _iBase
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Construct/Destructor
|
* Constructor Overwrite
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
@ -94,14 +33,16 @@ class Redis extends _Base implements _iBase
|
|||||||
* @param string $pass Password
|
* @param string $pass Password
|
||||||
* @param string $host Host
|
* @param string $host Host
|
||||||
*/
|
*/
|
||||||
public function __construct($host)
|
public function __construct($hostname, $data = array())
|
||||||
{
|
{
|
||||||
|
parent::__construct($hostname, $data);
|
||||||
|
|
||||||
// Silence errors and try to connect
|
// Silence errors and try to connect
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
$redis = new \Redis();
|
$redis = new \Redis();
|
||||||
|
|
||||||
if (!$redis->connect($host, 6379)) {
|
if (!$redis->connect($hostname, 6379)) {
|
||||||
$this->setConnectError('Failed to connect to Redis host on '.$host);
|
$this->setConnectError('Failed to connect to Redis host on '.$hostname);
|
||||||
$this->setConnectErrno(1);
|
$this->setConnectErrno(1);
|
||||||
//loadClass('Logger')->error($this->_connect_error);
|
//loadClass('Logger')->error($this->_connect_error);
|
||||||
} else {
|
} else {
|
||||||
@ -125,7 +66,7 @@ class Redis extends _Base implements _iBase
|
|||||||
|
|
||||||
/*********************************************************************************
|
/*********************************************************************************
|
||||||
*
|
*
|
||||||
* Redis Select functions
|
* Select functions
|
||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
@ -158,6 +99,41 @@ class Redis extends _Base implements _iBase
|
|||||||
*
|
*
|
||||||
*********************************************************************************/
|
*********************************************************************************/
|
||||||
|
|
||||||
|
private $_can_connect = array();
|
||||||
|
private $_can_connect_err = array();
|
||||||
|
|
||||||
|
private $_name = null;
|
||||||
|
private $_version = null;
|
||||||
|
|
||||||
|
public function canConnect(&$err, $hostname, $data = array())
|
||||||
|
{
|
||||||
|
$err = false;
|
||||||
|
|
||||||
|
// Return if already cached
|
||||||
|
if (isset($this->_can_connect[$hostname])) {
|
||||||
|
// Assume error for unset error message
|
||||||
|
$err = isset($this->_can_connect_err[$hostname]) ? $this->_can_connect_err[$hostname] : true;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Silence errors and try to connect
|
||||||
|
//error_reporting(0);
|
||||||
|
$redis = new \Redis();
|
||||||
|
|
||||||
|
if (!$redis->connect($hostname, 6379)) {
|
||||||
|
$err = 'Failed to connect to Redis host on '.$hostname;
|
||||||
|
$this->_can_connect[$hostname] = false;
|
||||||
|
} else {
|
||||||
|
$this->_can_connect[$hostname] = true;
|
||||||
|
}
|
||||||
|
//error_reporting(-1);
|
||||||
|
|
||||||
|
$redis->close();
|
||||||
|
|
||||||
|
$this->_can_connect_err[$hostname] = $err;
|
||||||
|
return $this->_can_connect[$hostname];
|
||||||
|
}
|
||||||
|
|
||||||
public function getName($default = 'Redis')
|
public function getName($default = 'Redis')
|
||||||
{
|
{
|
||||||
return $default;
|
return $default;
|
||||||
@ -165,11 +141,25 @@ class Redis extends _Base implements _iBase
|
|||||||
|
|
||||||
public function getVersion()
|
public function getVersion()
|
||||||
{
|
{
|
||||||
|
// Return if already cached
|
||||||
|
if ($this->_version !== null) {
|
||||||
|
return $this->_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return empty if not available
|
||||||
|
if (!$this->isAvailable()) {
|
||||||
|
$this->_version = '';
|
||||||
|
return $this->_version;
|
||||||
|
}
|
||||||
|
|
||||||
$info = $this->getInfo();
|
$info = $this->getInfo();
|
||||||
if (!isset($info['redis_version'])) {
|
if (!isset($info['redis_version'])) {
|
||||||
loadClass('Logger')->error('Could not get Redis version');
|
loadClass('Logger')->error('Could not get Redis version');
|
||||||
return '';
|
$this->_version = '';
|
||||||
|
} else {
|
||||||
|
$this->_version = $info['redis_version'];
|
||||||
}
|
}
|
||||||
return $info['redis_version'];
|
|
||||||
|
return $this->_version;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user