From d63ceade2147e2e89b34f603c80def6eb4aaabeb Mon Sep 17 00:00:00 2001
From: Florian Schaal <florian@schaal-24.de>
Date: Tue, 26 Jan 2016 03:02:21 -0500
Subject: [PATCH] FS#3973 - dns-wizard

---
 install/lib/installer_base.lib.php |   84 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index db83e05..69d5ccf 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -371,6 +371,84 @@
 
 
 	}
+	
+	public function detect_ips(){
+		global $conf;
+
+		exec("ip addr show | awk '/global/ { print $2 }' | cut -d '/' -f 1", $output, $retval);
+		
+		if($retval == 0){
+			if(is_array($output) && !empty($output)){
+				foreach($output as $line){
+					$line = trim($line);
+					$ip_type = '';
+					if (filter_var($line, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
+						$ip_type = 'IPv4';
+					}
+					if (filter_var($line, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
+						$ip_type = 'IPv6';
+					}
+					if($ip_type == '') continue;
+					if($this->db->dbHost != $this->dbmaster->dbHost){
+						$this->dbmaster->query('INSERT INTO server_ip (
+							sys_userid, sys_groupid, sys_perm_user, sys_perm_group,
+							sys_perm_other, server_id, client_id, ip_type, ip_address,
+							virtualhost, virtualhost_port
+						) VALUES (
+							1,
+							1,
+							"riud",
+							"riud",
+							"",
+							?,
+							0,
+							?,
+							?,
+							"y",
+							"80,443"
+						)', $conf['server_id'], $ip_type, $line);
+						$server_ip_id = $this->dbmaster->insertID();
+						$this->db->query('INSERT INTO server_ip (
+							server_php_id, sys_userid, sys_groupid, sys_perm_user, sys_perm_group,
+							sys_perm_other, server_id, client_id, ip_type, ip_address,
+							virtualhost, virtualhost_port
+						) VALUES (
+							?,
+							1,
+							1,
+							"riud",
+							"riud",
+							"",
+							?,
+							0,
+							?,
+							?,
+							"y",
+							"80,443"
+						)', $server_ip_id, $conf['server_id'], $ip_type, $line);
+					} else {
+						$this->db->query('INSERT INTO server_ip (
+							sys_userid, sys_groupid, sys_perm_user, sys_perm_group,
+							sys_perm_other, server_id, client_id, ip_type, ip_address,
+							virtualhost, virtualhost_port
+						) VALUES (
+							1,
+							1,
+							"riud",
+							"riud",
+							"",
+							?,
+							0,
+							?,
+							?,
+							"y",
+							"80,443"
+						)', $conf['server_id'], $ip_type, $line);
+					}
+				}
+			}
+		}
+	}
 
 	public function grant_master_database_rights($verbose = false) {
 		global $conf;
@@ -1403,12 +1481,12 @@
 
 		//* Create the slave subdirectory
 		$content .= 'slave';
-		if(!@is_dir($content)) mkdir($content, 2770, true);
+		if(!@is_dir($content)) mkdir($content, 02770, true);
 
 		//* Chown the slave subdirectory to $conf['bind']['bind_user']
 		chown($content, $conf['bind']['bind_user']);
 		chgrp($content, $conf['bind']['bind_group']);
-		chmod($content, 2770);
+		chmod($content, 02770);
 
 	}
 
@@ -2744,4 +2822,4 @@
 
 }
 
-?>
\ No newline at end of file
+?>

--
Gitblit v1.9.1