/**
  * Generates the zone configs (not files)
  *
  * @since 1.0
  * @package fmDNS
  */
 function buildZoneConfig($post_data)
 {
     global $fmdb, $__FM_CONFIG, $fm_module_servers, $fm_login;
     $server_serial_no = sanitize($post_data['SERIALNO']);
     extract($post_data);
     if (!isset($fm_login)) {
         require_once ABSPATH . 'fm-modules/facileManager/classes/class_logins.php';
     }
     if ($fm_login->isLoggedIn()) {
         if (!currentUserCan(array('access_specific_zones', 'view_all'), $_SESSION['module'], array(0, $domain_id))) {
             unAuth();
         }
     }
     basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', $server_serial_no, 'server_', 'server_serial_no');
     if ($fmdb->num_rows || $SERIALNO == -1) {
         if ($SERIALNO != -1) {
             $data = $fmdb->last_result[0];
             extract(get_object_vars($data), EXTR_SKIP);
         }
         if (!$domain_id) {
             /** Build all zone files */
             list($data->files, $message) = $this->buildZoneDefinitions($server_zones_dir, $server_serial_no);
         } else {
             /** Build zone files for $domain_id */
             $query = "SELECT * FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains` WHERE `domain_status`='active' AND (`domain_id`=" . sanitize($domain_id) . " OR `domain_clone_domain_id`=" . sanitize($domain_id) . ") ";
             if ($SERIALNO != -1) {
                 $server_id = getServerID($server_serial_no, $_SESSION['module']);
                 $query .= " AND (`domain_name_servers`='0' OR `domain_name_servers`='s_{$server_id}' OR `domain_name_servers` LIKE 's_{$server_id};%' OR `domain_name_servers` LIKE '%;s_{$server_id};%'";
                 /** Get the associated server groups */
                 if (!isset($fm_module_servers)) {
                     include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_servers.php';
                 }
                 if ($server_group_ids = $fm_module_servers->getServerGroupIDs($server_id)) {
                     foreach ($server_group_ids as $group_id) {
                         $query .= " OR `domain_name_servers`='g_{$group_id}' OR `domain_name_servers` LIKE 'g_{$group_id};%' OR `domain_name_servers` LIKE '%;g_{$group_id};%'";
                     }
                 }
                 $query .= ')';
             }
             $query .= " ORDER BY `domain_clone_domain_id`,`domain_name`";
             $result = $fmdb->query($query);
             if ($fmdb->num_rows) {
                 $count = $fmdb->num_rows;
                 $zone_result = $fmdb->last_result;
                 for ($i = 0; $i < $count; $i++) {
                     /** Is this a clone id? */
                     if ($zone_result[$i]->domain_clone_domain_id) {
                         $zone_result[$i] = $this->mergeZoneDetails($zone_result[$i], 'clone');
                     } elseif ($zone_result[$i]->domain_template_id) {
                         $zone_result[$i] = $this->mergeZoneDetails($zone_result[$i], 'template');
                     }
                     if (getSOACount($zone_result[$i]->domain_id)) {
                         $domain_name = $this->getDomainName($zone_result[$i]->domain_mapping, trimFullStop($zone_result[$i]->domain_name));
                         $file_ext = $zone_result[$i]->domain_mapping == 'forward' ? 'hosts' : 'rev';
                         /** Are there multiple zones with the same name? */
                         if (isset($zone_result[$i]->parent_domain_id)) {
                             basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $zone_result[$i]->domain_name, 'domain_', 'domain_name', 'AND domain_id!=' . $zone_result[$i]->parent_domain_id);
                             if ($fmdb->num_rows) {
                                 $file_ext = $zone_result[$i]->parent_domain_id . ".{$file_ext}";
                             }
                         } else {
                             $zone_result[$i]->parent_domain_id = $zone_result[$i]->domain_id;
                             basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $zone_result[$i]->domain_name, 'domain_', 'domain_name', 'AND domain_id!=' . $zone_result[$i]->domain_id);
                             if ($fmdb->num_rows) {
                                 $file_ext = $zone_result[$i]->domain_id . ".{$file_ext}";
                             }
                         }
                         //							basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $zone_result[$i]->domain_name, 'domain_', 'domain_name', 'AND domain_clone_domain_id=0 AND domain_id!=' . $zone_result[$i]->domain_id);
                         //							if ($fmdb->num_rows) $file_ext = $zone_result[$i]->domain_id . ".$file_ext";
                         /** Build zone file */
                         $data->files[$server_zones_dir . '/' . $zone_result[$i]->domain_type . '/db.' . $domain_name . $file_ext] = $this->buildZoneFile($zone_result[$i], $server_serial_no);
                     }
                 }
                 if (isset($data->files)) {
                     /** set the server_update_config flag */
                     if (!$dryrun) {
                         setBuildUpdateConfigFlag($server_serial_no, 'yes', 'update');
                     }
                     return array(get_object_vars($data), null);
                 }
             }
             /** Bad domain id */
             $error = "Domain ID {$domain_id} is not found or is not hosted on this server.\n";
         }
     } else {
         /** Bad DNS server */
         $error = "DNS server is not found.\n";
     }
     if ($compress) {
         echo gzcompress(serialize($error));
     } else {
         echo serialize($error);
     }
 }
