Skip to content

Commit

Permalink
force integer conversion for domainimport-offset-field, as POST sends…
Browse files Browse the repository at this point in the history
… it as string; filter IP-addresses that are unknown to froxlor when importing domains.

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
  • Loading branch information
d00p committed Jan 30, 2015
1 parent d7f8586 commit 7680cd4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion admin_domains.php
Expand Up @@ -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'];

Expand Down
15 changes: 15 additions & 0 deletions lib/classes/bulk/class.DomainBulkAction.php
Expand Up @@ -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
Expand Down Expand Up @@ -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']);

Expand Down Expand Up @@ -445,6 +459,7 @@ private function _readIpPortData() {
$this->_knownIpPort = array ();
while ($ipp = $knownip_stmt->fetch()) {
$this->_knownIpPort[$ipp['ip']][] = $ipp;
$this->_knownIpPortChk[] = $ipp['ip'];
}

}
Expand Down

0 comments on commit 7680cd4

Please sign in to comment.