/** * Returns the top level menu key * * @since 1.2 * @package facileManager * * @return integer|bool Returns the parent menu key or false if the menu item is not found */ function getParentMenuKey($search_slug = null) { global $menu, $submenu; if (!$search_slug) { $search_slug = $GLOBALS['basename']; } foreach ($menu as $position => $menu_items) { $parent_key = array_search($search_slug, $menu_items, true); if ($parent_key !== false) { return $position; } } foreach ($submenu as $parent_slug => $menu_items) { foreach ($menu_items as $element) { if (array_search($search_slug, $element, true) !== false) { return getParentMenuKey($parent_slug); } } } return false; }
| fmFirewall: Easily manage one or more software firewalls | +-------------------------------------------------------------------------+ | http://www.facilemanager.com/modules/fmdns/ | +-------------------------------------------------------------------------+ | Processes zone records page | | Author: Jon LaBass | +-------------------------------------------------------------------------+ */ 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)) {
autoCreatePTR($domain_id, $record_type, $data); $record_count++; } } if (isset($import_records)) { $domain_name = displayFriendlyDomainName(getNameFromID($_POST['domain_id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name')); addLogEntry(sprintf(dngettext($_SESSION['module'], 'Imported %d record from \'%s\' into %s.', 'Imported %d records from \'%s\' into %s.', $record_count), $record_count, $import_file, $domain_name)); } } if (isset($record_type) && $domain_id && !isset($import_records)) { header('Location: zone-records.php?map=' . $map . '&domain_id=' . $domain_id . '&record_type=' . $record_type); } else { if ($domain_id) { header('Location: zone-records.php?map=' . $map . '&domain_id=' . $domain_id); } else { header('Location: ' . $menu[getParentMenuKey(__('SOA'))][4]); } } 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));
break; } if (!empty($_POST['domain_name_servers'])) { include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_servers.php'; /** All servers */ if (in_array(0, $_POST['domain_name_servers'])) { basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', 'server_name', 'server_'); if ($fmdb->num_rows) { $result = $fmdb->last_result; for ($i = 0; $i < $fmdb->num_rows; $i++) { $all_servers[] = $result[$i]->server_id; } $_POST['domain_name_servers'] = $all_servers; } else { global $menu; $response = buildPopup('header', 'Error'); $response .= sprintf(__('<p>You currently have no active name servers defined. <a href="%s">Click here</a> to define one or more to manage.</p>'), $menu[getParentMenuKey(__('Servers'))][4]); break; } } foreach ($_POST['domain_name_servers'] as $server_id) { $response .= '<pre>' . $fm_module_servers->manageCache($server_id, $_POST['task']) . '</pre>'; } } else { $response = buildPopup('header', __('Error')); $response .= sprintf('<p>%s</p>', __('Please specify at least one server.')); } break; } } }
+-------------------------------------------------------------------------+ | Copyright (C) 2013 The facileManager Team | | | | This program is free software; you can redistribute it and/or | | modify it under the terms of the GNU General Public License | | as published by the Free Software Foundation; either version 2 | | of the License, or (at your option) any later version. | | | | This program is distributed in the hope that it will be useful, | | but WITHOUT ANY WARRANTY; without even the implied warranty of | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | +-------------------------------------------------------------------------+ | facileManager: Easy System Administration | +-------------------------------------------------------------------------+ | http://www.facilemanager.com/ | +-------------------------------------------------------------------------+ | Processes main page | | Author: Jon LaBass | +-------------------------------------------------------------------------+ */ /* Redirect to activate modules if none are active */ if ($_SESSION['module'] == $fm_name && currentUserCan('manage_modules')) { header('Location: ' . $menu[getParentMenuKey(_('Modules'))][4]); } setUserModule($_REQUEST['module']); /* Prevent a redirect loop **/ if ($_SESSION['module'] == $fm_name) { unAuth('hide'); } header('Location: ' . $GLOBALS['RELPATH']);