bugfixing : Populating the db_servers table while dbusers table is empty did not work.
This commit is contained in:
parent
dcc53d6156
commit
ed5886cb1e
|
@ -9,18 +9,57 @@ if(!function_exists('mysql_connect')) {
|
||||||
|
|
||||||
// we don't check our AlternC session
|
// we don't check our AlternC session
|
||||||
if(!chdir("/usr/share/alternc/panel"))
|
if(!chdir("/usr/share/alternc/panel"))
|
||||||
exit(1);
|
exit(1);
|
||||||
require("/usr/share/alternc/panel/class/config_nochk.php");
|
require("/usr/share/alternc/panel/class/config_nochk.php");
|
||||||
|
|
||||||
|
|
||||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
// FIRST PART : populate the table db_servers
|
// 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
|
// populate it if there is not entry
|
||||||
$db->query("select * from db_servers;");
|
$db->query("select * from db_servers;");
|
||||||
if ($db->num_rows()==0) {
|
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
|
// set the membres.db_server_id
|
||||||
|
|
Loading…
Reference in New Issue