From 7680cd441c7405f0305f855ff651983cf0b1bbe6 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Fri, 30 Jan 2015 17:55:27 +0100 Subject: [PATCH] force integer conversion for domainimport-offset-field, as POST sends it as string; filter IP-addresses that are unknown to froxlor when importing domains. Signed-off-by: Michael Kaufmann (d00p) --- admin_domains.php | 2 +- lib/classes/bulk/class.DomainBulkAction.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/admin_domains.php b/admin_domains.php index 338d34ba9b..facc63b9aa 100644 --- a/admin_domains.php +++ b/admin_domains.php @@ -1911,7 +1911,7 @@ $customerid = intval($_POST['customerid']); $separator = validate($_POST['separator'], 'separator'); - $offset = validate($_POST['offset'], 'offset', "/[0-9]/i"); + $offset = (int)validate($_POST['offset'], 'offset', "/[0-9]/i"); $file_name = $_FILES['file']['tmp_name']; diff --git a/lib/classes/bulk/class.DomainBulkAction.php b/lib/classes/bulk/class.DomainBulkAction.php index e4a07019c7..b424dab31e 100644 --- a/lib/classes/bulk/class.DomainBulkAction.php +++ b/lib/classes/bulk/class.DomainBulkAction.php @@ -60,6 +60,13 @@ class DomainBulkAction { * @var array */ private $_knownIpPort = null; + + /** + * array of known IP's to check against + * + * @var array + */ + private $_knownIpPortChk = null; /** * array of fields to import to panel_domains @@ -319,6 +326,13 @@ private function _addSingleDomainToDatabase($domain_data = array()) { // save iplist $iplist = $domain_data['ips']; + $iplist_arr = array_unique(explode(",", $iplist)); + $knownIPsCheck = array_unique($this->_knownIpPortChk); + // check whether we actually have at least one of the used IP's in our system + $result_iplist = array_intersect($iplist_arr, $knownIPsCheck); + // write back iplist + $iplist = implode(",", $result_iplist); + // dont need that for the domain-insert-statement unset($domain_data['ips']); @@ -445,6 +459,7 @@ private function _readIpPortData() { $this->_knownIpPort = array (); while ($ipp = $knownip_stmt->fetch()) { $this->_knownIpPort[$ipp['ip']][] = $ipp; + $this->_knownIpPortChk[] = $ipp['ip']; } }