mirror of
https://github.com/cytopia/devilbox.git
synced 2024-12-22 06:07:48 +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); ?>
|
||||
<th>MySQL socket</th>
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php $err; $valid = my_mysql_connection_test($err, 'localhost'); ?>
|
||||
<th>MySQL test</th>
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php $err; $valid = my_mysql_connection_test($err, '127.0.0.1'); ?>
|
||||
<th>MySQL test</th>
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php $err; $valid = my_mysql_connection_test($err, $MYSQL_HOST_ADDR); ?>
|
||||
<th>MySQL test</th>
|
||||
<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>
|
||||
</tr>
|
||||
|
||||
@ -300,6 +300,9 @@
|
||||
<td>./etc</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>MySQL socket</th>
|
||||
<td>./run/mysql/mysqld.sock</td>
|
||||
</tr> <tr>
|
||||
<th>Log directory</th>
|
||||
<td>./log</td>
|
||||
</tr>
|
||||
|
@ -112,6 +112,10 @@ function my_mysqli_close($link) {
|
||||
*/
|
||||
function my_mysqli_select(&$err, $link, $query, $callback = NULL)
|
||||
{
|
||||
if (!$link) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!($result = mysqli_query($link, $query))) {
|
||||
$err = mysqli_error($link);
|
||||
return FALSE;
|
||||
@ -166,7 +170,9 @@ function getDatabases() {
|
||||
S.SCHEMA_NAME != 'performance_schema' AND
|
||||
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;';
|
||||
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;
|
||||
}
|
||||
|
||||
if (getMySQLConfigByKey('socket') != $ENV['MYSQL_SOCKET_PATH']) {
|
||||
$error = 'Mounted from mysql:'.$ENV['MYSQL_SOCKET_PATH']. ', but socket is in mysql:'.getMySQLConfigByKey('socket');
|
||||
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;
|
||||
@ -421,9 +428,14 @@ function getHttpVersion() {
|
||||
* Get MySQL Version
|
||||
* @return [type] [description]
|
||||
*/
|
||||
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user