Skip to content

Commit

Permalink
keep known_filenames as it results in no zone-file being generated (d…
Browse files Browse the repository at this point in the history
…'oh); also use all available ip's for the froxlor-hostname config, thx a lot to vali for testing, really fixes #1090 this time

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
  • Loading branch information
d00p committed Mar 11, 2014
1 parent 31fa23a commit 9c87792
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions scripts/jobs/cron_tasks.inc.dns.10.bind.php
Expand Up @@ -24,6 +24,8 @@ class bind {
public $mxservers = array();
public $axfrservers = array();

private $_known_filenames = array();

public function __construct($logger, $debugHandler) {

$this->logger = $logger;
Expand Down Expand Up @@ -72,7 +74,7 @@ public function writeConfigs() {
safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
}

$known_filenames = array();
$this->_known_filenames = array();

$bindconf_file = '# ' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf' . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n";
$result_domains_stmt = Database::query("
Expand Down Expand Up @@ -118,7 +120,7 @@ public function writeConfigs() {

if ($domain_filename != '.'
&& $domain_filename != '..'
&& !in_array($domain_filename, $known_filenames)
&& !in_array($domain_filename, $this->_known_filenames)
&& is_file($full_filename)
&& file_exists($full_filename)) {
fwrite($this->debugHandler, ' cron_tasks: Task4 - unlinking ' . $domain_filename . "\n");
Expand All @@ -140,7 +142,7 @@ private function _generateDomainConfig($domain = array(), $froxlorhost = false)
$zonefile = $this->generateZone($domain, $froxlorhost);
$domain['zonefile'] = 'domains/' . $domain['domain'] . '.zone';
$zonefile_name = makeCorrectFile(Settings::Get('system.bindconf_directory') . '/' . $domain['zonefile']);
$known_filenames[] = basename($zonefile_name);
$this->_known_filenames[] = basename($zonefile_name);
$zonefile_handler = fopen($zonefile_name, 'w');
fwrite($zonefile_handler, $zonefile);
fclose($zonefile_handler);
Expand Down Expand Up @@ -200,16 +202,22 @@ protected function generateZone($domain, $froxlorhost = false) {
$domainidquery = '';
$query_params = array();
if (!$froxlorhost) {

$domainidquery = "`di`.`id_domain` = :domainid AND ";
$query_params['domainid'] = $domain['id'];
}

$result_ip_stmt = Database::prepare("
SELECT `p`.`ip` AS `ip`
FROM `".TABLE_PANEL_IPSANDPORTS."` `p`, `".TABLE_DOMAINTOIP."` `di`
WHERE ".$domainidquery."`p`.`id` = `di`.`id_ipandports`
GROUP BY `p`.`ip`;
");
$result_ip_stmt = Database::prepare("
SELECT `p`.`ip` AS `ip`
FROM `".TABLE_PANEL_IPSANDPORTS."` `p`, `".TABLE_DOMAINTOIP."` `di`
WHERE ".$domainidquery."`p`.`id` = `di`.`id_ipandports`
GROUP BY `p`.`ip`;
");
} else {
// use all available IP's for the froxlor-hostname
$result_ip_stmt = Database::prepare("
SELECT `ip` FROM `".TABLE_PANEL_IPSANDPORTS."` GROUP BY `ip`
");
}
Database::pexecute($result_ip_stmt, $query_params);

while ($ip = $result_ip_stmt->fetch(PDO::FETCH_ASSOC)) {
Expand Down

0 comments on commit 9c87792

Please sign in to comment.