bugfixing : Populating the db_servers table while dbusers table is empty did not work.
This commit is contained in:
parent
dcc53d6156
commit
ed5886cb1e
|
@ -16,11 +16,50 @@ require("/usr/share/alternc/panel/class/config_nochk.php");
|
|||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// FIRST PART : populate the table db_servers
|
||||
|
||||
$l = $mysql->dbus;
|
||||
|
||||
# Use the dbusers file if exist, else use default alternc configuration
|
||||
if ( is_readable("/etc/alternc/dbusers.cnf") ) {
|
||||
$mysqlconf=file_get_contents("/etc/alternc/dbusers.cnf");
|
||||
} else {
|
||||
$mysqlconf=file_get_contents("/etc/alternc/my.cnf");
|
||||
}
|
||||
$mysqlconf=explode("\n",$mysqlconf);
|
||||
|
||||
# Read the configuration
|
||||
foreach ($mysqlconf as $line) {
|
||||
# First, read the "standard" configuration
|
||||
if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
|
||||
switch ($regs[1]) {
|
||||
case "user":
|
||||
$user = $regs[2];
|
||||
break;
|
||||
case "password":
|
||||
$password = $regs[2];
|
||||
break;
|
||||
case "host":
|
||||
$host = $regs[2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
# Then, read specific alternc configuration
|
||||
if (preg_match('/^#alternc_var ([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
|
||||
$$regs[1]=$regs[2];
|
||||
}
|
||||
}
|
||||
|
||||
# Set value of human_host if unset
|
||||
if (! isset($human_hostname) || empty($human_hostname)) {
|
||||
if ( checkip($host) || checkipv6($host) ) {
|
||||
$human_hostname = gethostbyaddr($host);
|
||||
} else {
|
||||
$human_hostname = $host;
|
||||
}
|
||||
}
|
||||
|
||||
// populate it if there is not entry
|
||||
$db->query("select * from db_servers;");
|
||||
if ($db->num_rows()==0) {
|
||||
$db->query(" insert into db_servers (name, host, login, password, client) values ('".mysql_escape_string($l->HumanHostname)."','".mysql_escape_string($l->Host)."','".mysql_escape_string($l->User)."','".mysql_escape_string($l->Password)."','".mysql_escape_string($L_MYSQL_CLIENT)."');");
|
||||
$db->query(" insert into db_servers (name, host, login, password, client) values ('".mysql_escape_string($human_hostname)."','".mysql_escape_string($host)."','".mysql_escape_string($user)."','".mysql_escape_string($password)."','".mysql_escape_string($L_MYSQL_CLIENT)."');");
|
||||
}
|
||||
|
||||
// set the membres.db_server_id
|
||||
|
|
Loading…
Reference in New Issue