/** * Displays the server group list */ function rows($result) { global $fmdb, $__FM_CONFIG, $fm_users; if (!$result) { printf('<p id="table_edits" class="noresult" name="servers">%s</p>', __('There are no active database server groups.')); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results', 'id' => 'table_edits'); $title_array = array(array('title' => '<input type="checkbox" class="tickall" onClick="toggle(this, \'group[]\')" checked />', 'class' => 'header-tiny'), __('Server Group'), __('Last Changed')); echo displayTableHeader($table_info, $title_array); echo '<form name="manage" id="manage" method="post" action="' . $GLOBALS['basename'] . '">' . "\n"; for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x]); } echo "</tbody>\n</table>\n"; } if (currentUserCan('manage_passwords', $_SESSION['module']) && $result) { printf('<br /><br /> <a name="#manage"></a> <input type="hidden" name="item_type" value="set_mysql_password" /> <h2>%s</h2>', __('Set User Password')); if (!($pwd_strength = getOption('minimum_pwd_strength', $_SESSION['user']['account_id'], $_SESSION['module']))) { $pwd_strength = $GLOBALS['PWD_STRENGTH']; } echo $fm_users->printUsersForm(null, 'add', array('user_login', 'user_password' => $pwd_strength, 'verbose'), __('Set Password'), 'set_sql_password', 'config-passwords', false, 'embed'); printf('<div><input type="submit" id="set_sql_password" name="submit" value="%s" class="button primary" disabled /></div>', __('Set Password')); echo '</form>'; } }
/** * Displays the server list */ function rows($result) { global $fmdb; $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; if (currentUserCan('build_server_configs', $_SESSION['module'])) { $bulk_actions_list = array(__('Upgrade'), __('Build Config')); $title_array[] = array('title' => '<input type="checkbox" class="tickall" onClick="toggle(this, \'server_list[]\')" />', 'class' => 'header-tiny'); } else { $bulk_actions_list = null; } if (!$result) { printf('<p id="table_edits" class="noresult" name="servers">%s</p>', __('There are no firewall servers.')); } else { echo @buildBulkActionMenu($bulk_actions_list, 'server_id_list'); $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'servers'); $title_array[] = array('class' => 'header-tiny'); $title_array = array_merge($title_array, array(__('Hostname'), __('Method'), __('Firewall Type'), __('Version'), __('Config File'))); $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions'); echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x]); } echo "</tbody>\n</table>\n"; } }
/** * Displays the user list * * @since 1.0 * @package facileManager */ function rows($result, $type) { global $fmdb; if (!$result) { $message = $type == 'users' ? _('There are no users.') : _('There are no groups.'); printf('<p id="table_edits" class="noresult" name="users">%s</p>', $message); } else { $table_info = array('class' => 'display_results sortable', 'id' => 'table_edits', 'name' => 'users'); if ($type == 'users') { $title_array[] = array('class' => 'header-tiny header-nosort'); $title_array[] = array('title' => _('Login'), 'rel' => 'user_login'); array_push($title_array, array('title' => _('Last Session Date'), 'rel' => 'user_last_login'), array('title' => _('Last Session Host'), 'class' => 'header-nosort'), array('title' => _('Authenticate With'), 'class' => 'header-nosort'), array('title' => _('Super Admin'), 'class' => 'header-nosort')); } else { $title_array[] = array('title' => _('Group Name'), 'rel' => 'group_name'); $title_array[] = array('title' => _('Comment'), 'class' => 'header-nosort'); } $title_array[] = array('title' => _('Actions'), 'class' => 'header-actions header-nosort'); echo displayTableHeader($table_info, $title_array); $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x], $type); } echo "</tbody>\n</table>\n"; } }
/** * Displays the option list */ function rows($result) { global $fmdb; if (!$result) { printf('<p id="table_edits" class="noresult" name="options">%s</p>', __('There are no options.')); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results sortable', 'id' => 'table_edits', 'name' => 'options'); if (isset($_GET['option_type']) && sanitize($_GET['option_type']) == 'ratelimit') { $title_array[] = array('title' => __('Zone'), 'rel' => 'domain_id'); } $title_array[] = array('title' => __('Option'), 'rel' => 'cfg_name'); $title_array[] = array('title' => __('Value'), 'rel' => 'cfg_data'); $title_array[] = array('title' => __('Comment'), 'class' => 'header-nosort'); if (currentUserCan('manage_servers', $_SESSION['module'])) { $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions header-nosort'); } echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x]); } echo "</tbody>\n</table>\n"; } }
/** * Displays the policy list */ function rows($result, $type) { global $fmdb, $__FM_CONFIG; if (!$result) { printf('<p id="table_edits" class="noresult" name="policies">%s</p>', __('There are no firewall policies.')); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'policies'); if (currentUserCan('manage_servers', $_SESSION['module']) && $num_rows > 1) { $table_info['class'] .= ' grab'; } $title_array = array(array('class' => 'header-tiny'), __('Source'), __('Destination'), __('Service'), __('Interface'), __('Direction'), __('Time'), array('title' => __('Comment'), 'style' => 'width: 20%;')); if (currentUserCan('manage_servers', $_SESSION['module'])) { $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions'); } echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x], $type); } echo "</tbody>\n"; } $server_firewall_type = getNameFromID($_REQUEST['server_serial_no'], 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_serial_no', 'server_type'); if (array_key_exists($server_firewall_type, $__FM_CONFIG['fw']['notes'])) { $policy_note = sprintf('<br /> <div id="shadow_box" class="fullwidthbox"> <div id="shadow_container" class="fullwidthbox note"> <p><b>%s</b><br />%s</p> </div> </div>', __('Note:'), $__FM_CONFIG['fw']['notes'][$server_firewall_type]); } else { $policy_note = null; } $action_icons = enumMYSQLSelect('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'policies', 'policy_action'); $action_icons[] = 'log'; foreach ($action_icons as $action) { $action_active[] = '<td>' . str_replace(array('__action__', '__Action__'), array($action, ucfirst($action)), $__FM_CONFIG['icons']['action']['active']) . "<span>{$action}</span></td>\n"; $action_disabled[] = '<td>' . str_replace(array('__action__', '__Action__'), array($action, ucfirst($action)), $__FM_CONFIG['icons']['action']['disabled']) . "<span>{$action} (" . __('disabled') . ")</span></td>\n"; } $action_active = implode("\n", $action_active); $action_disabled = implode("\n", $action_disabled); echo <<<HTML \t\t\t</table> \t\t\t{$policy_note} \t\t\t<table class="legend"> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t{$action_active} \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t{$action_disabled} \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> HTML; }
/** * Displays the zone list */ function rows($result, $map, $reload_allowed, $page, $total_pages) { global $fmdb, $__FM_CONFIG; $all_num_rows = $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; if (currentUserCan('reload_zones', $_SESSION['module'])) { $bulk_actions_list = array(__('Reload')); $checkbox[] = array('title' => '<input type="checkbox" class="tickall" onClick="toggle(this, \'domain_list[]\')" />', 'class' => 'header-tiny header-nosort'); } else { $checkbox = $bulk_actions_list = null; } if (!$result) { printf('<p id="table_edits" class="noresult" name="domains">%s</p>', __('There are no zones.')); } else { if (array_key_exists('attention', $_GET)) { $num_rows = $GLOBALS['zone_badge_counts'][$map]; $total_pages = ceil($num_rows / $_SESSION['user']['record_count']); if ($page > $total_pages) { $page = $total_pages; } } $start = $_SESSION['user']['record_count'] * ($page - 1); $end = $_SESSION['user']['record_count'] * $page > $num_rows ? $num_rows : $_SESSION['user']['record_count'] * $page; $classes = array_key_exists('attention', $_GET) ? null : ' grey'; $eye_attention = $GLOBALS['zone_badge_counts'][$map] ? '<i class="fa fa-eye fa-lg eye-attention' . $classes . '" title="' . __('Only view zones that need attention') . '"></i>' : null; $addl_blocks = array(@buildBulkActionMenu($bulk_actions_list, 'server_id_list'), $this->buildFilterMenu(), $eye_attention); $fmdb->num_rows = $num_rows; echo displayPagination($page, $total_pages, $addl_blocks); $table_info = array('class' => 'display_results sortable', 'id' => 'table_edits', 'name' => 'domains'); $title_array = array(array('title' => __('ID'), 'class' => 'header-small header-nosort'), array('title' => __('Domain'), 'rel' => 'domain_name'), array('title' => __('Type'), 'rel' => 'domain_type'), array('title' => __('Views'), 'class' => 'header-nosort'), array('title' => __('Records'), 'class' => 'header-small header-nosort')); $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions header-nosort'); if (is_array($checkbox)) { $title_array = array_merge($checkbox, $title_array); } echo displayTableHeader($table_info, $title_array, 'zones'); $y = 0; for ($x = $start; $x < $all_num_rows; $x++) { if ($y == $_SESSION['user']['record_count']) { break; } if (array_key_exists('attention', $_GET)) { if (!$results[$x]->domain_clone_domain_id && $results[$x]->domain_type == 'master' && $results[$x]->domain_template == 'no' && (!getSOACount($results[$x]->domain_id) || !getNSCount($results[$x]->domain_id) || $results[$x]->domain_reload != 'no')) { $this->displayRow($results[$x], $map, $reload_allowed); $y++; } } else { $this->displayRow($results[$x], $map, $reload_allowed); $y++; } } echo "</tbody>\n</table>\n"; } }
/** * Displays the group list */ function rows($result) { global $fmdb; if (!$result) { printf('<p id="table_edits" class="noresult" name="groups">%s</p>', __('There are no server groups.')); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'groups'); $title_array = array(__('Group Name'), __('Associated Servers')); if (currentUserCan('manage_servers', $_SESSION['module'])) { $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions'); } echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x]); } echo "</tbody>\n</table>\n"; } }
/** * Displays the time list */ function rows($result) { global $fmdb; if (!$result) { printf('<p id="table_edits" class="noresult" name="time">%s</p>', __('There are no time restrictions defined.')); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'time'); $title_array = array(__('Restriction Name'), __('Date Range'), __('Time'), __('Weekdays'), array('title' => __('Comment'), 'style' => 'width: 30%;')); if (currentUserCan('manage_time', $_SESSION['module'])) { $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions'); } echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x]); } echo "</tbody>\n</table>\n"; } }
/** * Displays the service list */ function rows($result, $type) { global $fmdb; if (!$result) { printf('<p id="table_edits" class="noresult" name="services">%s</p>', sprintf(__('There are no %s services defined.'), strtoupper($type))); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'services'); $title_array = $type == 'icmp' ? array(__('Service Name'), __('ICMP Type'), __('ICMP Code'), __('Comment')) : array(__('Service Name'), __('Source Ports'), __('Dest Ports'), __('Flags'), __('Comment')); if (currentUserCan('manage_services', $_SESSION['module'])) { $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions'); } echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x]); } echo "</tbody>\n</table>\n"; } }
/** * Displays the key list */ function rows($result) { global $fmdb; if (!$result) { printf('<p id="table_edits" class="noresult" name="keys">%s</p>', __('There are no keys.')); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results sortable', 'id' => 'table_edits', 'name' => 'keys'); $title_array = array(array('title' => __('Key'), 'rel' => 'key_name'), array('title' => __('Algorithm'), 'class' => 'header-nosort'), array('title' => __('Secret'), 'rel' => 'key_secret'), array('title' => __('View'), 'class' => 'header-nosort'), array('title' => __('Comment'), 'class' => 'header-nosort')); if (currentUserCan('manage_servers', $_SESSION['module'])) { $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions header-nosort'); } echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x]); } echo "</tbody>\n</table>\n"; } }
/** * Displays the logging list */ function rows($result, $channel_category) { global $fmdb, $__FM_CONFIG; if (!$result) { printf('<p id="table_edits" class="noresult" name="logging">%s</p>', sprintf(__('There are no %s defined.'), strtolower($__FM_CONFIG['logging']['avail_types'][$channel_category]))); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results sortable', 'id' => 'table_edits', 'name' => 'logging'); $title_array[] = array('title' => __('Name'), 'rel' => 'cfg_data'); if ($channel_category == 'category') { $title_array[] = array('title' => __('Channels'), 'class' => 'header-nosort'); } $title_array[] = array('title' => __('Comment'), 'class' => 'header-nosort'); if (currentUserCan('manage_servers', $_SESSION['module'])) { $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions header-nosort'); } echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x], $channel_category); } echo "</tbody>\n</table>\n"; } }
/** * Displays the object list */ function rows($result, $type) { global $fmdb; if (!$result) { printf('<p id="table_edits" class="noresult" name="objects">%s</p>', sprintf(__('There are no %s objects defined.'), $type)); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'objects'); $title_array = array(__('Object Name'), __('Address')); if ($type != 'address') { $title_array[] = __('Netmask'); } $title_array[] = array('title' => __('Comment'), 'style' => 'width: 40%;'); if (currentUserCan('manage_objects', $_SESSION['module'])) { $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions'); } echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x]); } echo "</tbody>\n</table>\n"; } }
/** * Displays the server list */ function rows($result, $type) { global $fmdb; $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $bulk_actions_list = null; // if (currentUserCan('manage_servers', $_SESSION['module'])) $bulk_actions_list = array('Enable', 'Disable', 'Delete', 'Upgrade'); if (currentUserCan('manage_servers', $_SESSION['module'])) { $bulk_actions_list[] = __('Upgrade'); } if (currentUserCan('build_server_configs', $_SESSION['module'])) { $bulk_actions_list[] = __('Build Config'); } if (is_array($bulk_actions_list)) { $title_array[] = array('title' => '<input type="checkbox" class="tickall" onClick="toggle(this, \'' . rtrim($type, 's') . '_list[]\')" />', 'class' => 'header-tiny header-nosort'); } if (!$result) { $message = $type == 'servers' ? __('There are no servers.') : __('There are no groups.'); printf('<p id="table_edits" class="noresult" name="servers">%s</p>', $message); } else { echo @buildBulkActionMenu($bulk_actions_list, 'server_id_list'); $table_info = array('class' => 'display_results sortable', 'id' => 'table_edits', 'name' => 'servers'); if ($type == 'servers') { $title_array[] = array('class' => 'header-tiny header-nosort'); $title_array = array_merge($title_array, array(array('title' => __('Hostname'), 'rel' => 'server_name'), array('title' => __('Method'), 'rel' => 'server_update_method'), array('title' => __('Key'), 'class' => 'header-nosort'), array('title' => __('Server Type'), 'class' => 'header-nosort'), array('title' => __('Version'), 'class' => 'header-nosort'), array('title' => __('Run-as'), 'rel' => 'server_run_as_predefined'), array('title' => __('Config File'), 'rel' => 'server_config_file'), array('title' => __('Server Root'), 'rel' => 'server_root_dir'), array('title' => __('Zones Directory'), 'rel' => 'server_zones_dir'))); } elseif ($type == 'groups') { $title_array = array_merge((array) $title_array, array(array('title' => __('Group Name'), 'rel' => 'group_name'), array('title' => __('Master Servers'), 'class' => 'header-nosort'), array('title' => __('Slave Servers'), 'class' => 'header-nosort'))); } $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions header-nosort'); echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x], $type); } echo "</tbody>\n</table>\n"; } }
/** * Displays the template list */ function rows($result, $template_type) { global $fmdb; if (!$result) { printf('<p id="table_edits" class="noresult" name="%s">%s</p>', $template_type, __('There are no templates.')); } else { $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $table_info = array('class' => 'display_results sortable', 'id' => 'table_edits', 'name' => $template_type); global $fm_dns_records; if (!isset($fm_dns_records)) { include ABSPATH . 'fm-modules/fmDNS/classes/class_records.php'; } $title_array = array_merge(array(array('title' => '', 'class' => 'header-nosort')), $fm_dns_records->getHeader(strtoupper($template_type))); if (currentUserCan('manage_zones', $_SESSION['module'])) { $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions header-nosort'); } echo displayTableHeader($table_info, $title_array); for ($x = 0; $x < $num_rows; $x++) { $this->displayRow($results[$x], $template_type); } echo "</tbody>\n</table>\n"; } }
$domain_info['map'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_mapping'); $domain_info['clone_of'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_clone_domain_id'); $domain_info['template_id'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id'); if (isset($_POST['update'])) { if ($_POST['update']['soa_template_chosen']) { global $fm_dns_records; /** Save the soa_template_chosen in domains table and end */ include_once ABSPATH . 'fm-modules/fmDNS/classes/class_records.php'; $fm_dns_records->assignSOA($_POST['update']['soa_template_chosen'], $domain_id); header('Location: zone-records.php?map=' . $_POST['map'] . '&domain_id=' . $domain_id . '&record_type=SOA'); } $_POST['update'] = buildUpdateArray($domain_id, $record_type, $_POST['update']); } $table_info = array('class' => 'display_results no-left-pad'); $header_array = $fm_dns_records->getHeader(strtoupper($record_type)); $header = displayTableHeader($table_info, $header_array); $body = null; foreach ($_POST as $name => $array) { if (in_array($name, array('create', 'update'))) { $body .= createOutput($domain_info, $record_type, $array, $name, $header_array); } } printHeader(); @printMenu(); printf('<div id="body_container"> <h2>%s</h2> <form method="POST" action="zone-records-write.php"> <input type="hidden" name="domain_id" value="%d"> <input type="hidden" name="record_type" value="%s"> <input type="hidden" name="map" value="%s"> %s
/** * Imports records from a zone file and presents a confirmation */ function zoneImportWizard() { global $__FM_CONFIG, $fm_name; if (!currentUserCan('manage_records', $_SESSION['module'])) { return $this->unAuth('zone'); } if (!zoneAccessIsAllowed(array($_POST['domain_id']))) { return $this->unAuth('zone'); } $raw_contents = file_get_contents($_FILES['import-file']['tmp_name']); /** Strip commented lines */ $clean_contents = preg_replace('/^;.*\\n?/m', '', $raw_contents); /** Strip blank lines */ $clean_contents = preg_replace('/^\\n?/m', '', $clean_contents); /** Strip $GENERATE lines */ $clean_contents = preg_replace('/^\\$GENERATE.*\\n?/m', '', $clean_contents, -1, $generate_count); /** Strip $ORIGIN lines */ $clean_contents = preg_replace('/^\\$ORIGIN.*\\n?/m', '', $clean_contents, -1, $origin_count); /** Handle unsupported message */ if ($generate_count || $origin_count) { $unsupported[] = sprintf('<h4>%s:</h4>', __('Unsupported Entries')); $unsupported[] = '<p class="soa_import">' . sprintf(__('%s currently does not support importing $GENERATE and $ORIGIN entries which were found in your zone file.'), $fm_name) . '</p>'; $unsupported = implode("\n", $unsupported); } else { $unsupported = null; } $domain_name = getNameFromID($_POST['domain_id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name'); $domain_map = getNameFromID($_POST['domain_id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_mapping'); $count = 1; /** Detect SOA */ if (!getSOACount($_POST['domain_id']) && strpos($clean_contents, ' SOA ') !== false && (in_array('SOA', $__FM_CONFIG['records']['require_zone_rights']) && currentUserCan('manage_zones', $_SESSION['module']))) { $raw_soa = preg_replace("/SOA(.+?)\\)/esim", "str_replace(PHP_EOL, ' ', '\\1')", $clean_contents); preg_match("/SOA(.+?)\\)/esim", $clean_contents, $raw_soa); preg_match("/TTL(.+?)\$/esim", $clean_contents, $raw_ttl); if (is_array($raw_ttl)) { $soa_array['soa_ttl'] = trim(preg_replace('/;(.+?)+/', '', $raw_ttl[1])); } if (is_array($raw_soa)) { $raw_soa = preg_replace('/;(.+?)+/', '', $raw_soa[1]); $soa = str_replace(array("\n", "\t", '(', ')', ' '), ' ', preg_replace('/\\s\\s+/', ' ', $raw_soa)); $soa = str_replace(' ', '|', trim($soa)); $soa_fields = explode('|', str_replace('||', '|', $soa)); list($soa_array['soa_master_server'], $soa_array['soa_email_address'], $tmp_serial, $soa_array['soa_refresh'], $soa_array['soa_retry'], $soa_array['soa_expire'], $tmp_neg_cache) = $soa_fields; if (strpos($soa_array['soa_master_server'], $domain_name) !== false) { $soa_array['soa_master_server'] = str_replace('.' . trimFullStop($domain_name) . '.', '', $soa_array['soa_master_server']); $soa_array['soa_email_address'] = str_replace('.' . trimFullStop($domain_name) . '.', '', $soa_array['soa_email_address']); $soa_array['soa_append'] = 'yes'; } else { $soa_array['soa_append'] = 'no'; } } $soa_row = '<h4>SOA:</h4><p class="soa_import">' . trimFullStop($domain_name) . '. IN SOA ' . $soa_array['soa_master_server']; if ($soa_array['soa_append'] == 'yes') { $soa_row .= '.' . trimFullStop($domain_name) . '.'; } $soa_row .= ' ' . $soa_array['soa_email_address']; if ($soa_array['soa_append'] == 'yes') { $soa_row .= '.' . trimFullStop($domain_name) . '.'; } $soa_row .= ' ( <autogen_serial> ' . $soa_array['soa_refresh'] . ' ' . $soa_array['soa_retry'] . ' ' . $soa_array['soa_expire'] . ' ' . $soa_array['soa_ttl'] . ' )'; $soa_row = <<<HTML \t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_master_server]" value="{$soa_array['soa_master_server']}" /> \t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_email_address]" value="{$soa_array['soa_email_address']}" /> \t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_refresh]" value="{$soa_array['soa_refresh']}" /> \t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_retry]" value="{$soa_array['soa_retry']}" /> \t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_expire]" value="{$soa_array['soa_expire']}" /> \t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_ttl]" value="{$soa_array['soa_ttl']}" /> \t\t\t\t\t\t<input type="hidden" name="create[{$count}][record_type]" value="SOA" /> \t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_append]" value="{$soa_array['soa_append']}" /> \t\t\t\t\t\t{$soa_row} \t\t\t\t\t\t<span><label><input type="checkbox" name="create[{$count}][record_skip]" />Skip Import</label></span> \t\t\t\t\t\t</p> \t\t\t\t\t\t \t\t\t\t\t\t<h4>Records:</h4> HTML; $count++; } else { $soa_row = null; } $clean_contents = str_replace('.' . trimFullStop($domain_name) . '.', '', $clean_contents); $clean_contents = str_replace(trimFullStop($domain_name) . '.', '', $clean_contents); $available_record_types = array_filter(enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', 'record_type'), 'removeRestrictedRR'); sort($available_record_types); /** Loop through the lines */ $lines = explode(PHP_EOL, $clean_contents); $failed = 0; $rows = null; $valid_hashes = array(';', '//', '#'); foreach ($lines as $line) { $null_keys = array('record_ttl', 'record_priority', 'record_weight', 'record_port'); foreach ($null_keys as $key) { $array[$key] = null; } if (!strlen(trim($line))) { continue; } foreach ($valid_hashes as $tmp_hash) { if (strpos($line, $tmp_hash)) { $hash = $tmp_hash; break; } else { $hash = null; } } if ($hash == '//') { $hash = '\\/\\/'; } /** Break up the line for comments */ if ($hash) { $comment_parts = preg_split("/{$hash}+/", $line); $array['record_comment'] = trim($comment_parts[1]) ? trim($comment_parts[1]) : 'none'; } else { $comment_parts[0] = $line; $array['record_comment'] = 'none'; } /** Break up the line for parts */ $parts = preg_split('/\\s+/', trim($comment_parts[0])); if ($domain_map == 'forward') { if (in_array('MX', $parts)) { switch (array_search('MX', $parts)) { case 3: list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts; break; case 2: if (is_numeric($parts[0])) { $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts; } else { list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts; } break; case 1: $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts; } } elseif (in_array('SRV', $parts)) { switch (array_search('SRV', $parts)) { case 3: list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts; break; case 2: if (is_numeric($parts[0])) { $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts; } else { list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts; } break; case 1: $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts; } } elseif (in_array('TXT', $parts)) { $key = array_search('TXT', $parts); $txt_record = null; for ($i = $key + 1; $i < count($parts); $i++) { $txt_record .= $parts[$i] . ' '; } $parts[$key + 1] = rtrim($txt_record); switch ($key) { case 3: list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; break; case 2: if (is_numeric($parts[0])) { $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; } else { list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; } break; case 1: $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_class'], $array['record_type'], $array['record_value']) = $parts; } $array['record_value'] = str_replace('"', '', $array['record_value']); } elseif (in_array('A', $parts) || in_array('CNAME', $parts) || in_array('AAAA', $parts)) { if (in_array('AAAA', $parts)) { $key = array_search('AAAA', $parts); } else { $key = in_array('A', $parts) ? array_search('A', $parts) : array_search('CNAME', $parts); } switch ($key) { case 3: list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; break; case 2: if (is_numeric($parts[0])) { $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; } else { list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; } break; case 1: $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_class'], $array['record_type'], $array['record_value']) = $parts; } } } else { if (in_array('PTR', $parts)) { switch (array_search('PTR', $parts)) { case 3: list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; break; case 2: if ($parts[0] > 255) { $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; } else { list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; } break; case 1: $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_class'], $array['record_type'], $array['record_value']) = $parts; } } } if (in_array('NS', $parts) && in_array('NS', $__FM_CONFIG['records']['require_zone_rights']) && currentUserCan('manage_zones', $_SESSION['module'])) { switch (array_search('NS', $parts)) { case 3: list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; break; case 2: if (is_numeric($parts[0])) { $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; } else { list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts; } break; case 1: $array['record_name'] = isset($current_name) ? $current_name : '@'; list($array['record_class'], $array['record_type'], $array['record_value']) = $parts; } } if (empty($array['record_name']) && !empty($array['record_comment'])) { continue; } $array['record_append'] = substr($array['record_value'], -1) == '.' ? 'no' : 'yes'; /** Set current_name to check for blanks on next run */ $current_name = $array['record_name']; /** Automatically skip duplicates */ $checked = $this->checkDuplicates($array, $_POST['domain_id']); $rows .= <<<ROW \t\t\t\t\t<tr class="import_swap"> \t\t\t\t\t\t<td><span id="name{$count}" onclick="exchange(this);">{$array['record_name']}</span><input onblur="exchange(this);" type="text" id="name{$count}b" name="create[{$count}][record_name]" value="{$array['record_name']}" /></td> \t\t\t\t\t\t<td><span id="ttl{$count}" onclick="exchange(this);">{$array['record_ttl']}</span><input onblur="exchange(this);" type="number" id="ttl{$count}b" name="create[{$count}][record_ttl]" value="{$array['record_ttl']}" /></td> \t\t\t\t\t\t<td><input type="hidden" name="create[{$count}][record_class]" value="{$array['record_class']}" />{$array['record_class']}</td> \t\t\t\t\t\t<td><input type="hidden" name="create[{$count}][record_type]" value="{$array['record_type']}" />{$array['record_type']}</td> \t\t\t\t\t\t<td><span id="priority{$count}" onclick="exchange(this);">{$array['record_priority']}</span><input onblur="exchange(this);" type="number" id="priority{$count}b" name="create[{$count}][record_priority]" value="{$array['record_priority']}" /></td> \t\t\t\t\t\t<td><span id="value{$count}" onclick="exchange(this);">{$array['record_value']}</span><input onblur="exchange(this);" type="text" id="value{$count}b" name="create[{$count}][record_value]" value="{$array['record_value']}" /></td> \t\t\t\t\t\t<td><span id="weight{$count}" onclick="exchange(this);">{$array['record_weight']}</span><input onblur="exchange(this);" type="number" id="weight{$count}b" name="create[{$count}][record_weight]" value="{$array['record_weight']}" /></td> \t\t\t\t\t\t<td><span id="port{$count}" onclick="exchange(this);">{$array['record_port']}</span><input onblur="exchange(this);" type="number" id="port{$count}b" name="create[{$count}][record_port]" value="{$array['record_port']}" /></td> \t\t\t\t\t\t<td><span id="comment{$count}" onclick="exchange(this);">{$array['record_comment']}</span><input onblur="exchange(this);" type="text" id="comment{$count}b" name="create[{$count}][record_comment]" value="{$array['record_comment']}" /></td> \t\t\t\t\t\t<td style="text-align: center;" nowrap><input type="hidden" name="create[{$count}][record_append]" value="{$array['record_append']}" />{$array['record_append']}</td> \t\t\t\t\t\t<td style="text-align: center;"><label><input type="checkbox" name="create[{$count}][record_skip]" {$checked} />Skip Import</label></td> \t\t\t\t\t</tr> ROW; $count++; } $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'views'); $title_array = array(__('Record'), __('TTL'), __('Class'), __('Type'), __('Priority'), __('Value'), __('Weight'), __('Port'), __('Comment')); $title_array[] = array('title' => __('Append Domain'), 'style' => 'text-align: center;', 'nowrap' => null); $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions'); $table_header = displayTableHeader($table_info, $title_array); $popup_header = buildPopup('header', __('Import Verification')); $popup_footer = buildPopup('footer', __('Import'), array('import' => 'submit', 'cancel_button' => 'cancel')); $body = <<<BODY \t\t<form method="post" action="zone-records-write.php"> \t\t{$popup_header} \t\t\t<p>Domain: {$domain_name}</p> \t\t\t<input type="hidden" name="domain_id" value="{$_POST['domain_id']}"> \t\t\t<input type="hidden" name="map" value="{$domain_map}"> \t\t\t<input type="hidden" name="import_records" value="true"> \t\t\t<input type="hidden" name="import_file" value="{$_FILES['import-file']['name']}"> \t\t\t{$unsupported} \t\t\t{$soa_row} \t\t\t{$table_header} \t\t\t\t{$rows} \t\t\t\t</tbody> \t\t\t</table> \t\t\t<br /> \t\t{$popup_footer} \t\t</form> BODY; return $body; }
/** * Displays the form to add new record */ function printRecordsForm($data = '', $action = 'create', $record_type, $domain_id) { $ucf_action = ucfirst($action); if (!empty($_POST)) { if (is_array($_POST)) { extract($_POST); } } elseif (@is_object($data[0])) { extract(get_object_vars($data[0])); } $table_info = array('class' => 'display_results'); $return = displayTableHeader($table_info, $this->getHeader(strtoupper($record_type)), 'more_records'); $return .= $this->getInputForm(strtoupper($record_type), true, $domain_id); $return .= sprintf('</tbody> </table> <p class="add_records"><a id="add_records" href="#">+ %s</a></p>', __('Add more records')); return $return; }