$default_record_type = $map == 'reverse' ? 'PTR' : 'A';
if (isset($_GET['record_type'])) {
    $record_type = strtoupper($_GET['record_type']);
} else {
    $record_type = $default_record_type;
}
$domain_id = isset($_GET['domain_id']) ? $_GET['domain_id'] : header('Location: ' . getMenuURL(__('Zones')));
if (!isValidDomain($domain_id)) {
    header('Location: ' . getMenuURL(__('Zones')));
}
/** Does the user have access? */
if (!currentUserCan(array('access_specific_zones', 'view_all'), $_SESSION['module'], array(0, $domain_id))) {
    unAuth();
}
if (in_array($record_type, $__FM_CONFIG['records']['require_zone_rights']) && !currentUserCan('manage_zones', $_SESSION['module'])) {
    unAuth();
}
if ($record_type == 'SOA') {
    if (getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_clone_domain_id')) {
        $record_type = $default_record_type;
    } elseif (getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id')) {
        $record_type = $default_record_type;
    }
}
define('FM_INCLUDE_SEARCH', true);
printHeader();
@printMenu();
include ABSPATH . 'fm-modules/fmDNS/classes/class_records.php';
$search_query = createSearchSQL(array('name', 'value', 'ttl', 'class', 'text', 'comment'), 'record_');
$supported_record_types = enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', 'record_type');
sort($supported_record_types);
Exemple #3
0
 +-------------------------------------------------------------------------+
 | Copyright (C) 2013 The facileManager Team                               |
 |                                                                         |
 | This program is free software; you can redistribute it and/or           |
 | modify it under the terms of the GNU General Public License             |
 | as published by the Free Software Foundation; either version 2          |
 | of the License, or (at your option) any later version.                  |
 |                                                                         |
 | This program is distributed in the hope that it will be useful,         |
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | facileManager: Easy System Administration                               |
 +-------------------------------------------------------------------------+
 | http://www.facilemanager.com/                                           |
 +-------------------------------------------------------------------------+
 | Processes main page                                                     |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
/* Redirect to activate modules if none are active */
if ($_SESSION['module'] == $fm_name && currentUserCan('manage_modules')) {
    header('Location: ' . $menu[getParentMenuKey(_('Modules'))][4]);
}
setUserModule($_REQUEST['module']);
/* Prevent a redirect loop **/
if ($_SESSION['module'] == $fm_name) {
    unAuth('hide');
}
header('Location: ' . $GLOBALS['RELPATH']);