/** * Builds the additional module menu for display * * @since 1.0 * @package facileManager * @subpackage fmFirewall */ function buildModuleToolbar() { global $__FM_CONFIG; if (isset($_GET['server_serial_no'])) { $server_name = getNameFromID($_GET['server_serial_no'], 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_serial_no', 'server_name'); $domain_menu = sprintf('<div id="topheadpart"> <span class="single_line">%s: %s</span> </div>', __('Firewall'), $server_name); } else { $domain_menu = null; } return array($domain_menu, null); }
case 'delete': if (isset($id)) { exit(parseAjaxOutput($post_class->delete(sanitize($id), $server_serial_no, $type))); } break; case 'edit': if (isset($_POST['item_status'])) { if (!updateStatus('fm_' . $table, $id, $prefix, sanitize($_POST['item_status']), $field)) { exit(sprintf(__('This item could not be set to %s.') . "\n", $_POST['item_status'])); } else { if ($server_serial_no) { setBuildUpdateConfigFlag($server_serial_no, 'yes', 'build'); } $tmp_name = getNameFromID($id, 'fm_' . $table, $prefix, $field, $prefix . 'name'); if ($server_serial_no && $_POST['item_type'] == 'policies') { $tmp_server = getNameFromID($server_serial_no, 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_serial_no', 'server_name'); addLogEntry(sprintf(__('Set %s for %s status to %s.'), $object, $tmp_server, sanitize($_POST['item_status']))); } else { addLogEntry(sprintf(__('Set %s (%s) status to %s.'), $object, $tmp_name, sanitize($_POST['item_status']))); } exit('Success'); } } break; case 'update_sort': if (!empty($_POST)) { $result = $post_class->update($_POST); if ($result !== true) { exit($result); } exit('Success');
/** * Gets the user capabilities * * @since 1.2 * @package facileManager * * @param integer $user_id User ID to retrieve. * @param string $type User, group, or all * @return array */ function getUserCapabilities($user_id, $type = 'user') { if ($type == 'all') { if ($group_id = getNameFromID($user_id, 'fm_users', 'user_', 'user_id', 'user_group')) { return getUserCapabilities($group_id, 'group'); } } $user_capabilities = getNameFromID($user_id, 'fm_' . $type . 's', $type . '_', $type . '_id', $type . '_caps'); if (isSerialized($user_capabilities)) { $user_capabilities = unserialize($user_capabilities); } return $user_capabilities; }
/** * Attempts to resolve the master servers for the group * * @since 2.0 * @package fmDNS * * @param array $zone_array The zone data * @param integer $server_id The server id to check * @return array */ function resolveServerGroupMasters($masters) { global $__FM_CONFIG; if (!count($masters)) { return null; } foreach ($masters as $server_id) { $server_name = getNameFromID($server_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', 'server_', 'server_id', 'server_name'); $server_ip = gethostbyname($server_name); $master_ips[] = $server_ip != $server_name ? $server_ip : sprintf(__('Cannot resolve %s'), $server_name); } return implode('; ', (array) $master_ips) . ';'; }
function formatPolicyIDs($ids) { global $__FM_CONFIG; $names = null; foreach (explode(';', trim($ids, ';')) as $temp_id) { if ($temp_id[0] == 's') { $names[] = getNameFromID(substr($temp_id, 1), 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'services', 'service_', 'service_id', 'service_name'); } elseif ($temp_id[0] == 'o') { $names[] = getNameFromID(substr($temp_id, 1), 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', 'object_', 'object_id', 'object_name'); } else { $names[] = getNameFromID(substr($temp_id, 1), 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'groups', 'group_', 'group_id', 'group_name'); } } return implode("<br />\n", $names); }
function displayRow($row) { global $fmdb, $__FM_CONFIG, $fm_dns_acls; if (!class_exists('fm_dns_acls')) { include ABSPATH . 'fm-modules/fmDNS/classes/class_acls.php'; } $disabled_class = $row->cfg_status == 'disabled' ? ' class="disabled"' : null; if (currentUserCan('manage_servers', $_SESSION['module'])) { $edit_uri = strpos($_SERVER['REQUEST_URI'], '?') ? $_SERVER['REQUEST_URI'] . '&' : $_SERVER['REQUEST_URI'] . '?'; $edit_status = '<td id="edit_delete_img">'; $edit_status .= '<a class="edit_form_link" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>'; $edit_status .= '<a class="status_form_link" href="#" rel="'; $edit_status .= $row->cfg_status == 'active' ? 'disabled' : 'active'; $edit_status .= '">'; $edit_status .= $row->cfg_status == 'active' ? $__FM_CONFIG['icons']['disable'] : $__FM_CONFIG['icons']['enable']; $edit_status .= '</a>'; $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>'; $edit_status .= '</td>'; } else { $edit_status = null; } $comments = nl2br($row->cfg_comment); /** Parse address_match_element configs */ $cfg_data = $this->parseDefType($row->cfg_name, $row->cfg_data); $zone_row = null; if (isset($_GET['option_type']) && sanitize($_GET['option_type']) == 'ratelimit') { $domain_name = $row->domain_id ? getNameFromID($row->domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name') : '<span>All Zones</span>'; $zone_row = '<td>' . $domain_name . '</td>'; unset($domain_name); } echo <<<HTML \t\t<tr id="{$row->cfg_id}"{$disabled_class}> \t\t\t{$zone_row} \t\t\t<td>{$row->cfg_name}</td> \t\t\t<td>{$cfg_data}</td> \t\t\t<td>{$comments}</td> \t\t\t{$edit_status} \t\t</tr> HTML; }
/** * Checks if the user is authenticated * * @since 1.0 * @package facileManager * * @return boolean */ function isLoggedIn() { global $fm_name; if (defined('INSTALL')) { return false; } /** No auth_method defined */ if (getOption('fm_db_version') >= 18) { if (!getOption('auth_method')) { if (!isset($_COOKIE['myid'])) { session_set_cookie_params(strtotime('+1 week')); @session_start(); $_SESSION['user']['logged_in'] = true; $_SESSION['user']['id'] = 1; $_SESSION['user']['account_id'] = 1; $modules = getActiveModules(true); if (!isset($_SESSION['module'])) { $_SESSION['module'] = is_array($modules) && count($modules) ? $modules[0] : $fm_name; } setcookie('myid', session_id(), strtotime('+1 week')); } session_set_cookie_params(strtotime('+1 week')); if (!empty($_COOKIE['myid'])) { @session_id($_COOKIE['myid']); @session_start(); } return true; } } /** Auth method defined so let's validate */ if (isset($_COOKIE['myid'])) { $myid = $_COOKIE['myid']; /** Init the session. */ session_set_cookie_params(strtotime('+1 week')); session_id($myid); @session_start(); /** Check if they're logged in. */ if (isset($_SESSION['user']['logged_in']) && $_SESSION['user']['logged_in']) { /** Set the last login info */ if (strtotime("-1 hour") > $_SESSION['user']['last_login']) { $_SESSION['user']['last_login'] = strtotime("-15 minutes"); $_SESSION['user']['ipaddr'] = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $_SERVER['REMOTE_ADDR']; } /** Should the user be logged in? */ if (getNameFromID($_SESSION['user']['id'], 'fm_users', 'user_', 'user_id', 'user_status') != 'active') { header('Location: ' . $GLOBALS['RELPATH'] . '?logout'); } return true; } } return false; }
/** * Gets all servers in a group * * @since 2.1 * @package facileManager */ function getGroupServers($id) { global $fmdb, $__FM_CONFIG; basicGet('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'server_groups', sanitize($id), 'group_', 'group_id'); if (!$fmdb->num_rows) { return sprintf(_('%d is not a valid group number.'), $id); } $group_details = $fmdb->last_result[0]; $group_masters = isset($group_details->group_masters) ? explode(';', $group_details->group_masters) : null; $group_slaves = isset($group_details->group_slaves) ? explode(';', $group_details->group_slaves) : null; $group_servers = array_merge($group_masters, $group_slaves); foreach ($group_servers as $key => $id) { $server_serial_nos[] = getNameFromID($id, 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_id', 'server_serial_no'); } return (array) $server_serial_nos; }
/** * Builds an array of available zone templates * * @since 2.0 * @package facileManager * @subpackage fmDNS * * @param int $domain_id Domain ID to get children * @return array */ function getZoneTemplateChildren($domain_id) { global $fmdb, $__FM_CONFIG; if (getNameFromID($domain_id, 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template') == 'yes') { $children = array(); basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'domains', 'domain_id', 'domain_', 'AND domain_template_id=' . $domain_id); if ($fmdb->num_rows) { for ($x = 0; $x < $fmdb->num_rows; $x++) { $children[] = $fmdb->last_result[$x]->domain_id; } } return $children; } return array($domain_id); }
function displayRow($row) { global $__FM_CONFIG; $disabled_class = $row->server_status == 'disabled' ? ' class="disabled"' : null; $timezone = date("T"); if (currentUserCan('manage_servers', $_SESSION['module'])) { $edit_status = '<td id="edit_delete_img">'; $edit_status .= '<a class="edit_form_link" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>'; $edit_status .= '<a class="status_form_link" href="#" rel="'; $edit_status .= $row->server_status == 'active' ? 'disabled' : 'active'; $edit_status .= '">'; $edit_status .= $row->server_status == 'active' ? $__FM_CONFIG['icons']['disable'] : $__FM_CONFIG['icons']['enable']; $edit_status .= '</a>'; $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>'; $edit_status .= '</td>'; } else { $edit_status = null; } /** Get some options */ $server_backup_credentials = getServerCredentials($_SESSION['user']['account_id'], $row->server_serial_no); if (!empty($server_backup_credentials[0])) { list($backup_username, $backup_password) = $server_backup_credentials; } else { $backup_username = getOption('backup_username', $_SESSION['user']['account_id'], $_SESSION['module']); $backup_password = getOption('backup_password', $_SESSION['user']['account_id'], $_SESSION['module']); } /** Get group associations */ $groups_array = explode(';', $row->server_groups); $groups = null; foreach ($groups_array as $group_id) { $group_name = getNameFromID($group_id, 'fm_' . $__FM_CONFIG['fmSQLPass']['prefix'] . 'groups', 'group_', 'group_id', 'group_name'); $groups .= "{$group_name}\n"; } $groups = nl2br(trim($groups)); if (empty($groups)) { $groups = 'None'; } echo <<<HTML \t\t<tr id="{$row->server_id}"{$disabled_class}> \t\t\t<td>{$row->server_name}</td> \t\t\t<td>{$row->server_type} (tcp/{$row->server_port})</td> \t\t\t<td>{$groups}</td> \t\t\t{$edit_status} \t\t</tr> HTML; }
function buildServerConfig($serial_no, $action = 'buildconf', $friendly_action = 'Configuration Build') { global $fmdb, $__FM_CONFIG, $fm_name; /** Check serial number */ basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', sanitize($serial_no), 'server_', 'server_serial_no'); if (!$fmdb->num_rows) { return sprintf('<p class="error">%s</p>', __('This server is not found.')); } $server_details = $fmdb->last_result; extract(get_object_vars($server_details[0]), EXTR_SKIP); $options[] = $response = null; $popup_footer = buildPopup('footer', 'OK', array('cancel_button' => 'cancel')); if ($action == 'buildconf') { if (getOption('enable_named_checks', $_SESSION['user']['account_id'], 'fmDNS') == 'yes') { global $fm_module_buildconf; include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_buildconf.php'; $data['SERIALNO'] = $server_serial_no; $data['compress'] = 0; $data['dryrun'] = true; basicGet('fm_accounts', $_SESSION['user']['account_id'], 'account_', 'account_id'); $account_result = $fmdb->last_result; $data['AUTHKEY'] = $account_result[0]->account_key; list($raw_data, $response) = $fm_module_buildconf->buildServerConfig($data); $response .= @$fm_module_buildconf->namedSyntaxChecks($raw_data); if (strpos($response, 'error') !== false) { return buildPopup('header', $friendly_action . ' Results') . $response . $popup_footer; } } if (getOption('purge_config_files', $_SESSION['user']['account_id'], 'fmDNS') == 'yes') { $options[] = 'purge'; } } switch ($server_update_method) { case 'cron': if ($action == 'buildconf') { /* set the server_update_config flag */ setBuildUpdateConfigFlag($serial_no, 'conf', 'update'); $response = sprintf('<p>%s</p>' . "\n", __('This server will be updated on the next cron run.')); } else { $response = sprintf('<p>%s</p>' . "\n", __('This server receives updates via cron - please manage the server manually.')); } break; case 'http': case 'https': /** Test the port first */ if (!socketTest($server_name, $server_update_port, 10)) { return sprintf('<p class="error">%s</p>' . "\n", sprintf(__('Failed: could not access %s using %s (tcp/%d).'), $server_name, $server_update_method, $server_update_port)); } /** Remote URL to use */ $url = $server_update_method . '://' . $server_name . ':' . $server_update_port . '/' . $_SESSION['module'] . '/reload.php'; /** Data to post to $url */ $post_data = array('action' => $action, 'serial_no' => $server_serial_no, 'options' => implode(' ', $options)); $post_result = @unserialize(getPostData($url, $post_data)); if (!is_array($post_result)) { /** Something went wrong */ if (empty($post_result)) { return sprintf('<p class="error">%s</p>', sprintf(__('It appears %s does not have php configured properly within httpd or httpd is not running.'), $server_name)); } return '<p class="error">' . $post_result . '</p>'; } else { if (count($post_result) > 1) { $response .= "<pre>\n"; /** Loop through and format the output */ foreach ($post_result as $line) { $response .= "[{$server_name}] {$line}\n"; } $response .= "</pre>\n"; } else { $response = "<p>[{$server_name}] " . $post_result[0] . '</p>'; } } break; case 'ssh': /** Test the port first */ if (!socketTest($server_name, $server_update_port, 10)) { return sprintf('<p class="error">%s</p>' . "\n", sprintf(__('Failed: could not access %s using %s (tcp/%d).'), $server_name, $server_update_method, $server_update_port)); } /** Get SSH key */ $ssh_key = getOption('ssh_key_priv', $_SESSION['user']['account_id']); if (!$ssh_key) { return sprintf('<p class="error">%s</p>' . "\n", sprintf(__('Failed: SSH key is not <a href="%s">defined</a>.'), getMenuURL(__('General')))); } $temp_ssh_key = sys_get_temp_dir() . '/fm_id_rsa'; if (file_exists($temp_ssh_key)) { @unlink($temp_ssh_key); } if (@file_put_contents($temp_ssh_key, $ssh_key) === false) { return sprintf('<p class="error">%s</p>' . "\n", sprintf(__('Failed: could not load SSH key into %s.'), $temp_ssh_key)); } @chmod($temp_ssh_key, 0400); $ssh_user = getOption('ssh_user', $_SESSION['user']['account_id']); if (!$ssh_user) { return sprintf('<p class="error">%s</p>' . "\n", sprintf(__('Failed: SSH user is not <a href="%s">defined</a>.'), getMenuURL(__('General')))); } /** Test SSH authentication */ exec(findProgram('ssh') . " -t -i {$temp_ssh_key} -o 'StrictHostKeyChecking no' -p {$server_update_port} -l {$ssh_user} {$server_name} 'ls /usr/local/{$fm_name}/{$_SESSION['module']}/dns.php'", $post_result, $retval); if ($retval) { /** Something went wrong */ @unlink($temp_ssh_key); return sprintf('<p class="error">%s</p>' . "\n", __('Failed: Could not login via SSH.')); } unset($post_result); /** Run build */ exec(findProgram('ssh') . " -t -i {$temp_ssh_key} -o 'StrictHostKeyChecking no' -p {$server_update_port} -l {$ssh_user} {$server_name} 'sudo php /usr/local/{$fm_name}/{$_SESSION['module']}/dns.php {$action} " . implode(' ', $options) . "'", $post_result, $retval); @unlink($temp_ssh_key); if ($retval) { /** Something went wrong */ return '<p class="error">' . ucfirst($friendly_action) . ' failed.</p>' . "\n"; } if (!count($post_result)) { $post_result[] = ucfirst($friendly_action) . ' was successful.'; } if (count($post_result) > 1) { $response = "<pre>\n"; /** Loop through and format the output */ foreach ($post_result as $line) { $response .= "[{$server_name}] {$line}\n"; } $response .= "</pre>\n"; } else { $response = "<p>[{$server_name}] " . $post_result[0] . '</p>'; } break; } if ($action == 'buildconf') { /* reset the server_build_config flag */ if (!strpos($response, strtolower('failed'))) { setBuildUpdateConfigFlag($serial_no, 'no', 'build'); } } $tmp_name = getNameFromID($serial_no, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', 'server_', 'server_serial_no', 'server_name'); addLogEntry(ucfirst($friendly_action) . " was performed on server '{$tmp_name}'."); if (strpos($response, '<pre>') !== false) { $response = buildPopup('header', $friendly_action . ' Results') . $response . $popup_footer; } return $response; }
/** * Deletes the selected template */ function delete($id, $table, $prefix) { global $fmdb, $__FM_CONFIG; $tmp_name = getNameFromID($id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . $table, $prefix . '_', $prefix . '_id', $prefix . '_name'); if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . $table, $id, $prefix . '_', 'deleted', $prefix . '_id') === false) { return __('This template could not be deleted because a database error occurred.'); } else { addLogEntry("Deleted {$prefix} template '{$tmp_name}'."); return true; } }
/** * Saves the options */ function save() { global $fmdb, $__FM_CONFIG, $fm_name; if (!currentUserCan('manage_settings')) { return _('You do not have permission to make these changes.'); } $force_logout = false; $exclude = array('save', 'item_type', 'gen_ssh'); $ports = array('ldap_port', 'ldap_port_ssl', 'fm_port_ssl'); $log_message = _('Set system settings to the following:') . "\n"; foreach ($_POST as $key => $data) { if (!in_array($key, $exclude)) { unset($data_array); if (is_array($data)) { $data_array = $data; $account_id = $_SESSION['user']['account_id']; $data = $data[$account_id]; } else { $account_id = 0; } /** Check if the option has changed */ $current_value = getOption($key, $account_id); unset($account_id); if ($current_value == $data) { continue; } if ($key == 'mail_from' && isEmailAddressValid($data) === false) { return sprintf(_('%s is not a valid e-mail address.'), $data); } if (in_array($key, $ports)) { if (!verifyNumber($data, 1, 65535, false)) { return _('Invalid port number specified.'); } } if (isset($data_array)) { $data = $data_array; } $new_array[$key] = $current_value === false ? array($data, 'insert') : array($data, 'update'); } } if (isset($new_array) && is_array($new_array)) { foreach ($new_array as $option => $value) { list($option_value, $command) = $value; if (is_array($option_value)) { $data_array = $option_value; $account_id = $_SESSION['user']['account_id']; $option_value = $option_value[$account_id]; } else { $account_id = 0; } /** Update with the new value */ $result = setOption($option, $option_value, $command, false, $account_id); unset($account_id); if (!$result) { return _('Could not save settings because a database error occurred.'); } $log_value = trim($option_value); $log_message .= ucwords(str_replace('_', ' ', $option)) . ': '; if (@is_array($__FM_CONFIG['options'][$option][0])) { foreach ($__FM_CONFIG['options'][$option] as $array) { if ($log_value == $array[1]) { $log_message .= $array[0]; break; } } } elseif ($option == 'mail_smtp_pass') { $log_message .= str_repeat('*', 8); } elseif ($option == 'date_format' || $option == 'time_format') { $log_message .= date($log_value); } elseif ($option == 'ldap_user_template') { $log_message .= getNameFromID($log_value, 'fm_users', 'user_', 'user_id', 'user_login'); } elseif ($option_value == '1') { $log_message .= _('Yes'); } elseif ($option_value == '0') { $log_message .= _('No'); } else { $log_message .= $log_value; } $log_message .= "\n"; if ($option == 'auth_method') { $force_logout = true; } if (isset($data_array)) { $data = $data_array; unset($data_array); } } addLogEntry($log_message, $fm_name); if ($force_logout) { exit('force_logout'); } return true; } return true; }
if ($_GET['type'] == 'servers') { if (!updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', $_GET['id'], 'server_', $_GET['status'], 'server_id')) { $response = sprintf(__('This server could not be set to %s.') . "\n", $_GET['status']); } else { /* set the server_build_config flag */ $query = "UPDATE `fm_{$__FM_CONFIG['fmDNS']['prefix']}servers` SET `server_build_config`='yes' WHERE `server_id`=" . sanitize($_GET['id']); $result = $fmdb->query($query); $tmp_name = getNameFromID($_GET['id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', 'server_', 'server_id', 'server_name'); addLogEntry(sprintf(__('Set server (%s) status to %s.'), $tmp_name, $_GET['status'])); header('Location: ' . $GLOBALS['basename'] . '?type=' . $_GET['type']); } } elseif ($_GET['type'] == 'groups') { if (!updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'server_groups', $_GET['id'], 'group_', $_GET['status'], 'group_id')) { $response = sprintf(__('This server group could not be set to %s.') . "\n", $_GET['status']); } else { $tmp_name = getNameFromID($_GET['id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'server_groups', 'group_', 'group_id', 'group_name'); addLogEntry(sprintf(__('Set server group (%s) status to %s.'), $tmp_name, $_GET['status'])); header('Location: ' . $GLOBALS['basename'] . '?type=' . $_GET['type']); } } } break; } } printHeader(); @printMenu(); $avail_types = buildSubMenu($type); echo printPageHeader($response, $display_type, currentUserCan('manage_servers', $_SESSION['module']), $type); $sort_direction = null; if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) { extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
function autoCreatePTR($domain_id, $record_type, $data) { if ($record_type == 'A' && isset($data['PTR']) && zoneAccessIsAllowed(array($data['PTR']))) { global $__FM_CONFIG; $domain = '.' . trimFullStop(getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name')) . '.'; if ($data['record_name'][0] == '@') { $data['record_name'] = null; $domain = substr($domain, 1); } /** Get reverse zone */ if (!strrpos($data['record_value'], ':')) { $rev_domain = trimFullStop(getNameFromID($data['PTR'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name')); $domain_pieces = array_reverse(explode('.', $rev_domain)); $domain_parts = count($domain_pieces); $subnet_ips = null; for ($i = 2; $i < $domain_parts; $i++) { $subnet_ips .= $domain_pieces[$i] . '.'; } $record_octets = array_reverse(explode('.', str_replace($subnet_ips, '', $data['record_value']))); $temp_record_value = null; for ($j = 0; $j < count($record_octets); $j++) { $temp_record_value .= $record_octets[$j] . '.'; } $data['record_value'] = rtrim($temp_record_value, '.'); } else { /** IPv6 not yet supported */ break; } $array = array('record_name' => $data['record_value'], 'record_value' => $data['record_name'] . $domain, 'record_comment' => $data['record_comment'], 'record_status' => $data['record_status']); global $fm_dns_records; $fm_dns_records->add($data['PTR'], 'PTR', $array, 'replace'); } }
/** * Deletes the selected user * * @since 1.0 * @package facileManager */ function delete($id) { global $fm_name; /** Ensure user is not current LDAP template user */ if (getOption('auth_method') == 2) { $template_user_id = getOption('ldap_user_template'); if ($id == $template_user_id) { return _('This user is the LDAP user template and cannot be deleted at this time.'); } } $tmp_name = getNameFromID($id, 'fm_users', 'user_', 'user_id', 'user_login'); if (!updateStatus('fm_users', $id, 'user_', 'deleted', 'user_id')) { return _('This user could not be deleted.') . "\n"; } else { addLogEntry(sprintf(_("Deleted user '%s'."), $tmp_name), $fm_name); return true; } }
*/ if (!currentUserCan(array('manage_policies', 'view_all'), $_SESSION['module'])) { unAuth(); } /** Include module variables */ if (isset($_SESSION['module'])) { include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/variables.inc.php'; } $server_config_page = $GLOBALS['RELPATH'] . $menu[getParentMenuKey()][4]; $type = isset($_GET['type']) && array_key_exists(sanitize(strtolower($_GET['type'])), $__FM_CONFIG['policy']['avail_types']) ? sanitize(strtolower($_GET['type'])) : 'rules'; $server_serial_no = isset($_GET['server_serial_no']) ? sanitize($_GET['server_serial_no']) : header('Location: ' . $server_config_page); if (!($server_id = getServerID($server_serial_no, $_SESSION['module']))) { header('Location: ' . $server_config_page); } /** Should not be here if the client has not been installed */ if (getNameFromID($server_id, 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_id', 'server_installed') != 'yes') { header('Location: ' . $server_config_page); } include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_policies.php'; if (currentUserCan('manage_servers', $_SESSION['module'])) { $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'add'; switch ($action) { case 'add': if (!empty($_POST)) { $result = $fm_module_policies->add($_POST); if ($result !== true) { $response = $result; $form_data = $_POST; } else { header('Location: ' . $GLOBALS['basename'] . "?type={$type}&server_serial_no={$server_serial_no}"); }
function displayRow($row, $channel_category) { global $__FM_CONFIG; $disabled_class = $row->cfg_status == 'disabled' ? ' class="disabled"' : null; $edit_name = $row->cfg_parent ? ' ' : null; if (currentUserCan('manage_servers', $_SESSION['module'])) { $edit_status = '<td id="edit_delete_img">'; $edit_status .= '<a class="edit_form_link" name="' . $channel_category . '" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>'; $edit_status .= '<a class="status_form_link" href="#" rel="'; $edit_status .= $row->cfg_status == 'active' ? 'disabled' : 'active'; $edit_status .= '">'; $edit_status .= $row->cfg_status == 'active' ? $__FM_CONFIG['icons']['disable'] : $__FM_CONFIG['icons']['enable']; $edit_status .= '</a>'; if ($channel_category == 'channel' && is_array($this->getAssocCategories($row->cfg_id))) { $edit_status .= null; } else { $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>'; } $edit_status .= '</td>'; } else { $edit_status = null; } $edit_name .= $row->cfg_data; if ($channel_category == 'category') { $channels = null; $assoc_channels = $this->getAssocChannels($row->cfg_id); foreach ($assoc_channels as $channel) { if (is_numeric($channel)) { $channel = getNameFromID($channel, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_', 'cfg_id', 'cfg_data'); } $channels .= "{$channel}, "; } $channels = rtrim($channels, ', '); $channels_row = '<td>' . $channels . '</td>'; } else { $channels_row = null; } $comments = nl2br($row->cfg_comment); echo <<<HTML \t\t<tr id="{$row->cfg_id}"{$disabled_class}> \t\t\t<td>{$edit_name}</td> \t\t\t{$channels_row} \t\t\t<td>{$comments}</td> \t\t\t{$edit_status} \t\t</tr> HTML; }
/** * Deletes the selected group */ function delete($id) { global $fmdb, $__FM_CONFIG; // Delete group $tmp_name = getNameFromID($id, 'fm_' . $__FM_CONFIG['fmSQLPass']['prefix'] . 'groups', 'group_', 'group_id', 'group_name'); if (!updateStatus('fm_' . $__FM_CONFIG['fmSQLPass']['prefix'] . 'groups', $id, 'group_', 'deleted', 'group_id')) { return __('This server group could not be deleted.') . "\n"; } else { addLogEntry("Deleted server group '{$tmp_name}'."); return true; } }
exit('Success'); } } break; case 'delete': if (isset($id)) { exit(parseAjaxOutput($post_class->delete(sanitize($id), $type, $server_serial_no))); } break; case 'edit': if (isset($_POST['item_status'])) { if (!updateStatus('fm_' . $table, $id, $prefix, sanitize($_POST['item_status']), $prefix . 'id')) { exit(sprintf(__('This item could not be set to %s.') . "\n", $_POST['item_status'])); } else { setBuildUpdateConfigFlag($server_serial_no, 'yes', 'build'); $tmp_name = getNameFromID($id, 'fm_' . $table, $prefix, $prefix . 'id', $field_data); addLogEntry(sprintf(__('Set %s (%s) status to %s.'), $object, $tmp_name, sanitize($_POST['item_status']))); exit('Success'); } } break; } exit; } echo $unpriv_message; /** * Processes the array of domain ids for reload * * @since 2.0 * @package facileManager * @subpackage fmDNS
include ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $fm_name . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'class_users.php'; switch ($_POST['action']) { case 'delete': if (isset($id)) { $delete_status = $fm_users->delete(sanitize($id), substr(sanitize($_POST['item_sub_type']), 0, -1)); if ($delete_status !== true) { echo $delete_status; } else { exit('Success'); } } break; case 'edit': if (isset($_POST['item_status'])) { if (!updateStatus('fm_users', $id, 'user_', sanitize($_POST['item_status']), 'user_id')) { exit(sprintf(_('This user could not be set to %s.') . "\n", $_POST['item_status'])); } else { $tmp_name = getNameFromID($id, 'fm_users', 'user_', 'user_id', 'user_login'); addLogEntry(sprintf(_('Set user (%s) status to %s.'), $tmp_name, sanitize($_POST['item_status']))); exit('Success'); } } break; } /** Handle everything else */ } elseif (isset($_SESSION['module']) && $_SESSION['module'] != $fm_name) { $include_file = ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $_SESSION['module'] . DIRECTORY_SEPARATOR . 'ajax' . DIRECTORY_SEPARATOR . 'processPost.php'; if (file_exists($include_file)) { include $include_file; } }
/** * Deletes the selected object */ function delete($object_id) { global $fmdb, $__FM_CONFIG; /** Does the object_id exist for this account? */ basicGet('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', $object_id, 'object_', 'object_id'); if ($fmdb->num_rows) { /** Is the object_id present in a policy? */ if (isItemInPolicy($object_id, 'object')) { return __('This object could not be deleted because it is associated with one or more policies.'); } /** Delete object */ $tmp_name = getNameFromID($object_id, 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', 'object_', 'object_id', 'object_name'); if (updateStatus('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', $object_id, 'object_', 'deleted', 'object_id')) { addLogEntry(sprintf(__('Object (%s) was deleted.'), $tmp_name)); return true; } } return __('This object could not be deleted.'); }
if (!currentUserCan('manage_records', $_SESSION['module'])) { unAuth(); } if (!zoneAccessIsAllowed(array($domain_id))) { unAuth(); } if (in_array($record_type, $__FM_CONFIG['records']['require_zone_rights']) && !currentUserCan('manage_zones', $_SESSION['module'])) { unAuth(); } /** Make sure we can handle all of the variables */ checkMaxInputVars(); $domain_info['id'] = $domain_id; $domain_info['name'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name'); $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) {
/** 1.3-beta1 */ function upgradefmDNS_1301($__FM_CONFIG, $running_version) { global $fmdb, $module_name; $success = version_compare($running_version, '1.2.4', '<') ? upgradefmDNS_124($__FM_CONFIG, $running_version) : true; if (!$success) { return false; } $table[] = <<<TABLE CREATE TABLE IF NOT EXISTS `fm_{$__FM_CONFIG['fmDNS']['prefix']}controls` ( `control_id` int(11) NOT NULL AUTO_INCREMENT, `account_id` int(11) NOT NULL DEFAULT '1', `server_serial_no` int(11) NOT NULL DEFAULT '0', `control_ip` varchar(15) NOT NULL DEFAULT '*', `control_port` int(5) NOT NULL DEFAULT '953', `control_addresses` text NOT NULL, `control_keys` varchar(255) DEFAULT NULL, `control_comment` text NOT NULL, `control_status` enum('active','disabled','deleted') NOT NULL DEFAULT 'active', PRIMARY KEY (`control_id`) ) ENGINE = MYISAM DEFAULT CHARSET=utf8; TABLE; $table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}records` CHANGE `record_type` `record_type` ENUM( 'A', 'AAAA', 'CERT', 'CNAME', 'DNAME', 'DNSKEY', 'KEY', 'KX', 'MX', 'NS', 'PTR', 'RP', 'SRV', 'TXT', 'HINFO', 'SSHFP' ) NOT NULL DEFAULT 'A'"; $table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}soa` ADD `soa_name` VARCHAR(255) NULL AFTER `domain_id`"; $table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}servers` ADD `server_chroot_dir` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `server_root_dir`"; $table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains` ADD `soa_id` INT( 11 ) NOT NULL DEFAULT '0' AFTER `account_id` ,\n\t\tADD `soa_serial_no` INT(2) UNSIGNED ZEROFILL NOT NULL DEFAULT '0' AFTER `soa_id` "; $table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}soa` ADD `soa_template` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `domain_id`"; $table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}config` CHANGE `cfg_view` `view_id` INT(11) NOT NULL DEFAULT '0'"; $table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}config` ADD `domain_id` INT(11) NOT NULL DEFAULT '0' AFTER `view_id`"; $table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}config` ADD INDEX(`domain_id`)"; $table[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}functions` CHANGE `def_view_support` `def_clause_support` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'O'"; $table[] = "TRUNCATE `fm_{$__FM_CONFIG['fmDNS']['prefix']}functions`"; $updates[] = "UPDATE `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains` d JOIN `fm_{$__FM_CONFIG['fmDNS']['prefix']}soa` s ON d.`domain_id` = s.`domain_id` SET d.`soa_id`=s.`soa_id`"; $updates[] = "UPDATE `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains` d JOIN `fm_{$__FM_CONFIG['fmDNS']['prefix']}soa` s ON d.`domain_id` = s.`domain_id` SET d.`soa_serial_no`=s.`soa_serial_no`"; $updates[] = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}soa` DROP `domain_id`, DROP `soa_serial_no`"; $inserts[] = <<<INSERT INSERT IGNORE INTO `fm_{$__FM_CONFIG['fmDNS']['prefix']}functions` ( `def_function` , `def_option` , `def_type` , `def_multiple_values` , `def_clause_support`, `def_dropdown` ) VALUES ('key', 'algorithm', 'string', 'no', 'K', 'no'), ('key', 'secret', 'quoted_string', 'no', 'K', 'no'), ('options', 'acache-cleaning-interval', '( minutes )', 'no', 'OV', 'no'), ('options', 'acache-enable', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'additional-from-auth', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'additional-from-cache', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'allow-notify', '( address_match_element )', 'yes', 'OVZ', 'no'), ('options', 'allow-query', '( address_match_element )', 'yes', 'OVZ', 'no'), ('options', 'allow-query-cache', '( address_match_element )', 'yes', 'OV', 'no'), ('options', 'allow-query-cache-on', '( address_match_element )', 'yes', 'OV', 'no'), ('options', 'allow-query-on', '( address_match_element )', 'yes', 'OVZ', 'no'), ('options', 'allow-recursion', '( address_match_element )', 'yes', 'OV', 'no'), ('options', 'allow-recursion-on', '( address_match_element )', 'yes', 'OV', 'no'), ('options', 'allow-transfer', '( address_match_element )', 'yes', 'OVZ', 'no'), ('options', 'allow-update', '( address_match_element )', 'yes', 'OVZ', 'no'), ('options', 'allow-update-forwarding', '( address_match_element )', 'yes', 'OVZ', 'no'), ('options', 'also-notify', '( ipv4_address | ipv6_address ) [ port ( ip_port | * ) ]', 'yes', 'OVZ', 'no'), ('options', 'alt-transfer-source', '( ipv4_address | * ) [ port ( ip_port | * ) ]', 'no', 'OVZ', 'no'), ('options', 'alt-transfer-source-v6', '( ipv6_address | * ) [ port ( ip_port | * ) ]', 'no', 'OVZ', 'no'), ('options', 'attach-cache', '( quoted_string )', 'no', 'OV', 'no'), ('options', 'auth-nxdomain', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'auto-dnssec', '( allow | maintain | create | off )', 'no', 'OVZ', 'yes'), ('options', 'avoid-v4-udp-ports', '( ip_port )', 'yes', 'O', 'no'), ('options', 'avoid-v6-udp-ports', '( ip_port )', 'yes', 'O', 'no'), ('options', 'bindkeys-file', '( quoted_string )', 'no', 'O', 'no'), ('options', 'blackhole', '( address_match_element )', 'yes', 'O', 'no'), ('options', 'bogus', '( yes | no )', 'no', 'S', 'yes'), ('options', 'check-dup-records', '( fail | warn | ignore )', 'no', 'OVZ', 'yes'), ('options', 'check-integrity', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'check-mx', '( fail | warn | ignore )', 'no', 'OVZ', 'yes'), ('options', 'check-mx-cname', '( fail | warn | ignore )', 'no', 'OVZ', 'yes'), ('options', 'check-names', '( master | slave | response ) ( warn | fail | ignore )', 'no', 'OVZ', 'yes'), ('options', 'check-sibling', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'check-srv-cname', '( fail | warn | ignore )', 'no', 'OVZ', 'yes'), ('options', 'check-wildcard', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'cleaning-interval', '( minutes )', 'no', 'OV', 'no'), ('options', 'clients-per-query', '( integer )', 'no', 'OV', 'no'), ('options', 'coresize', '( size_in_bytes )', 'no', 'O', 'no'), ('options', 'database', '( quoted_string )', 'no', 'Z', 'no'), ('options', 'datasize', '( size_in_bytes )', 'no', 'O', 'no'), ('options', 'delegation-only', '( yes | no )', 'no', 'Z', 'yes'), ('options', 'deny-answer-address', '( address_match_element ) [ except-from { ( address_match_element ) } ]', 'yes', 'OV', 'no'), ('options', 'deny-answer-aliases', '( quoted_string ) [ except-from { ( address_match_element ) } ]', 'yes', 'OV', 'no'), ('options', 'dialup', '( yes | no | notify | refresh | passive | notify-passive )', 'no', 'OVZ', 'yes'), ('options', 'disable-algorithms', '( string )', 'yes', 'OV', 'no'), ('options', 'disable-empty-zone', '( quoted_string )', 'no', 'OV', 'no'), ('options', 'dnssec-accept-expired', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'dnssec-dnskey-kskonly', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'dnssec-enable', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'dnssec-lookaside', 'domain trust-anchor domain', 'no', 'OV', 'no'), ('options', 'dnssec-must-be-secure', 'domain ( yes | no )', 'no', 'OV', 'no'), ('options', 'dnssec-secure-to-insecure', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'dnssec-validation', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'dual-stack-servers', '( quoted_string )', 'yes', 'OV', 'no'), ('options', 'dump-file', '( quoted_string )', 'no', 'O', 'no'), ('options', 'edns', '( yes | no )', 'no', 'S', 'yes'), ('options', 'edns-udp-size', '( size_in_bytes )', 'no', 'OSV', 'no'), ('options', 'empty-contact', '( string )', 'no', 'OV', 'no'), ('options', 'empty-server', '( string )', 'no', 'OV', 'no'), ('options', 'empty-zones-enable', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'files', '( integer )', 'no', 'O', 'no'), ('options', 'flush-zones-on-shutdown', '( yes | no )', 'no', 'O', 'yes'), ('options', 'forward', '( first | only )', 'no', 'OVZ', 'yes'), ('options', 'forwarders', '[ port ( ip_port | * ) ] { ( ipv4_address | ipv6_address ) } [ port ( ip_port | * ) ]', 'yes', 'OVZ', 'no'), ('options', 'heartbeat-interval', '( minutes )', 'no', 'O', 'no'), ('options', 'hostname', '( quoted_string | none )', 'no', 'O', 'no'), ('options', 'interface-interval', '( minutes )', 'no', 'O', 'no'), ('options', 'ixfr-from-differences', '( yes | no )', 'no', 'Z', 'yes'), ('options', 'journal', '( quoted_string )', 'no', 'Z', 'no'), ('options', 'key-directory', '( quoted_string )', 'no', 'OVZ', 'no'), ('options', 'lame-ttl', '( seconds )', 'no', 'OV', 'no'), ('options', 'listen-on', '[ port ( ip_port | * ) ] { ( ipv4_address ) }', 'yes', 'OR', 'no'), ('options', 'listen-on-v6', '[ port ( ip_port | * ) ] { ( ipv6_address ) }', 'yes', 'O', 'no'), ('options', 'managed-keys-directory', '( quoted_string )', 'no', 'O', 'no'), ('options', 'masterfile-format', '( text | raw )', 'no', 'OVZ', 'yes'), ('options', 'masters', '( { ipv4_address | ipv6_address } )', 'yes', 'OVZ', 'no'), ('options', 'match-clients', '( address_match_element )', 'yes', 'V', 'no'), ('options', 'match-destinations', '( address_match_element )', 'yes', 'V', 'no'), ('options', 'match-mapped-addresses', '( yes | no )', 'no', 'O', 'yes'), ('options', 'match-recursive-only', '( yes | no )', 'no', 'V', 'yes'), ('options', 'max-acache-size', '( size_in_bytes )', 'no', 'OV', 'no'), ('options', 'max-cache-size', '( size_in_bytes )', 'no', 'OV', 'no'), ('options', 'max-cache-ttl', '( seconds )', 'no', 'OV', 'no'), ('options', 'max-clients-per-query', '( integer )', 'no', 'OV', 'no'), ('options', 'max-journal-size', '( size_in_bytes )', 'no', 'OVZ', 'no'), ('options', 'max-ncache-ttl', '( seconds )', 'no', 'OV', 'no'), ('options', 'max-refresh-time', '( seconds )', 'no', 'OVZ', 'no'), ('options', 'max-retry-time', '( seconds )', 'no', 'OVZ', 'no'), ('options', 'max-transfer-idle-in', '( minutes )', 'no', 'OVZ', 'no'), ('options', 'max-transfer-idle-out', '( minutes )', 'no', 'OVZ', 'no'), ('options', 'max-transfer-time-in', '( minutes )', 'no', 'OVZ', 'no'), ('options', 'max-transfer-time-out', '( minutes )', 'no', 'OVZ', 'no'), ('options', 'max-udp-size', '( size_in_bytes )', 'no', 'OSV', 'no'), ('options', 'memstatistics', '( yes | no )', 'no', 'O', 'yes'), ('options', 'memstatistics-file', '( quoted_string )', 'no', 'O', 'no'), ('options', 'min-refresh-time', '( seconds )', 'no', 'OVZ', 'no'), ('options', 'min-retry-time', '( seconds )', 'no', 'OVZ', 'no'), ('options', 'minimal-responses', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'multi-master', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'ndots', '( integer )', 'no', 'R', 'no'), ('options', 'notify', '( yes | no | explicit )', 'no', 'OVZ', 'yes'), ('options', 'notify-delay', '( seconds )', 'no', 'OVZ', 'no'), ('options', 'notify-source', '( ipv4_address | * ) [ port ( ip_port | * ) ]', 'no', 'OSVZ', 'no'), ('options', 'notify-source-v6', '( ipv6_address | * ) [ port ( ip_port | * ) ]', 'no', 'OSVZ', 'no'), ('options', 'notify-to-soa', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'pid-file', '( quoted_string | none )', 'no', 'O', 'no'), ('options', 'port', '( ip_port )', 'no', 'O', 'no'), ('options', 'preferred-glue', '( A | AAAA )', 'no', 'OV', 'yes'), ('options', 'provide-ixfr', '( yes | no )', 'no', 'S', 'yes'), ('options', 'query-source', 'address ( ipv4_address | * ) [ port ( ip_port | * ) ]', 'no', 'OVZ', 'no'), ('options', 'query-source-v6', 'address ( ipv6_address | * ) [ port ( ip_port | * ) ]', 'no', 'OVZ', 'no'), ('options', 'querylog', '( yes | no )', 'no', 'O', 'yes'), ('options', 'random-device', '( quoted_string )', 'no', 'O', 'no'), ('options', 'recursing-file', '( quoted_string )', 'no', 'O', 'no'), ('options', 'recursion', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'recursive-clients', '( integer )', 'no', 'O', 'no'), ('options', 'request-ixfr', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'request-nsid', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'reserved-sockets', '( integer )', 'no', 'O', 'no'), ('options', 'search', '( quoted_string )', 'yes', 'R', 'no'), ('options', 'secroots-file', '( quoted_string )', 'no', 'O', 'no'), ('options', 'serial-query-rate', '( integer )', 'no', 'O', 'no'), ('options', 'server-id', '( quoted_string | none | hostname )', 'no', 'O', 'no'), ('options', 'session-keyfile', '( quoted_string | none )', 'no', 'O', 'no'), ('options', 'session-keyname', '( quoted_string )', 'no', 'O', 'no'), ('options', 'session-keyalg', '( string )', 'no', 'O', 'no'), ('options', 'sig-signing-nodes', '( integer )', 'no', 'OVZ', 'no'), ('options', 'sig-signing-signatures', '( integer )', 'no', 'OVZ', 'no'), ('options', 'sig-signing-type', '( integer )', 'no', 'OVZ', 'no'), ('options', 'sig-validity-interval', '( days )', 'no', 'OVZ', 'no'), ('options', 'sortlist', '( address_match_element )', 'yes', 'OV', 'no'), ('options', 'stacksize', '( size_in_bytes )', 'no', 'O', 'no'), ('options', 'statistics-file', '( quoted_string )', 'no', 'O', 'no'), ('options', 'tcp-clients', '( integer )', 'no', 'O', 'no'), ('options', 'tcp-listen-queue', '( integer )', 'no', 'O', 'no'), ('options', 'tkey-dhkey', '( quoted_string integer )', 'no', 'O', 'no'), ('options', 'tkey-domain', '( quoted_string )', 'no', 'O', 'no'), ('options', 'tkey-gssapi-credential', '( quoted_string )', 'no', 'O', 'no'), ('options', 'transfer-format', '( many-answers | one-answer )', 'no', 'OSVZ', 'yes'), ('options', 'transfer-source', '( ipv4_address | * ) [ port ( ip_port | * ) ]', 'no', 'OSVZ', 'no'), ('options', 'transfer-source-v6', '( ipv6_address | * ) [ port ( ip_port | * ) ]', 'no', 'OSVZ', 'no'), ('options', 'transfers', '( integer )', 'no', 'S', 'no'), ('options', 'transfers-in', '( integer )', 'no', 'O', 'no'), ('options', 'transfers-out', '( integer )', 'no', 'O', 'no'), ('options', 'transfers-per-ns', '( integer )', 'no', 'O', 'no'), ('options', 'try-tcp-refresh', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'update-check-ksk', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'update-policy', '( local | { update-policy-rule } )', 'no', 'Z', 'no'), ('options', 'use-alt-transfer-source', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'use-v4-udp-ports', '( range ip_port ip_port )', 'no', 'O', 'no'), ('options', 'use-v6-udp-ports', '( range ip_port ip_port )', 'no', 'O', 'no'), ('options', 'view', '( quoted_string )', 'no', 'R', 'no'), ('options', 'version', '( quoted_string | none )', 'no', 'O', 'no'), ('options', 'zero-no-soa-ttl', '( yes | no )', 'no', 'OVZ', 'yes'), ('options', 'zero-no-soa-ttl-cache', '( yes | no )', 'no', 'OV', 'yes'), ('options', 'zone-statistics', '( yes | no )', 'no', 'OVZ', 'yes') ; INSERT; /** Create table schema */ if (count($table) && $table[0]) { foreach ($table as $schema) { $fmdb->query($schema); if (!$fmdb->result || $fmdb->sql_errors) { return false; } } } if (count($inserts) && $inserts[0]) { foreach ($inserts as $schema) { $fmdb->query($schema); if (!$fmdb->result || $fmdb->sql_errors) { return false; } } } if (count($updates) && $updates[0]) { foreach ($updates as $schema) { $fmdb->query($schema); if (!$fmdb->result || $fmdb->sql_errors) { return false; } } } $query = "SELECT * FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains`"; $fmdb->query($query); $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; $translate_array = array('domain_check_names' => 'check-names', 'domain_notify_slaves' => 'notify', 'domain_multi_masters' => 'multi-master', 'domain_transfers_from' => 'transfers-from', 'domain_updates_from' => 'updates-from', 'domain_master_servers' => 'masters', 'domain_forward_servers' => 'forwarders'); for ($x = 0; $x < $num_rows; $x++) { foreach ($translate_array as $old_key => $new_key) { if ($results[$x]->{$old_key}) { $query = "INSERT INTO `fm_{$__FM_CONFIG['fmDNS']['prefix']}config` \n\t\t\t\t\t(account_id,domain_id,cfg_name,cfg_data) VALUES ({$_SESSION['user']['account_id']},\n\t\t\t\t\t{$results[$x]->domain_id}, '{$new_key}', '{$results[$x]->{$old_key}}')"; $fmdb->query($query); if (!$fmdb->result || $fmdb->sql_errors) { return false; } } } } $query = "ALTER TABLE `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains`"; foreach ($translate_array as $old_key => $new_key) { $query .= " DROP `{$old_key}`,"; } $query = rtrim($query, ','); $fmdb->query($query); if (!$fmdb->result || $fmdb->sql_errors) { return false; } /** Update manually entered ACLs with acl_ids */ $query = "SELECT * FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}config` WHERE cfg_type='global'"; $fmdb->query($query); $num_rows = $fmdb->num_rows; $results = $fmdb->last_result; for ($x = 0; $x < $num_rows; $x++) { $cfg_data_array = explode(';', $results[$x]->cfg_data); $new_cfg_data = null; foreach ($cfg_data_array as $acl_name) { $acl_id = getNameFromID(trim($acl_name), "fm_{$__FM_CONFIG['fmDNS']['prefix']}acls", 'acl_', 'acl_name', 'acl_id'); $new_cfg_data .= $acl_id ? "acl_{$acl_id}," : $acl_name . ','; } $new_cfg_data = rtrim($new_cfg_data, ','); $query = "UPDATE `fm_{$__FM_CONFIG['fmDNS']['prefix']}config` SET cfg_data='{$new_cfg_data}' WHERE cfg_id=" . $results[$x]->cfg_id; $fmdb->query($query); if (!$fmdb->result || $fmdb->sql_errors) { return false; } } setOption('version', '1.3-beta1', 'auto', false, 0, $module_name); return true; }
/** * Gets the user capabilities * * @since 1.2 * @package facileManager * * @param integer $user_id User ID to retrieve. * @return array */ function getUserCapabilities($user_id) { $user_capabilities = getNameFromID($user_id, 'fm_users', 'user_', 'user_id', 'user_caps'); if (isSerialized($user_capabilities)) { $user_capabilities = unserialize($user_capabilities); } return $user_capabilities; }
function displayLogData($page, $search_sql = null) { global $fmdb, $fm_name, $__FM_CONFIG; /** Get datetime formatting */ $date_format = getOption('date_format', $_SESSION['user']['account_id']); $time_format = getOption('time_format', $_SESSION['user']['account_id']); $query = "SELECT * FROM fm_logs WHERE account_id IN (0,{$_SESSION['user']['account_id']}) {$search_sql} ORDER BY log_timestamp DESC LIMIT " . ($page - 1) * $_SESSION['user']['record_count'] . ", {$_SESSION['user']['record_count']}"; $fmdb->query($query); $result = $fmdb->last_result; $log_count = $fmdb->num_rows; if (!$log_count) { printf('<tr><td colspan="4"><p class="no_results">%s</p></td></tr>', _('There are no log results.')); } for ($i = 0; $i < $log_count; $i++) { extract(get_object_vars($result[$i]), EXTR_OVERWRITE); $log_data = nl2br(wordwrap($log_data, 80, "\n", true)); if (isset($_POST['log_search_query'])) { $log_data = str_replace($_POST['log_search_query'], '<span class="highlighted">' . $_POST['log_search_query'] . '</span>', $log_data); } $user_name = $user_id ? getNameFromID($user_id, 'fm_users', 'user_', 'user_id', 'user_login') : $fm_name; $log_timestamp = date($date_format . ' ' . $time_format . ' e', $log_timestamp); echo <<<ROW \t\t\t\t<tr> \t\t\t\t\t<td>{$log_timestamp}</td> \t\t\t\t\t<td>{$log_module}</td> \t\t\t\t\t<td>{$user_name}</td> \t\t\t\t\t<td>{$log_data}</td> \t\t\t\t</tr> ROW; } }
function buildRecordTypes($record_type = null, $all_domain_ids = null, $map = 'forward', $supported_record_types, $search_query = null) { global $fmdb, $__FM_CONFIG; $menu_selects = $menu_sub_selects = null; $q = isset($_GET['q']) ? '&q=' . sanitize($_GET['q']) : null; if (isset($record_type) && $all_domain_ids != null) { $domain_id = $all_domain_ids[0]; $query = "SELECT DISTINCT `record_type` FROM fm_{$__FM_CONFIG['fmDNS']['prefix']}records WHERE `record_status`!='deleted' AND\n\t\t\t`account_id`={$_SESSION['user']['account_id']} AND `domain_id` IN (" . implode(',', $all_domain_ids) . ") {$search_query}"; $fmdb->get_results($query); $used_record_types = array(); if ($fmdb->num_rows) { $type_result = $fmdb->last_result; for ($i = 0; $i < $fmdb->num_rows; $i++) { $used_record_types[] = $type_result[$i]->record_type; } } @sort($used_record_types); $used_record_types[] = 'SOA'; foreach ($used_record_types as $type) { if (empty($type)) { continue; } if (in_array($type, $__FM_CONFIG['records']['require_zone_rights']) && !currentUserCan('manage_zones', $_SESSION['module'])) { continue; } if ($type == 'SOA') { /** Skip clones */ if (getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_clone_domain_id')) { continue; } /** Skip templates */ if (getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id')) { continue; } } $select = $record_type == $type ? ' class="selected"' : ''; $menu_selects .= "<span{$select}><a{$select} href=\"zone-records.php?map={$map}&domain_id={$domain_id}&record_type={$type}{$q}\">{$type}</a></span>\n"; } /** More record types menu */ if (count($used_record_types) < count($supported_record_types)) { foreach ($supported_record_types as $type) { if (!in_array($type, $used_record_types)) { if ($record_type == $type) { $menu_selects .= "<span class=\"selected\"><a class=\"selected\" href=\"zone-records.php?map={$map}&domain_id={$domain_id}&record_type={$type}\">{$type}</a></span>\n"; } else { $menu_sub_selects .= "<li><a href=\"zone-records.php?map={$map}&domain_id={$domain_id}&record_type={$type}{$q}\"><span>{$type}</span></a></li>\n"; } } } $menu_selects = <<<MENU \t\t\t{$menu_selects} \t\t\t</div> \t\t\t<div id="configtypesmenu" class="nopadding dropdown"> \t\t\t\t<div id="recordmenu"> \t\t\t\t<ul> \t\t\t\t\t<li class="has-sub"><a href="#"><span>...</span></a> \t\t\t\t\t\t<ul> \t\t\t\t\t\t{$menu_sub_selects} \t\t\t\t\t\t</ul> \t\t\t\t\t</li> \t\t\t\t</ul> \t\t\t\t</div> MENU; } } return '<div id="configtypesmenu" class="submenus">' . $menu_selects . '</div>'; }
/** * 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; }
function validatePost($post) { global $fmdb, $__FM_CONFIG; if (empty($post['server_name'])) { return __('No server name defined.'); } /** Check name field length */ $field_length = getColumnLength('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_name'); if ($field_length !== false && strlen($post['server_name']) > $field_length) { return sprintf(dngettext($_SESSION['module'], 'Server name is too long (maximum %d character).', 'Server name is too long (maximum %d characters).', $field_length), $field_length); } /** Does the record already exist for this account? */ basicGet('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', $post['server_name'], 'server_', 'server_name', "AND server_id!='{$post['server_id']}'"); if ($fmdb->num_rows) { return __('This server name already exists.'); } if (empty($post['server_config_file'])) { $post['server_config_file'] = $__FM_CONFIG['fw']['config_file']['default']; if (!is_array($__FM_CONFIG['fw']['config_file'][$post['server_type']]) && $__FM_CONFIG['fw']['config_file'][$post['server_type']]) { $post['server_config_file'] = $__FM_CONFIG['fw']['config_file'][$post['server_type']]; } elseif (is_array($__FM_CONFIG['fw']['config_file'][$post['server_type']])) { if (isset($post['server_os_distro'])) { $distro = $post['server_os_distro']; } else { if ($post['action'] == 'edit') { $distro = getNameFromID($post['server_id'], 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_id', 'server_os_distro'); } } if (isset($distro) && array_key_exists($distro, $__FM_CONFIG['fw']['config_file'][$post['server_type']])) { $post['server_config_file'] = $__FM_CONFIG['fw']['config_file'][$post['server_type']][$distro]; } } } /** Set default ports */ if (empty($post['server_update_port']) || isset($post['server_update_port']) && $post['server_update_method'] == 'cron') { $post['server_update_port'] = 0; } if (!empty($post['server_update_port']) && !verifyNumber($post['server_update_port'], 1, 65535, false)) { return __('Server update port must be a valid TCP port.'); } if (empty($post['server_update_port']) && isset($post['server_update_method'])) { if ($post['server_update_method'] == 'http') { $post['server_update_port'] = 80; } elseif ($post['server_update_method'] == 'https') { $post['server_update_port'] = 443; } elseif ($post['server_update_method'] == 'ssh') { $post['server_update_port'] = 22; } } return $post; }
/** * Deletes the selected control */ function delete($id, $server_serial_no = 0) { global $fmdb, $__FM_CONFIG; $tmp_name = getNameFromID($id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'controls', 'control_', 'control_id', 'control_name'); if (updateStatus('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'controls', $id, 'control_', 'deleted', 'control_id') === false) { return __('This control could not be deleted because a database error occurred.'); } else { setBuildUpdateConfigFlag($server_serial_no, 'yes', 'build'); addLogEntry(sprintf(__("Control '%s' was deleted."), $tmp_name)); return true; } }