diff --git a/docker-compose.yml b/docker-compose.yml index 3afe4461..6b1f55d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -222,6 +222,7 @@ services: # Runtime settings - MYSQL_GENERAL_LOG=${MYSQL_GENERAL_LOG} + - MYSQL_INNODB_LOG_FILE_SIZE=${MYSQL_INNODB_LOG_FILE_SIZE} - MYSQL_INNODB_BUFFER_POOL_SIZE=${MYSQL_INNODB_BUFFER_POOL_SIZE} - MYSQL_JOIN_BUFFER_SIZE=${MYSQL_JOIN_BUFFER_SIZE} - MYSQL_SORT_BUFFER_SIZE=${MYSQL_SORT_BUFFER_SIZE} @@ -229,6 +230,10 @@ services: - MYSQL_SYMBOLIC_LINKS=${MYSQL_SYMBOLIC_LINKS} - MYSQL_SQL_MODE=${MYSQL_SQL_MODE} + # Used for repairing + - MYSQL_INNODB_FORCE_RECOVERY=${MYSQL_INNODB_FORCE_RECOVERY} + - MYSQL_MODE=${MYSQL_MODE} + ports: # [local-machine:]local-port:docker-port - "127.0.0.1:3306:3306" diff --git a/www/config.php b/www/config.php index 732ae0fa..eac981cf 100644 --- a/www/config.php +++ b/www/config.php @@ -1,5 +1,5 @@ tbody>tr.success>td, +.table>tbody>tr.success>th, +.table>tbody>tr>td.success, +.table>tbody>tr>th.success, +.table>tfoot>tr.success>td, +.table>tfoot>tr.success>th, +.table>tfoot>tr>td.success, +.table>tfoot>tr>th.success, +.table>thead>tr.success>td, +.table>thead>tr.success>th, +.table>thead>tr>td.success, +.table>thead>tr>th.success { + background-color: #dff0d8; +} +.table>tbody>tr.danger>td, +.table>tbody>tr.danger>th, +.table>tbody>tr>td.danger, +.table>tbody>tr>th.danger, +.table>tfoot>tr.danger>td, +.table>tfoot>tr.danger>th, +.table>tfoot>tr>td.danger, +.table>tfoot>tr>th.danger, +.table>thead>tr.danger>td, +.table>thead>tr.danger>th, +.table>thead>tr>td.danger, +.table>thead>tr>th.danger { + background-color: #f2dede; +} + + + + + + + + +.text-right { + text-align: right; +} + + + +/******************************************************************************** + * Clearings + ********************************************************************************/ + +.btn-group-vertical>.btn-group:after, .btn-toolbar:after, .clearfix:after, .container-fluid:after, .container:after, .dl-horizontal dd:after, .form-horizontal .form-group:after, .modal-footer:after, .modal-header:after, .nav:after, .navbar-collapse:after, .navbar-header:after, .navbar:after, .pager:after, .panel-body:after, .row:after { + clear: both; +} +.btn-group-vertical>.btn-group:after, .btn-group-vertical>.btn-group:before, .btn-toolbar:after, .btn-toolbar:before, .clearfix:after, .clearfix:before, .container-fluid:after, .container-fluid:before, .container:after, .container:before, .dl-horizontal dd:after, .dl-horizontal dd:before, .form-horizontal .form-group:after, .form-horizontal .form-group:before, .modal-footer:after, .modal-footer:before, .modal-header:after, .modal-header:before, .nav:after, .nav:before, .navbar-collapse:after, .navbar-collapse:before, .navbar-header:after, .navbar-header:before, .navbar:after, .navbar:before, .pager:after, .pager:before, .panel-body:after, .panel-body:before, .row:after, .row:before { + display: table; + content: " "; +} +:after, :before { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + + + + + + /******************************************************************************** diff --git a/www/htdocs/databases.php b/www/htdocs/databases.php index 995ecc57..e8735da3 100644 --- a/www/htdocs/databases.php +++ b/www/htdocs/databases.php @@ -54,6 +54,7 @@ Name Charset Collation + Tables Size @@ -63,8 +64,10 @@ - MB +      +          + @@ -73,7 +76,7 @@ - + diff --git a/www/htdocs/index.php b/www/htdocs/index.php index 26c64bae..9f853de7 100644 --- a/www/htdocs/index.php +++ b/www/htdocs/index.php @@ -213,6 +213,13 @@ sql_mode = - + + diff --git a/www/htdocs/php.php b/www/htdocs/php.php index d287e32f..69836673 100644 --- a/www/htdocs/php.php +++ b/www/htdocs/php.php @@ -47,5 +47,13 @@ + + diff --git a/www/htdocs/vhosts.php b/www/htdocs/vhosts.php index 0b758ff9..f8a1a947 100644 --- a/www/htdocs/vhosts.php +++ b/www/htdocs/vhosts.php @@ -45,7 +45,7 @@
- + @@ -57,43 +57,21 @@ + - htdocs directory in: '.$ENV['HOST_PATH_TO_WWW_DOCROOTS'].'/'.$vHost['name'].'/'; - $ern++; - } - if ($vHost['dns_ok']) { - - if ($vHost['dns_ip'] != '127.0.0.1') { - $err[] = 'Error in /etc/hosts
'. - 'Found:
'. - ''.$vHost['dns_ip'].' '.$vHost['domain'].'
'. - 'But it should be:
'. - '127.0.0.1 '.$vHost['domain'].'
'; - $ern++; - - } - } else { - $err[] = 'Missing entry in /etc/hosts:
127.0.0.1 '.$vHost['domain'].''; - $ern++; - } - ?> - - - - - - + + +
//htdocs - ', $err); ?> - OK   
@@ -107,5 +85,50 @@
+ + diff --git a/www/include/footer.php b/www/include/footer.php new file mode 100644 index 00000000..3645aaa5 --- /dev/null +++ b/www/include/footer.php @@ -0,0 +1,6 @@ + + \ No newline at end of file diff --git a/www/include/functions.php b/www/include/functions.php index 15ab142b..e43c70f5 100644 --- a/www/include/functions.php +++ b/www/include/functions.php @@ -1,6 +1,13 @@ getMessage().': '.mysqli_connect_error(); + return FALSE; + } + +// if (!($link = @mysqli_connect($host, $user, $pass))) { +// $err = mysqli_connect_error(); +// return FALSE; +// } + return $link; +} + +/** + * Close Database connection + * + * @param [type] $link [description] + * @return [type] [description] + */ +function my_mysqli_close($link) { + return mysqli_close($link); +} + + +/** + * Query Database + * + * @param [type] $err [description] + * @param [type] $link [description] + * @param [type] $query [description] + * @param [type] $callback [description] + * @return [type] [description] + */ +function my_mysqli_select(&$err, $link, $query, $callback = NULL) +{ + if (!($result = mysqli_query($link, $query))) { + $err = mysqli_error($link); + return FALSE; + } + + $data = array(); + + if ($callback) { + while ($row = $result->fetch_array(MYSQLI_ASSOC)) { + $callback($row, $data); + } + } else { + $data[] = $row; + } + mysqli_free_result($result); + + return $data; +} + + + + /******************************************************************************** * - * G E T D A T A + * M Y S Q L F U N C T I O N S * ********************************************************************************/ @@ -20,9 +106,13 @@ function my_exec($cmd, &$output = '') * @return mixed Array of name => size */ function getDatabases() { - global $MYSQL_HOST_ADDR; - global $MYSQL_ROOT_PASS; - $conn = mysqli_connect($MYSQL_HOST_ADDR, 'root', $MYSQL_ROOT_PASS); + $error; + $callback = function ($row, &$data) { + $data[$row['database']] = array( + 'charset' => $row['charset'], + 'collation' => $row['collation'] + ); + }; $sql = "SELECT S.SCHEMA_NAME AS 'database', @@ -35,46 +125,160 @@ function getDatabases() { S.SCHEMA_NAME != 'performance_schema' AND S.SCHEMA_NAME != 'information_schema'"; - $result = mysqli_query($conn, $sql); - $data = array(); - while ($row = $result->fetch_array(MYSQLI_ASSOC)) { - $data[$row['database']] = array( - 'charset' => $row['charset'], - 'collation' => $row['collation'], - //'size' => $row['size'], - ); - } - mysqli_close($conn); - return $data; + return my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback); } +/** + * Get Database size in Megabytes + * @param [type] $db_name [description] + * @return [type] [description] + */ function getDBSize($db_name) { - global $MYSQL_HOST_ADDR; - global $MYSQL_ROOT_PASS; - $conn = mysqli_connect($MYSQL_HOST_ADDR, 'root', $MYSQL_ROOT_PASS); + $error; + $callback = function ($row, &$data) { + $data = $row['size']; + }; $sql = "SELECT - SUM( T.data_length + T.index_length ) / 1048576 AS 'size' + ROUND( SUM((T.data_length+T.index_length)/1048576), 2 ) AS 'size' FROM information_schema.TABLES AS T WHERE T.TABLE_SCHEMA = '".$db_name."';"; - $result = mysqli_query($conn, $sql); - $data = array(); - $size = 0; - while ($row = $result->fetch_array(MYSQLI_ASSOC)) { - $size = $row['size']; - } - mysqli_close($conn); - return $size ? $size : '0'; + $size = my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback); + return $size ? $size : 0; + } +/** + * Get Number of Tables per Database + * @param [type] $db_name [description] + * @return [type] [description] + */ +function getTableCount($db_name) { + $error; + $callback = function ($row, &$data) { + $data = $row['count']; + }; + + $sql = "SELECT + COUNT(*) AS 'count' + FROM + information_schema.TABLES AS T + WHERE + T.TABLE_SCHEMA = '".$db_name."';"; + + $count = my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback); + return $count ? $count : 0; +} + + + +/** + * Read out MySQL Server variables + * + * @param [type] $key [description] + * @return [type] [description] + */ +function getMySQLConfig($key) { + $key = str_replace('-', '_', $key); + + $callback = function ($row, &$data) use ($key) { + $data = isset($row['Value']) ? $row['Value'] : FALSE; + }; + + $sql = 'SHOW VARIABLES WHERE Variable_Name = "'.$key.'";'; + $val = my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback); + + if (!is_array($val)) { + return $val; + } else if (is_array($val) && $val) { + return print_r($val, TRUE); + } else { + return ''; + } +} + + + + + + + + function is_valid_dir($path) { return (is_dir($path) || (is_link($path) && is_dir(readlink($path)))); } +function getVirtualHosts() +{ + $docRoot = '/shared/httpd'; + $vhosts = array(); + + if ($handle = opendir($docRoot)) { + while (false !== ($directory = readdir($handle))) { + if (is_valid_dir($docRoot . DIRECTORY_SEPARATOR . $directory) && $directory != '.' && $directory != '..') { + + $vhosts[] = array( + 'name' => $directory, + 'domain' => $directory.'.loc', + 'href' => 'http://' . $directory.'.loc' + ); + } + } + } + + return $vhosts; +} +function checkVirtualHost($vhost) +{ + global $ENV; + + $docRoot = '/shared/httpd'; + $htdocs = $docRoot.DIRECTORY_SEPARATOR.$vhost.DIRECTORY_SEPARATOR.'htdocs'; + $domain = $vhost.'.loc'; + $url = 'http://'.$domain; + $error = array(); + + + // 1. Check htdocs folder + if (!is_valid_dir($htdocs)) { + $error[] = 'Missing htdocs directory in: '.$ENV['HOST_PATH_TO_WWW_DOCROOTS'].'/'.$vhost.'/'; + } + + + // 2. Check /etc/resolv DNS entry + $output; + if (my_exec('getent hosts '.$domain, $output) !== 0) { + $error[] = 'Missing entry in /etc/hosts:
127.0.0.1 '.$domain.''; + } + + // 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 /etc/hosts
'. + 'Found:
'. + ''.$dns_ip.' '.$domain.'
'. + 'But it should be:
'. + '127.0.0.1 '.$domain.'
'; + } + + if (is_array($error) && count($error)) { + return implode('
', $error); + } else { + return ''; + } +} + + /** * Get all VirtualHosts * @return [type] [description] @@ -120,6 +324,9 @@ function getVhosts() { + + + /******************************************************************************** * * G E T V E R S I O N @@ -153,24 +360,6 @@ function getPHPVersion() { -function getMySQLConfig($key) { - global $MYSQL_HOST_ADDR; - global $MYSQL_ROOT_PASS; - - $link = @mysqli_connect($MYSQL_HOST_ADDR, 'root', $MYSQL_ROOT_PASS); - - if (!$link) { - return 'Cannot conncet to MySQL Database: '.mysqli_connect_error(); - } - $key = str_replace('-', '_', $key); - $query = 'SHOW VARIABLES WHERE Variable_Name = "'.$key.'";'; - $result = mysqli_query($link, $query); - $data = mysqli_fetch_array($result); - if (isset($data[1])) { - return $data[1]; - } - return FALSE; -}