2017-05-15 06:56:17 +00:00
|
|
|
<?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'
|
|
|
|
),
|
2017-05-22 21:20:20 +00:00
|
|
|
array(
|
|
|
|
'name' => 'MongoDB DB',
|
|
|
|
'path' => '/db_mongo.php'
|
|
|
|
),
|
2017-05-15 06:56:17 +00:00
|
|
|
array(
|
|
|
|
'name' => 'Redis DB',
|
|
|
|
'path' => '/db_redis.php'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => 'Memcached DB',
|
|
|
|
'path' => '/db_memcd.php'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => 'Info',
|
|
|
|
'menu' => array(
|
2017-05-16 14:59:21 +00:00
|
|
|
array(
|
|
|
|
'name' => 'Httpd Info',
|
|
|
|
'path' => '/info_httpd.php'
|
|
|
|
),
|
2017-05-15 06:56:17 +00:00
|
|
|
array(
|
|
|
|
'name' => 'PHP Info',
|
|
|
|
'path' => '/info_php.php'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => 'MySQL Info',
|
|
|
|
'path' => '/info_mysql.php'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => 'PgSQL Info',
|
|
|
|
'path' => '/info_pgsql.php'
|
|
|
|
),
|
2017-05-22 21:20:20 +00:00
|
|
|
array(
|
|
|
|
'name' => 'MongoDB Info',
|
|
|
|
'path' => '/info_mongo.php'
|
|
|
|
),
|
2017-05-15 06:56:17 +00:00
|
|
|
array(
|
|
|
|
'name' => 'Redis Info',
|
|
|
|
'path' => '/info_redis.php'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => 'Memcached Info',
|
|
|
|
'path' => '/info_memcd.php'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'name' => 'Tools',
|
|
|
|
'menu' => array(
|
2018-08-12 08:52:13 +00:00
|
|
|
array(
|
|
|
|
'name' => 'Adminer',
|
2018-12-15 23:29:50 +00:00
|
|
|
'path' => '__ADMINER__',
|
2018-08-12 08:52:13 +00:00
|
|
|
'target' => '_blank'
|
|
|
|
),
|
2017-05-15 06:56:17 +00:00
|
|
|
array(
|
|
|
|
'name' => 'phpMyAdmin',
|
|
|
|
'path' => '__PHPMYADMIN__',
|
|
|
|
'target' => '_blank'
|
|
|
|
),
|
2018-12-28 21:38:09 +00:00
|
|
|
array(
|
|
|
|
'name' => 'phpPgAdmin',
|
|
|
|
'path' => '__PHPPGADMIN__',
|
|
|
|
'target' => '_blank'
|
|
|
|
),
|
2017-05-15 06:56:17 +00:00
|
|
|
array(
|
2018-08-12 08:52:13 +00:00
|
|
|
'name' => 'PHPRedMin',
|
|
|
|
'path' => '/vendor/phpredmin/public/index.php',
|
2017-09-09 06:29:22 +00:00
|
|
|
'target' => '_blank'
|
2017-05-15 06:56:17 +00:00
|
|
|
),
|
|
|
|
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();
|
2017-09-09 08:40:07 +00:00
|
|
|
$logout = '';
|
|
|
|
if (loadClass('Helper')->isLoginProtected()) {
|
|
|
|
$logout = '<ul class="navbar-nav">'.
|
|
|
|
'<li class="nav-item text-right"><a class="nav-link" href="/logout.php?id='.session_id().'">Log out</a></li>'.
|
|
|
|
'</ul>';
|
|
|
|
}
|
2017-05-15 06:56:17 +00:00
|
|
|
|
|
|
|
$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">
|
2017-10-16 07:17:27 +00:00
|
|
|
<img src="/assets/img/logo.png" width="30" height="30" class="d-inline-block align-top" alt="">devilbox
|
2017-05-15 06:56:17 +00:00
|
|
|
</a>
|
|
|
|
|
|
|
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
|
|
<ul class="navbar-nav mr-auto">
|
|
|
|
|
|
|
|
{$menu}
|
|
|
|
|
2017-09-09 08:40:07 +00:00
|
|
|
|
2017-05-15 06:56:17 +00:00
|
|
|
</ul>
|
2017-09-09 08:40:07 +00:00
|
|
|
{$logout}
|
2017-05-15 06:56:17 +00:00
|
|
|
</div>
|
2017-09-09 08:40:07 +00:00
|
|
|
|
2017-05-15 06:56:17 +00:00
|
|
|
</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;
|
2017-05-22 21:20:20 +00:00
|
|
|
case 'mongo':
|
|
|
|
$class = 'bg-danger';
|
|
|
|
$version = loadClass('Mongo')->getVersion();
|
|
|
|
$available = loadClass('Mongo')->isAvailable();
|
|
|
|
$name = loadClass('Mongo')->getName();
|
|
|
|
break;
|
2017-05-15 06:56:17 +00:00
|
|
|
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__') {
|
2018-12-16 14:31:03 +00:00
|
|
|
$el['path'] = (version_compare(loadClass('Php')->getVersion(), '5.5', '<')) ? '/vendor/phpmyadmin-4.0/index.php' : '/vendor/phpmyadmin-4.8.4/index.php';
|
2018-12-15 23:29:50 +00:00
|
|
|
}
|
2018-12-28 21:38:09 +00:00
|
|
|
if ($el['path'] == '__PHPPGADMIN__') {
|
|
|
|
$el['path'] = (version_compare(loadClass('Php')->getVersion(), '5.2', '<')) ? '/vendor/phpmyadmin-4.0/' : '/vendor/phppgadmin-5.6.0/';
|
|
|
|
}
|
2018-12-15 23:29:50 +00:00
|
|
|
if ($el['path'] == '__ADMINER__') {
|
2019-02-03 12:13:26 +00:00
|
|
|
$el['path'] = (version_compare(loadClass('Php')->getVersion(), '5.4', '<')) ? '/vendor/adminer-4.6.3-en.php' : '/vendor/adminer-4.7.1-en.php';
|
2017-05-15 06:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
}
|