mirror of
https://github.com/cytopia/devilbox.git
synced 2025-01-03 11:24:14 +00:00
Intranet: Better error handling
This commit is contained in:
parent
c7919f572b
commit
579ca1aabc
@ -141,28 +141,28 @@
|
|||||||
<?php $error; $valid = php_has_valid_mysql_socket($error); ?>
|
<?php $error; $valid = php_has_valid_mysql_socket($error); ?>
|
||||||
<th>MySQL socket</th>
|
<th>MySQL socket</th>
|
||||||
<td class="<?php echo !$valid ? 'bg-danger' : '';?>">
|
<td class="<?php echo !$valid ? 'bg-danger' : '';?>">
|
||||||
<?php echo !$valid ? 'Error' : $ENV['MYSQL_SOCKET_PATH']; ?>
|
<?php echo !$valid ? 'Error<br/><sub>'.$error.'</sub>' : $ENV['MYSQL_SOCKET_PATH']; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<?php $err; $valid = my_mysql_connection_test($err, 'localhost'); ?>
|
<?php $err; $valid = my_mysql_connection_test($err, 'localhost'); ?>
|
||||||
<th>MySQL test</th>
|
<th>MySQL test</th>
|
||||||
<td class="<?php echo !$valid ? 'bg-danger' : '';?>">
|
<td class="<?php echo !$valid ? 'bg-danger' : '';?>">
|
||||||
<?php echo $valid ? '<span class="bg-success">OK</span> localhost:3306' : 'Failoed: localhost:3306'; ?>
|
<?php echo $valid ? '<span class="bg-success">OK</span> localhost:3306' : 'Failed: localhost:3306<br/><sub>'.$err.'</sub>'; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<?php $err; $valid = my_mysql_connection_test($err, '127.0.0.1'); ?>
|
<?php $err; $valid = my_mysql_connection_test($err, '127.0.0.1'); ?>
|
||||||
<th>MySQL test</th>
|
<th>MySQL test</th>
|
||||||
<td class="<?php echo !$valid ? 'bg-danger' : '';?>">
|
<td class="<?php echo !$valid ? 'bg-danger' : '';?>">
|
||||||
<?php echo $valid ? '<span class="bg-success">OK</span> 127.0.0.1:3306' : 'Failed: 127.0.0.1:3306'; ?>
|
<?php echo $valid ? '<span class="bg-success">OK</span> 127.0.0.1:3306' : 'Failed: 127.0.0.1:3306<br/><sub>'.$err.'</sub>'; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<?php $err; $valid = my_mysql_connection_test($err, $MYSQL_HOST_ADDR); ?>
|
<?php $err; $valid = my_mysql_connection_test($err, $MYSQL_HOST_ADDR); ?>
|
||||||
<th>MySQL test</th>
|
<th>MySQL test</th>
|
||||||
<td class="<?php echo !$valid ? 'bg-danger' : '';?>">
|
<td class="<?php echo !$valid ? 'bg-danger' : '';?>">
|
||||||
<?php echo $valid ? '<span class="bg-success">OK</span> '.$MYSQL_HOST_ADDR.':3306' : 'Failed: '.$MYSQL_HOST_ADDR.':3306'; ?>
|
<?php echo $valid ? '<span class="bg-success">OK</span> '.$MYSQL_HOST_ADDR.':3306' : 'Failed: '.$MYSQL_HOST_ADDR.':3306<br/><sub>'.$err.'</sub>'; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -300,6 +300,9 @@
|
|||||||
<td>./etc</td>
|
<td>./etc</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>MySQL socket</th>
|
||||||
|
<td>./run/mysql/mysqld.sock</td>
|
||||||
|
</tr> <tr>
|
||||||
<th>Log directory</th>
|
<th>Log directory</th>
|
||||||
<td>./log</td>
|
<td>./log</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -112,6 +112,10 @@ function my_mysqli_close($link) {
|
|||||||
*/
|
*/
|
||||||
function my_mysqli_select(&$err, $link, $query, $callback = NULL)
|
function my_mysqli_select(&$err, $link, $query, $callback = NULL)
|
||||||
{
|
{
|
||||||
|
if (!$link) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!($result = mysqli_query($link, $query))) {
|
if (!($result = mysqli_query($link, $query))) {
|
||||||
$err = mysqli_error($link);
|
$err = mysqli_error($link);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -166,7 +170,9 @@ function getDatabases() {
|
|||||||
S.SCHEMA_NAME != 'performance_schema' AND
|
S.SCHEMA_NAME != 'performance_schema' AND
|
||||||
S.SCHEMA_NAME != 'information_schema'";
|
S.SCHEMA_NAME != 'information_schema'";
|
||||||
|
|
||||||
return my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback);
|
$databases = my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback);
|
||||||
|
|
||||||
|
return $databases ? $databases : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -249,8 +255,9 @@ function getMySQLConfig() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$sql = 'SHOW VARIABLES;';
|
$sql = 'SHOW VARIABLES;';
|
||||||
return my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback);
|
$configs = my_mysqli_select($error, $GLOBALS['MY_MYSQL_LINK'], $sql, $callback);
|
||||||
|
|
||||||
|
return $configs ? $configs : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -269,10 +276,10 @@ function php_has_valid_mysql_socket(&$error) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getMySQLConfigByKey('socket') != $ENV['MYSQL_SOCKET_PATH']) {
|
//if (getMySQLConfigByKey('socket') != $ENV['MYSQL_SOCKET_PATH']) {
|
||||||
$error = 'Mounted from mysql:'.$ENV['MYSQL_SOCKET_PATH']. ', but socket is in mysql:'.getMySQLConfigByKey('socket');
|
// $error = 'Mounted from mysql:'.$ENV['MYSQL_SOCKET_PATH']. ', but socket is in mysql:'.getMySQLConfigByKey('socket');
|
||||||
return FALSE;
|
// return FALSE;
|
||||||
}
|
//}
|
||||||
|
|
||||||
$error = '';
|
$error = '';
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -421,9 +428,14 @@ function getHttpVersion() {
|
|||||||
* Get MySQL Version
|
* Get MySQL Version
|
||||||
* @return [type] [description]
|
* @return [type] [description]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getMySQLVersion() {
|
function getMySQLVersion() {
|
||||||
return getMySQLConfigByKey('version_comment') . ' ' . getMySQLConfigByKey('version');
|
$name = getMySQLConfigByKey('version_comment');
|
||||||
|
$version = getMySQLConfigByKey('version');
|
||||||
|
|
||||||
|
if (!$name && !$version) {
|
||||||
|
return 'Unknown Version';
|
||||||
|
}
|
||||||
|
return $name . ' ' . $version;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPHPVersion() {
|
function getPHPVersion() {
|
||||||
|
Loading…
Reference in New Issue
Block a user