40 lines
1.2 KiB
INI
40 lines
1.2 KiB
INI
<?php
|
|
|
|
// Observium MySQL Agent Script -> Config File
|
|
// (c) 2012, Tom Laermans for Observium (www.observium.org)
|
|
|
|
// Autodetect user/pass on Debian, please configure if other distro.
|
|
|
|
if (is_readable('/etc/mysql/debian.cnf'))
|
|
{
|
|
//$mysql_cnf = parse_ini_file('/etc/mysql/debian.cnf', TRUE); // parse_ini_file(), hash marks (#) are no longer recognized as comments in php7
|
|
$mysql_ini = preg_replace('/^\s*#/', ';', file_get_contents('/etc/mysql/debian.cnf'));
|
|
$mysql_cnf = parse_ini_string($mysql_ini, TRUE);
|
|
|
|
$mysql_user = $mysql_cnf['client']['user'];
|
|
$mysql_pass = $mysql_cnf['client']['password'];
|
|
}
|
|
else if (is_readable('/root/.my.cnf'))
|
|
{
|
|
//$mysql_cnf = parse_ini_file('/root/.my.cnf', TRUE);
|
|
$mysql_ini = preg_replace('/^\s*#/', ';', file_get_contents('/root/.my.cnf')); // parse_ini_file(), hash marks (#) are no longer recognized as comments in php7
|
|
$mysql_cnf = parse_ini_string($mysql_ini, TRUE);
|
|
|
|
$mysql_user = $mysql_cnf['client']['user'];
|
|
if ($mysql_cnf['client']['password'] != '')
|
|
{
|
|
$mysql_pass = $mysql_cnf['client']['password'];
|
|
}
|
|
else
|
|
{
|
|
$mysql_pass = $mysql_cnf['client']['pass'];
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$mysql_user = '';
|
|
$mysql_pass = '';
|
|
}
|
|
|
|
// EOF
|