From d22277878254cf33fd63ca1bf12b215f4e030a27 Mon Sep 17 00:00:00 2001
From: Marius Burkard <m.burkard@pixcept.de>
Date: Mon, 04 Jan 2016 05:12:49 -0500
Subject: [PATCH] - merged different fixes and updates from foreign branches

---
 install/lib/installer_base.lib.php |   78 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index db83e05..be878c1 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",
+							"",
+							' . $conf['server_id'] . ',
+							0,
+							"'.$ip_type.'",
+							"'.$line.'",
+							"y",
+							"80,443"
+						)');
+						$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 (
+							'.$server_ip_id.',
+							1,
+							1,
+							"riud",
+							"riud",
+							"",
+							' . $conf['server_id'] . ',
+							0,
+							"'.$ip_type.'",
+							"'.$line.'",
+							"y",
+							"80,443"
+						)');
+					} 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",
+							"",
+							' . $conf['server_id'] . ',
+							0,
+							"'.$ip_type.'",
+							"'.$line.'",
+							"y",
+							"80,443"
+						)');
+					}
+				}
+			}
+		}
+	}
 
 	public function grant_master_database_rights($verbose = false) {
 		global $conf;

--
Gitblit v1.9.1