Alternc  latest
Alternc logiel libre pour l'hébergement
3.1.0~b.php
Go to the documentation of this file.
1 #!/usr/bin/php
2 <?php
3 
4 // we don't check our AlternC session
5 if(!chdir("/usr/share/alternc/panel"))
6 exit(1);
7 require("/usr/share/alternc/panel/class/config_nochk.php");
8 
9 
10 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 // FIRST PART : populate the table db_servers
12 
13 
14 # Use the dbusers file if exist, else use default alternc configuration
15 if ( is_readable("/etc/alternc/dbusers.cnf") ) {
16  $mysqlconf=file_get_contents("/etc/alternc/dbusers.cnf");
17 } else {
18  $mysqlconf=file_get_contents("/etc/alternc/my.cnf");
19 }
20 $mysqlconf=explode("\n",$mysqlconf);
21 
22 # Read the configuration
23 foreach ($mysqlconf as $line) {
24 # First, read the "standard" configuration
25  if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
26  switch ($regs[1]) {
27  case "user":
28  $user = $regs[2];
29  break;
30  case "password":
31  $password = $regs[2];
32  break;
33  case "host":
34  $host = $regs[2];
35  break;
36  }
37  }
38 # Then, read specific alternc configuration
39  if (preg_match('/^#alternc_var ([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
40  $$regs[1]=$regs[2];
41  }
42 }
43 
44 # Set value of human_host if unset
45 if (! isset($human_hostname) || empty($human_hostname)) {
46  if ( checkip($host) || checkipv6($host) ) {
47  $human_hostname = gethostbyaddr($host);
48  } else {
49  $human_hostname = $host;
50  }
51 }
52 
53 // populate it if there is not entry
54 $db->query("select * from db_servers;");
55 if ($db->num_rows()==0) {
56  $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)."');");
57 }
58 
59 // set the membres.db_server_id
60 $db->query(" update membres set db_server_id = (select max(id) from db_servers) where db_server_id is null ;");
61 
62 // END of db_servers part
63 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
64 
65 ?>
$mysqlconf
Definition: 3.1.0~b.php:20
exit
Definition: adm_doadd.php:70
global $db
Definition: bootstrap.php:26
$host
Definition: config.php:71
checkipv6($ip)
Check that $ip is a correct ipv6 ip.
Definition: functions.php:221
checkip($ip)
Check that $ip is a correct 4 Dotted ip.
Definition: functions.php:210
$user
Definition: bootstrap.php:84
$password
Definition: bootstrap.php:85