示例#1
0
/**
 * Displays unauthorized message
 *
 * @since 1.0
 * @package facileManager
 */
function returnUnAuth($window = true)
{
    $msg = _('You do not have permission to make these changes.');
    if ($window) {
        echo buildPopup('header', _('Error'));
        echo "<p>{$msg}</p>\n";
        echo buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'));
    } else {
        echo '<p class="error">' . $msg . "</p>\n";
    }
    exit;
}
示例#2
0
    /**
     * Displays the form to add/edit logging types
     */
    function printForm($data = '', $action = 'add', $type = 'channel')
    {
        global $__FM_CONFIG;
        $cfg_id = 0;
        $cfg_name = $cfg_root_dir = $cfg_zones_dir = $cfg_comment = null;
        $server_serial_no = isset($_REQUEST['request_uri']['server_serial_no']) && (intval($_REQUEST['request_uri']['server_serial_no']) > 0 || $_REQUEST['request_uri']['server_serial_no'][0] == 'g') ? sanitize($_REQUEST['request_uri']['server_serial_no']) : 0;
        $cfg_data = null;
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        if ($action == 'add') {
            $popup_title = $type == 'channel' ? __('Add Channel') : __('Add Category');
        } else {
            $popup_title = $type == 'channel' ? __('Edit Channel') : __('Edit Category');
        }
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = <<<FORM
\t\t\t<form name="manage" id="manage" method="post" action="?type={$type}">
\t\t\t{$popup_header}
\t\t\t\t<input type="hidden" name="action" value="{$action}" />
\t\t\t\t<input type="hidden" name="cfg_id" value="{$cfg_id}" />
\t\t\t\t<input type="hidden" name="cfg_type" value="logging" />
\t\t\t\t<input type="hidden" name="sub_type" value="{$type}" />
\t\t\t\t<input type="hidden" name="server_serial_no" value="{$server_serial_no}" />
FORM;
        if ($type == 'channel') {
            $dest = $this->getChannel($cfg_id);
            $cfg_syslog = buildSelect('cfg_syslog', 'cfg_syslog', $__FM_CONFIG['logging']['options']['syslog'], $this->getChannel($cfg_id, 'syslog'));
            $cfg_destination = buildSelect('cfg_destination', 'cfg_destination', $__FM_CONFIG['logging']['options']['destinations'], $dest, 1);
            $cfg_severity = buildSelect('severity', 'severity', $__FM_CONFIG['logging']['options']['severity'], $this->getChannel($cfg_id, 'severity'));
            $cfg_print_category = buildSelect('print-category', 'print-category', $__FM_CONFIG['logging']['options']['print-category'], $this->getChannel($cfg_id, 'print-category'));
            $cfg_print_severity = buildSelect('print-severity', 'print-severity', $__FM_CONFIG['logging']['options']['print-severity'], $this->getChannel($cfg_id, 'print-severity'));
            $cfg_print_time = buildSelect('print-time', 'print-time', $__FM_CONFIG['logging']['options']['print-time'], $this->getChannel($cfg_id, 'print-time'));
            $raw_cfg_file_path = explode(' ', str_replace('"', '', $this->getChannel($cfg_id, 'file')));
            $cfg_file_path = $raw_cfg_file_path[0];
            $cfg_file_versions = @buildSelect('cfg_file_path[]', 'cfg_file_path[]', $__FM_CONFIG['logging']['options']['file_versions'], $raw_cfg_file_path[array_search('versions', $raw_cfg_file_path) + 1]);
            $cfg_file_size = isset($raw_cfg_file_path[array_search('size', $raw_cfg_file_path) + 1]) ? substr($raw_cfg_file_path[array_search('size', $raw_cfg_file_path) + 1], 0, -1) : null;
            $cfg_file_size_spec = @buildSelect('cfg_file_path[]', 'cfg_file_path[]', $__FM_CONFIG['logging']['options']['file_sizes'], substr($raw_cfg_file_path[array_search('size', $raw_cfg_file_path) + 1], -1, 1));
            /** Show/hide divs */
            if ($dest == 'file' || !$dest) {
                $fileshow = 'block';
                $syslogshow = 'none';
            } elseif ($dest == 'syslog') {
                $fileshow = 'none';
                $syslogshow = 'block';
            } else {
                $fileshow = 'none';
                $syslogshow = 'none';
            }
            $return_form .= sprintf('<table class="form-table">
					<tr>
						<th width="33&#37;" scope="row"><label for="cfg_name">%s</label></th>
						<td width="67&#37;"><input name="cfg_name" id="cfg_name" type="text" value="%s" size="40" /></td>
					</tr>
					<tr>
						<th width="33&#37;" scope="row"><label for="cfg_destination">%s</label></th>
						<td width="67&#37;">
							%s
							<div id="destination_option" style="display: %s">
								<input type="text" name="cfg_file_path[]" value="%s" placeholder="/path/to/file" /><br />
								versions %s <input type="number" name="cfg_file_path[]" value="%s" style="width: 5em;" onkeydown="return validateNumber(event)" /> 
								%s
							</div>
							<div id="syslog_options" style="display: %s">%s</div></td>
					</tr>
					</span>
					<tr>
						<th width="33&#37;" scope="row"><label for="cfg_severity">%s</label></th>
						<td width="67&#37;">%s</td>
					</tr>
					<tr>
						<th width="33&#37;" scope="row"><label for="print-category">%s</label></th>
						<td width="67&#37;">%s</td>
					</tr>
					<tr>
						<th width="33&#37;" scope="row"><label for="print-severity">%s</label></th>
						<td width="67&#37;">%s</td>
					</tr>
					<tr>
						<th width="33&#37;" scope="row"><label for="print-time">%s</label></th>
						<td width="67&#37;">%s</td>
					</tr>
					<tr>
						<th width="33&#37;" scope="row"><label for="cfg_comment">%s</label></th>
						<td width="67&#37;"><textarea id="cfg_comment" name="cfg_comment" rows="4" cols="30">%s</textarea></td>
					</tr>
				</table>
				%s
			</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					allowClear: true,
					minimumResultsForSearch: 10
				});
			});
		</script>', __('Channel Name'), $cfg_data, __('Logging Destination'), $cfg_destination, $fileshow, $cfg_file_path, $cfg_file_versions, $cfg_file_size, $cfg_file_size_spec, $syslogshow, $cfg_syslog, __('Severity'), $cfg_severity, __('Print Category (optional)'), $cfg_print_category, __('Print Severity (optional)'), $cfg_print_severity, __('Print Time (optional)'), $cfg_print_time, __('Comment'), $cfg_comment, $popup_footer);
        } elseif ($type == 'category') {
            $cfg_name = buildSelect('cfg_name', 'cfg_name', $this->availableCategories($cfg_data), $cfg_data);
            $cfg_data = buildSelect('cfg_data', 'cfg_data', $this->availableChannels(), $this->getAssocChannels($cfg_id), 4, null, true);
            $return_form .= sprintf('<table class="form-table">
					<tr>
						<th width="33&#37;" scope="row"><label for="cfg_name">%s</label></th>
						<td width="67&#37;">%s</td>
					</tr>
					<tr>
						<th width="33&#37;" scope="row"><label for="cfg_data">%s</label></th>
						<td width="67&#37;">%s</td>
					</tr>
					<tr>
						<th width="33&#37;" scope="row"><label for="cfg_comment">%s</label></th>
						<td width="67&#37;"><textarea id="cfg_comment" name="cfg_comment" rows="4" cols="30">%s</textarea></td>
					</tr>
				</table>
				%s
			</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					allowClear: true,
					width: "235px",
					minimumResultsForSearch: 10
				});
			});
		</script>', __('Category'), $cfg_name, __('Channels'), $cfg_data, __('Comment'), $cfg_comment, $popup_footer);
        } else {
            $return_form = buildPopup('header', _('Error'));
            $return_form .= sprintf('<h3>%s</h3><p>%s</p>', __('Oops!'), __('Invalid request.'));
            $return_form .= buildPopup('footer', _('OK'), array('cancel'));
        }
        return $return_form;
    }
示例#3
0
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | facileManager: Easy System Administration                               |
 +-------------------------------------------------------------------------+
 | http://www.facilemanager.com/                                           |
 +-------------------------------------------------------------------------+
 | Formats results for dialog box                                          |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
if (isset($_POST)) {
    if (!defined('AJAX')) {
        define('AJAX', true);
    }
    require_once '../../../fm-init.php';
    $message_array = $_POST;
}
extract($message_array);
if (!isset($title) || empty($title)) {
    $title = _('Error');
}
echo buildPopup('header', $title);
if (strpos($content, '<p') === false) {
    $content = "<p>{$content}</p>";
}
if (isset($fmdb->last_error)) {
    $content .= $fmdb->last_error;
}
echo $content . buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'));
示例#4
0
    /**
     * Displays the form to add new policy
     */
    function printForm($data = '', $action = 'add', $type = 'rules')
    {
        global $__FM_CONFIG;
        $policy_id = $policy_order_id = 0;
        $policy_interface = $policy_direction = $policy_time = $policy_comment = $policy_options = null;
        $policy_services = $policy_source = $policy_destination = $policy_action = null;
        $source_items = $destination_items = $services_items = null;
        $policy_source_not = $policy_destination_not = $policy_services_not = null;
        $ucaction = ucfirst($action);
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        $server_firewall_type = getNameFromID($_POST['server_serial_no'], 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_serial_no', 'server_type');
        $available_policy_actions = enumMYSQLSelect('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'policies', 'policy_action');
        if ($server_firewall_type == 'ipfilter') {
            array_pop($available_policy_actions);
        }
        $policy_interface = buildSelect('policy_interface', 'policy_interface', $this->availableInterfaces($_REQUEST['server_serial_no']), $policy_interface);
        $policy_direction = buildSelect('policy_direction', 'policy_direction', enumMYSQLSelect('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'policies', 'policy_direction'), $policy_direction, 1);
        $policy_action = buildSelect('policy_action', 'policy_action', $available_policy_actions, $policy_action, 1);
        $source_items_assigned = getGroupItems($policy_source);
        $source_items = buildSelect('source_items', 'source_items', availableGroupItems('object', 'available'), $source_items_assigned, 1, null, true, null, null, __('Select one or more objects'));
        $destination_items_assigned = getGroupItems($policy_destination);
        $destination_items = buildSelect('destination_items', 'destination_items', availableGroupItems('object', 'available'), $destination_items_assigned, 1, null, true, null, null, __('Select one or more objects'));
        $services_items_assigned = getGroupItems($policy_services);
        $services_items = buildSelect('services_items', 'services_items', availableGroupItems('service', 'available'), $services_items_assigned, 1, null, true, null, null, __('Select one or more services'));
        $source_not_check = $policy_source_not ? 'checked' : null;
        $destination_not_check = $policy_destination_not ? 'checked' : null;
        $service_not_check = $policy_services_not ? 'checked' : null;
        $popup_title = $action == 'add' ? __('Add Policy') : __('Edit Policy');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = <<<FORM
\t\t<form name="manage" id="manage" method="post" action="?server_serial_no={$_REQUEST['server_serial_no']}">
\t\t{$popup_header}
\t\t\t<input type="hidden" name="action" value="{$action}" />
\t\t\t<input type="hidden" name="policy_id" value="{$policy_id}" />
\t\t\t<input type="hidden" name="policy_order_id" value="{$policy_order_id}" />
\t\t\t<input type="hidden" name="policy_source_not" value="0" />
\t\t\t<input type="hidden" name="policy_destination_not" value="0" />
\t\t\t<input type="hidden" name="policy_services_not" value="0" />
FORM;
        if ($type == 'rules') {
            $return_form .= sprintf('
			<table class="form-table policy-form">
				<tr>
					<th width="33&#37;" scope="row"><label for="policy_interface">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="policy_direction">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row">%s</th>
					<td width="67&#37;">
						<input name="policy_source_not" id="policy_source_not" value="1" type="checkbox" %s /><label for="policy_source_not"><b>%s</b></label>
						<p class="checkbox_desc">%s</p>
						%s
					</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row">%s</th>
					<td width="67&#37;">
						<input name="policy_destination_not" id="policy_destination_not" value="1" type="checkbox" %s /><label for="policy_destination_not"><b>%s</b></label>
						<p class="checkbox_desc">%s</p>
						%s
					</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row">%s</th>
					<td width="67&#37;">
						<input name="policy_services_not" id="policy_services_not" value="1" type="checkbox" %s /><label for="policy_services_not"><b>%s</b></label>
						<p class="checkbox_desc">%s</p>
						%s
					</td>
				</tr>', __('Interface'), $policy_interface, __('Direction'), $policy_direction, __('Source'), $source_not_check, __('not'), __('Use this option to invert the match'), $source_items, __('Destination'), $destination_not_check, __('not'), __('Use this option to invert the match'), $destination_items, __('Services'), $service_not_check, __('not'), __('Use this option to invert the match'), $services_items);
            if ($server_firewall_type == 'iptables') {
                $policy_time = buildSelect('policy_time', 'policy_time', $this->availableTimes(), $policy_time);
                $return_form .= sprintf('
				<tr>
					<th width="33&#37;" scope="row"><label for="policy_time">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>', __('Time Restriction'), $policy_time);
            }
            /** Parse options */
            $options = null;
            if ($server_firewall_type == 'pf') {
                array_pop($__FM_CONFIG['fw']['policy_options']);
                array_pop($__FM_CONFIG['fw']['policy_options']);
            }
            foreach ($__FM_CONFIG['fw']['policy_options'] as $opt => $opt_array) {
                $checked = $policy_options & $opt_array['bit'] ? 'checked' : null;
                $options .= '<input name="policy_options[]" id="policy_options[' . $opt_array['bit'] . ']" value="' . $opt_array['bit'] . '" type="checkbox" ' . $checked . ' /><label for="policy_options[' . $opt_array['bit'] . ']">' . $opt_array['desc'] . "</label><br />\n";
            }
            $return_form .= sprintf('
				<tr>
					<th width="33&#37;" scope="row"><label for="policy_action">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row">%s</th>
					<td width="67&#37;">
						%s
					</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="policy_comment">%s</label></th>
					<td width="67&#37;"><textarea id="policy_comment" name="policy_comment" rows="4" cols="30">%s</textarea></td>
				</tr>
			</table>', __('Action'), $policy_action, __('Options'), $options, __('Comment'), $policy_comment);
        }
        $return_form .= <<<FORM
\t\t{$popup_footer}
\t\t</form>
\t\t<script>
\t\t\t\$(document).ready(function() {
\t\t\t\t\$("#manage select").select2({
\t\t\t\t\twidth: '200px',
\t\t\t\t\tminimumResultsForSearch: 10
\t\t\t\t});
\t\t\t});
\t\t</script>
FORM;
        return $return_form;
    }
示例#5
0
                $result .= $fm_shared_module_servers->doClientUpgrade($server_results[$i]->server_serial_no);
                $result .= "\n";
            } elseif ($server_results[$i]->server_build_config != 'no') {
                $result .= $fm_shared_module_servers->doBulkServerBuild($server_results[$i]->server_serial_no);
                $result .= "\n";
            }
        }
    }
    /** Module mass updates */
    $include_file = ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $_SESSION['module'] . DIRECTORY_SEPARATOR . 'ajax' . DIRECTORY_SEPARATOR . 'processPost.php';
    if (file_exists($include_file)) {
        include $include_file;
    }
    $result .= "</pre>\n<p class=\"complete\">" . _('All updates have been processed.') . "</p>\n";
    unset($_SESSION['display-rebuild-all']);
    echo buildPopup('header', _('Updates Results')) . $result . buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'));
    /** Handle users */
} elseif (is_array($_POST) && array_key_exists('item_type', $_POST) && $_POST['item_type'] == 'users') {
    if (!currentUserCan('manage_users')) {
        returnUnAuth();
    }
    if (isset($_POST['item_id'])) {
        $id = sanitize($_POST['item_id']);
    } else {
        returnError();
    }
    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));
示例#6
0
    /**
     * Displays the form to add new group
     */
    function printForm($data = '', $action = 'add')
    {
        global $__FM_CONFIG;
        $group_id = 0;
        $group_name = null;
        $ucaction = ucfirst($action);
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($data)) {
                extract($data);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        /** Check name field length */
        $group_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmSQLPass']['prefix'] . 'groups', 'group_name');
        $popup_title = $action == 'add' ? __('Add Group') : __('Edit Group');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="">
		%s
			<input type="hidden" name="action" id="action" value="%s" />
			<input type="hidden" name="group_id" id="group_id" value="%d" />
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="group_name">%s</label></th>
					<td width="67&#37;"><input name="group_name" id="group_name" type="text" value="%s" size="40" placeholder="%s" maxlength="%d" /></td>
				</tr>
			</table>
		%s
		</form>', $popup_header, $action, $group_id, __('Group Name'), $group_name, __('internal'), $group_name_length, $popup_footer);
        return $return_form;
    }
示例#7
0
 function unAuth($message)
 {
     $response = buildPopup('header', _('Error'));
     $response .= sprintf('<p>%s</p>', sprintf(__('You do not have permission to access this %s.'), $message));
     return $response . buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'));
 }
示例#8
0
if (!defined('AJAX')) {
    define('AJAX', true);
}
require_once '../../../fm-init.php';
include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_servers.php';
include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_views.php';
include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_acls.php';
include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_keys.php';
include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_options.php';
include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_zones.php';
include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_logging.php';
include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_controls.php';
include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_templates.php';
if (is_array($_POST) && array_key_exists('action', $_POST) && $_POST['action'] == 'bulk' && array_key_exists('bulk_action', $_POST) && in_array($_POST['bulk_action'], array('reload'))) {
    $popup_footer = buildPopup('footer', __('OK'), array('cancel_button' => 'cancel'), getMenuURL(ucfirst(getNameFromID($_POST['item_id'][0], 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_mapping'))));
    echo buildPopup('header', 'Reload Results') . '<pre>';
    echo processBulkDomainIDs($_POST['item_id']);
    echo "\n" . ucfirst($_POST['bulk_action']) . ' is complete.</pre>' . $popup_footer;
    exit;
    /** Handle mass updates */
} elseif (is_array($_POST) && array_key_exists('action', $_POST) && $_POST['action'] == 'process-all-updates') {
    $result .= processBulkDomainIDs(getZoneReloads('ids'));
    return;
}
$unpriv_message = __('You do not have sufficient privileges.');
$checks_array = array('servers' => 'manage_servers', 'views' => 'manage_servers', 'acls' => 'manage_servers', 'keys' => 'manage_servers', 'options' => 'manage_servers', 'logging' => 'manage_servers', 'controls' => 'manage_servers', 'domains' => 'manage_zones', 'domain' => 'manage_zones', 'soa' => 'manage_zones');
$allowed_capabilities = array_unique($checks_array);
if (is_array($_POST) && count($_POST) && currentUserCan($allowed_capabilities, $_SESSION['module'])) {
    if (!checkUserPostPerms($checks_array, $_POST['item_type'])) {
        echo $unpriv_message;
        exit;
示例#9
0
    /**
     * Displays the form to add new key
     */
    function printForm($data = '', $action = 'add')
    {
        global $__FM_CONFIG, $fm_dns_zones;
        include_once ABSPATH . 'fm-modules/fmDNS/classes/class_zones.php';
        $key_id = 0;
        $key_name = $key_root_dir = $key_zones_dir = $key_comment = null;
        $ucaction = ucfirst($action);
        $key_algorithm = $key_view = $key_secret = null;
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        /** Check name field length */
        $key_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'keys', 'key_name');
        $key_secret_length = getColumnLength('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'keys', 'key_secret');
        $key_algorithm = buildSelect('key_algorithm', 'key_algorithm', enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'keys', 'key_algorithm'), $key_algorithm, 1);
        $key_view = buildSelect('key_view', 'key_view', $fm_dns_zones->availableViews(), $key_view);
        $popup_title = $action == 'add' ? __('Add Key') : __('Edit Key');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="">
		%s
			<input type="hidden" name="action" value="%s" />
			<input type="hidden" name="key_id" value="%d" />
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="key_name">%s</label></th>
					<td width="67&#37;"><input name="key_name" id="key_name" type="text" value="%s" size="40" maxlength="%d" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="key_view">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="key_algorithm">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="key_secret">%s</label></th>
					<td width="67&#37;"><input name="key_secret" id="key_secret" type="text" value="%s" size="40" maxlength="%d" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="key_comment">%s</label></th>
					<td width="67&#37;"><textarea id="key_comment" name="key_comment" rows="4" cols="30">%s</textarea></td>
				</tr>
			</table>
		%s
		</form>
		<script>
			$(document).ready(function() { $("#manage select").select2({minimumResultsForSearch: 10}); });
		</script>', $popup_header, $action, $key_id, __('Key Name'), $key_name, $key_name_length, __('View'), $key_view, __('Algorithm'), $key_algorithm, __('Secret'), $key_secret, $key_secret_length, __('Comment'), $key_comment, $popup_footer);
        return $return_form;
    }
示例#10
0
    /**
     * Displays the form to add new control
     */
    function printForm($data = '', $action = 'add')
    {
        global $__FM_CONFIG, $fm_dns_acls, $fm_module_servers;
        $control_id = 0;
        $control_ip = $control_addresses = $control_comment = null;
        $control_port = $control_keys = null;
        $ucaction = ucfirst($action);
        $server_serial_no = isset($_REQUEST['request_uri']['server_serial_no']) && (is_int($_REQUEST['request_uri']['server_serial_no']) && $_REQUEST['request_uri']['server_serial_no'] > 0 || $_REQUEST['request_uri']['server_serial_no'][0] == 'g') ? sanitize($_REQUEST['request_uri']['server_serial_no']) : 0;
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        $control_addresses = str_replace(';', "\n", rtrim(str_replace(' ', '', $control_addresses), ';'));
        $control_keys = buildSelect('control_keys', 'control_keys', $fm_module_servers->availableItems('key', 'nonempty'), explode(';', $control_keys), 1, null, true, null, null, __('Select one or more keys'));
        $available_acls = $fm_dns_acls->buildACLJSON($control_addresses, $server_serial_no);
        $popup_title = $action == 'add' ? __('Add Control') : __('Edit Control');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="">
		%s
			<input type="hidden" name="action" value="%s" />
			<input type="hidden" name="control_id" value="%d" />
			<input type="hidden" name="server_serial_no" value="%s" />
			<input type="hidden" name="control_keys" value="" />
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="control_ip">%s</label></th>
					<td width="67&#37;"><input name="control_ip" id="control_ip" type="text" value="%s" size="40" placeholder="127.0.0.1" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="control_port">%s</label></th>
					<td width="67&#37;"><input name="control_port" id="control_port" type="text" value="%s" size="40" placeholder="953" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="control_predefined">%s</label></th>
					<td width="67&#37;">
						<input type="hidden" name="control_addresses" id="address_match_element" data-placeholder="%s" value="%s" /><br />
						( address_match_element )
					</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="control_keys">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="control_comment">%s</label></th>
					<td width="67&#37;"><textarea id="control_comment" name="control_comment" rows="4" cols="30">%s</textarea></td>
				</tr>
			</table>
		%s
		</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					width: "200px",
					minimumResultsForSearch: 10,
					allowClear: true
				});
				$("#address_match_element").select2({
					createSearchChoice:function(term, data) { 
						if ($(data).filter(function() { 
							return this.text.localeCompare(term)===0; 
						}).length===0) 
						{return {id:term, text:term};} 
					},
					multiple: true,
					width: "200px",
					tokenSeparators: [",", " ", ";"],
					data: %s
				});
			});
		</script>', $popup_header, $action, $control_id, $server_serial_no, __('IP Address'), $control_ip, __('Port'), $control_port, __('Allowed Address List'), __('Define allowed hosts'), $control_addresses, __('Keys'), $control_keys, __('Comment'), $control_comment, $popup_footer, $available_acls);
        return $return_form;
    }
示例#11
0
    /**
     * Displays the form to add new acl
     */
    function printForm($data = '', $action = 'add')
    {
        global $__FM_CONFIG;
        $acl_id = 0;
        $acl_name = $acl_addresses = $acl_comment = null;
        $acl_predefined = 'as defined:';
        $ucaction = ucfirst($action);
        $server_serial_no = isset($_REQUEST['request_uri']['server_serial_no']) && (is_int($_REQUEST['request_uri']['server_serial_no']) && $_REQUEST['request_uri']['server_serial_no'] > 0 || $_REQUEST['request_uri']['server_serial_no'][0] == 'g') ? sanitize($_REQUEST['request_uri']['server_serial_no']) : 0;
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        $acl_predefined = buildSelect('acl_predefined', 'acl_predefined', enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'acls', 'acl_predefined'), $acl_predefined);
        $acl_addresses = str_replace(',', "\n", rtrim(str_replace(' ', '', $acl_addresses), ';'));
        /** Get field length */
        $acl_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'acls', 'acl_name');
        $popup_title = $action == 'add' ? __('Add ACL') : __('Edit ACL');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="">
		%s
			<input type="hidden" name="action" value="%s" />
			<input type="hidden" name="acl_id" value="%d" />
			<input type="hidden" name="server_serial_no" value="%s" />
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="acl_name">%s</label></th>
					<td width="67&#37;"><input name="acl_name" id="acl_name" type="text" value="%s" size="40" placeholder="%s" maxlength="%d" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="acl_predefined">%s</label></th>
					<td width="67&#37;">%s<br />
					<textarea name="acl_addresses" rows="7" cols="28" placeholder="%s">%s</textarea></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="acl_comment">%s</label></th>
					<td width="67&#37;"><textarea id="acl_comment" name="acl_comment" rows="4" cols="30">%s</textarea></td>
				</tr>
			</table>
		%s
		</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					width: "200px",
					minimumResultsForSearch: 10
				});
			});
		</script>', $popup_header, $action, $acl_id, $server_serial_no, __('ACL Name'), $acl_name, __('internal'), $acl_name_length, __('Matched Address List'), $acl_predefined, __('Addresses and subnets delimited by space, semi-colon, or newline'), $acl_addresses, __('Comment'), $acl_comment, $popup_footer);
        return $return_form;
    }
示例#12
0
    /**
     * Displays the form to add new service
     */
    function printForm($data = '', $action = 'add', $type = 'icmp')
    {
        global $__FM_CONFIG;
        $service_id = 0;
        $service_name = $service_tcp_flags = $service_comment = null;
        $service_icmp_type = $service_icmp_code = null;
        $ucaction = ucfirst($action);
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        /** Show/hide divs */
        if ($type == 'icmp') {
            $icmp_option = 'block';
            $tcpudp_option = $tcp_option = 'none';
        } elseif ($type == 'tcp') {
            $icmp_option = 'none';
            $tcpudp_option = $tcp_option = 'block';
        } else {
            $icmp_option = $tcp_option = 'none';
            $tcpudp_option = 'block';
        }
        $service_name_length = getColumnLength('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'services', 'service_name');
        $service_type = buildSelect('service_type', 'service_type', enumMYSQLSelect('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'services', 'service_type'), $type, 1);
        @(list($port_src_start, $port_src_end) = explode(':', $service_src_ports));
        @(list($port_dest_start, $port_dest_end) = explode(':', $service_dest_ports));
        /** Process TCP Flags */
        @(list($tcp_flag_mask, $tcp_flag_settings) = explode(':', $service_tcp_flags));
        $tcp_flags_mask_form = $tcp_flags_settings_form = $tcp_flags_head = null;
        foreach ($__FM_CONFIG['tcp_flags'] as $flag => $bit) {
            $tcp_flags_head .= '<th title="' . $flag . '">' . $flag[0] . "</th>\n";
            $tcp_flags_mask_form .= '<td><input type="checkbox" name="service_tcp_flags[mask][' . $bit . ']" ';
            if ($bit & $tcp_flag_mask) {
                $tcp_flags_mask_form .= 'checked';
            }
            $tcp_flags_mask_form .= "/></td>\n";
            $tcp_flags_settings_form .= '<td><input type="checkbox" name="service_tcp_flags[settings][' . $bit . ']" ';
            if ($bit & $tcp_flag_settings) {
                $tcp_flags_settings_form .= 'checked';
            }
            $tcp_flags_settings_form .= "/></td>\n";
        }
        $popup_title = $action == 'add' ? __('Add Service') : __('Edit Service');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="?type=%s">
		%s
			<input type="hidden" name="action" value="%s" />
			<input type="hidden" name="service_id" value="%s" />
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="service_name">%s</label></th>
					<td width="67&#37;"><input name="service_name" id="service_name" type="text" value="%s" size="40" placeholder="http" maxlength="%d" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="service_type">%s</label></th>
					<td width="67&#37;">
						%s
						<div id="icmp_option" style="display: %s;">
							<label for="service_icmp_type">Type</label> <input type="number" name="service_icmp_type" value="%s" style="width: 5em;" onkeydown="return validateNumber(event)" placeholder="0" max="40" /><br />
							<label for="service_icmp_code">Code</label> <input type="number" name="service_icmp_code" value="%s" style="width: 5em;" onkeydown="return validateNumber(event)" placeholder="0" max="15" />
						</div>
						<div id="tcpudp_option" style="display: %s;">
							<h4>%s</h4>
							<label for="port_src_start">%s</label> <input type="number" name="port_src[]" value="%s" placeholder="0" style="width: 5em;" onkeydown="return validateNumber(event)" max="65535" /> 
							<label for="port_src_end">%s</label> <input type="number" name="port_src[]" value="%s" placeholder="0" style="width: 5em;" onkeydown="return validateNumber(event)" max="65535" />
							<h4>%s</h4>
							<label for="port_dest_start">%s</label> <input type="number" name="port_dest[]" value="%s" placeholder="0" style="width: 5em;" onkeydown="return validateNumber(event)" max="65535" /> 
							<label for="port_dest_end">%s</label> <input type="number" name="port_dest[]" value="%s" placeholder="0" style="width: 5em;" onkeydown="return validateNumber(event)" max="65535" />
						</div>
						<div id="tcp_option" style="display: %s;">
							<h4>%s</h4>
							<table class="form-table tcp-flags">
								<tbody>
									<tr>
										<th></th>
										%s
									</tr>
									<tr>
										<th style="text-align: right;" title="%s">%s</th>
										%s
									</tr>
									<tr>
										<th style="text-align: right;">%s</th>
										%s
									</tr>
								</tbody>
							</table>
						</div>
					</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="service_comment">%s</label></th>
					<td width="67&#37;"><textarea id="service_comment" name="service_comment" rows="4" cols="30">%s</textarea></td>
				</tr>
			</table>
		%s
		</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					width: "200px",
					minimumResultsForSearch: 10
				});
			});
		</script>', $type, $popup_header, $action, $service_id, __('Service Name'), $service_name, $service_name_length, __('Service Type'), $service_type, $icmp_option, $service_icmp_type, $service_icmp_code, $tcpudp_option, __('Source Port Range'), __('Start'), $port_src_start, __('End'), $port_src_end, __('Destination Port Range'), __('Start'), $port_dest_start, __('End'), $port_dest_end, $tcp_option, __('TCP Flags'), $tcp_flags_head, __('Only iptables uses the Mask bit'), __('Mask'), $tcp_flags_mask_form, __('Settings'), $tcp_flags_settings_form, __('Comment'), $service_comment, $popup_footer);
        return $return_form;
    }
示例#13
0
    /**
     * Displays the form to add new view
     */
    function printForm($data = '', $action = 'add')
    {
        global $__FM_CONFIG;
        $view_id = 0;
        $view_name = $view_root_dir = $view_zones_dir = $view_comment = null;
        $ucaction = ucfirst($action);
        $server_serial_no = isset($_REQUEST['request_uri']['server_serial_no']) && (is_int($_REQUEST['request_uri']['server_serial_no']) && $_REQUEST['request_uri']['server_serial_no'] > 0 || $_REQUEST['request_uri']['server_serial_no'][0] == 'g') ? sanitize($_REQUEST['request_uri']['server_serial_no']) : 0;
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($data)) {
                extract($data);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        /** Get field length */
        $view_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'views', 'view_name');
        $popup_title = $action == 'add' ? __('Add View') : __('Edit View');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="">
		%s
			<input type="hidden" name="page" id="page" value="views" />
			<input type="hidden" name="action" id="action" value="%s" />
			<input type="hidden" name="view_id" id="view_id" value="%d" />
			<input type="hidden" name="server_serial_no" value="%s" />
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="view_name">%s</label></th>
					<td width="67&#37;"><input name="view_name" id="view_name" type="text" value="%s" size="40" placeholder="internal" maxlength="%d" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="view_comment">%s</label></th>
					<td width="67&#37;"><textarea id="view_comment" name="view_comment" rows="4" cols="30">%s</textarea></td>
				</tr>
			</table>
		%s
		</form>', $popup_header, $action, $view_id, $server_serial_no, __('View Name'), $view_name, $view_name_length, __('Comment'), $view_comment, $popup_footer);
        return $return_form;
    }
示例#14
0
    /**
     * Displays the form to add new time
     */
    function printForm($data = '', $action = 'add')
    {
        global $__FM_CONFIG;
        $time_weekdays = $time_id = 0;
        $time_name = $time_comment = null;
        $time_start_date = $time_start_time = $time_end_date = $time_end_time = null;
        $ucaction = ucfirst($action);
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        /* Time options */
        for ($x = 0; $x < 24; $x++) {
            $houropt[$x][] = sprintf("%02d", $x);
            $houropt[$x][] = sprintf("%02d", $x);
        }
        for ($x = 0; $x < 60; $x++) {
            $minopt[$x][] = sprintf("%02d", $x);
            $minopt[$x][] = sprintf("%02d", $x);
        }
        @(list($start_hour, $start_min) = explode(':', $time_start_time));
        @(list($end_hour, $end_min) = explode(':', $time_end_time));
        $time_name_length = getColumnLength('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'time', 'time_name');
        $time_start_hour = BuildSelect('time_start_time_hour', 1, $houropt, $start_hour, 1);
        $time_start_min = BuildSelect('time_start_time_min', 1, $minopt, $start_min, 1);
        $time_end_hour = BuildSelect('time_end_time_hour', 1, $houropt, $end_hour, 1);
        $time_end_min = BuildSelect('time_end_time_min', 1, $minopt, $end_min, 1);
        /** Weekdays */
        $weekdays_form = null;
        foreach ($__FM_CONFIG['weekdays'] as $day => $bit) {
            $weekdays_form .= '<label><input type="checkbox" name="time_weekdays[' . $bit . ']" ';
            if ($bit & $time_weekdays) {
                $weekdays_form .= 'checked';
            }
            $weekdays_form .= '/>' . $day . "</label>\n";
        }
        $popup_title = $action == 'add' ? __('Add Restriction') : __('Edit Restriction');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="">
		%s
			<input type="hidden" name="action" value="%s" />
			<input type="hidden" name="time_id" value="%d" />
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="time_name">%s</label></th>
					<td width="67&#37;"><input name="time_name" id="time_name" type="text" value="%s" size="40" maxlength="%d" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="time_start_date">%s</label></th>
					<td width="67&#37;"><input name="time_start_date" id="time_start_date" type="date" value="%s" size="40" class="datepicker" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="time_start_time">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="time_end_date">%s</label></th>
					<td width="67&#37;"><input name="time_end_date" id="time_end_date" type="date" value="%s" size="40" class="datepicker" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="time_end_time">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row">%s</th>
					<td width="67&#37;" style="white-space: nowrap;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="time_comment">%s</label></th>
					<td width="67&#37;"><textarea id="time_comment" name="time_comment" rows="4" cols="30">%s</textarea></td>
				</tr>
			</table>
		%s
		</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					width: "70px",
					minimumResultsForSearch: 10
				});
			});
		</script>', $popup_header, $action, $time_id, __('Name'), $time_name, $time_name_length, __('Start Date'), $time_start_date, __('Start Time'), "{$time_start_hour} : {$time_start_min}", __('End Date'), $time_end_date, __('End Time'), "{$time_end_hour} : {$time_end_min}", __('Weekdays'), $weekdays_form, __('Comment'), $time_comment, $popup_footer);
        return $return_form;
    }
示例#15
0
                    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;
        }
    }
}
示例#16
0
                $response .= buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'), getMenuURL(_('Modules')));
                echo $response;
                exit;
                break;
            case 'module_upgrade':
                $module_name = isset($_POST['item']) ? sanitize($_POST['item']) : null;
                $response = buildPopup('header', _('Upgrading Module'));
                $response .= $fm_tools->upgradeModule($module_name);
                if ($fmdb->last_error) {
                    $response .= $fmdb->last_error;
                }
                $response .= buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'), getMenuURL(_('Modules')));
                echo $response;
                exit;
                break;
            case 'db-cleanup':
                $response = buildPopup('header', _('Database Clean Up Results'));
                $response .= '<p>' . $fm_tools->cleanupDatabase() . '</p>';
                break;
            case 'purge-logs':
                $response = buildPopup('header', _('Log Purge Results'));
                $response .= '<p>' . $fm_tools->purgeLogs() . '</p>';
                break;
        }
    }
} else {
    echo buildPopup('header', _('Error'));
    printf("<p>%s</p>\n", _('You are not authorized to run this tool.'));
}
echo $response . buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'));
示例#17
0
    function printForm($data = '', $action = 'add', $template_type)
    {
        $popup_title = $action == 'add' ? __('Add Template') : __('Edit Template');
        $popup_header = buildPopup('header', $popup_title);
        $force_action = $action == 'add' ? 'create' : 'update';
        switch ($template_type) {
            case 'soa':
                global $fm_dns_records;
                if (!isset($fm_dns_records)) {
                    include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_records.php';
                }
                $form = '<form method="POST" action="zone-records-validate.php">
					<input type="hidden" name="domain_id" value="0" />
					<input type="hidden" name="record_type" value="SOA" />' . "\n";
                $form .= $popup_header;
                $form .= $fm_dns_records->buildSOA($data, array('template_name'), $force_action);
                break;
            case 'domain':
                global $fm_dns_zones;
                $form = '<form name="manage" id="manage" method="post" action="">' . $popup_header;
                $form .= $fm_dns_zones->printForm($data, $force_action, 'forward', array('template_name'));
                break;
        }
        $form .= buildPopup('footer');
        $form .= '</form>';
        echo $form;
    }
示例#18
0
    /**
     * Displays the form to add new object
     */
    function printForm($data = '', $action = 'add', $type = 'host')
    {
        global $__FM_CONFIG;
        $object_id = 0;
        $object_name = $object_address = $object_comment = null;
        $object_mask = null;
        $ucaction = ucfirst($action);
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        /** Show/hide divs */
        $netmask_option = $type == 'host' ? 'style="display: none;"' : null;
        $object_name_length = getColumnLength('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', 'object_name');
        $object_address_length = getColumnLength('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', 'object_address');
        $object_mask_length = getColumnLength('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', 'object_mask');
        $object_type = buildSelect('object_type', 'object_type', enumMYSQLSelect('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', 'object_type'), $type, 1);
        $popup_title = $action == 'add' ? __('Add Object') : __('Edit Object');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="?type=%s">
		%s
			<input type="hidden" name="action" value="%s" />
			<input type="hidden" name="object_id" value="%s" />
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="object_name">%s</label></th>
					<td width="67&#37;"><input name="object_name" id="object_name" type="text" value="%s" size="40" placeholder="http" maxlength="%s" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="object_type">%s</label></th>
					<td width="67&#37;">
						%s
					</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="object_address">%s</label></th>
					<td width="67&#37;"><input name="object_address" id="object_address" type="text" value="%s" size="40" placeholder="127.0.0.1" maxlength="%s" /></td>
				</tr>
				<tr id="netmask_option" %s>
					<th width="33&#37;" scope="row"><label for="object_mask">%s</label></th>
					<td width="67&#37;"><input name="object_mask" id="object_mask" type="text" value="%s" size="40" placeholder="255.255.255.0" maxlength="%s" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="object_comment">%s</label></th>
					<td width="67&#37;"><textarea id="object_comment" name="object_comment" rows="4" cols="30">%s</textarea></td>
				</tr>
			</table>
		%s
		</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					width: "200px",
					minimumResultsForSearch: 10
				});
			});
		</script>', $type, $popup_header, $action, $object_id, __('Object Name'), $object_name, $object_name_length, __('Object Type'), $object_type, __('Address'), $object_address, $object_address_length, $netmask_option, __('Netmask'), $object_mask, $object_mask_length, __('Comment'), $object_comment, $popup_footer);
        return $return_form;
    }
示例#19
0
 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;
 }
示例#20
0
 /**
  * Process bulk server config build
  *
  * @since 1.2
  * @package facileManager
  */
 function doBulkServerBuild($server_serial_no)
 {
     global $fmdb, $__FM_CONFIG, $fm_module_servers;
     /** Check permissions */
     if (!currentUserCan('build_server_configs', $_SESSION['module'])) {
         echo buildPopup('header', _('Error'));
         printf('<p>%s</p>', _('You do not have permission to build server configs.'));
         echo buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'));
         exit;
     }
     /** Process server group */
     if ($server_serial_no[0] == 'g') {
         $group_servers = $this->getGroupServers(substr($server_serial_no, 1));
         if (!is_array($group_servers)) {
             return $group_servers;
         }
         $response = null;
         foreach ($group_servers as $serial_no) {
             if (is_numeric($serial_no)) {
                 $response .= $this->doClientUpgrade($serial_no) . "\n";
             }
         }
         return $response;
     }
     /** Check serial number */
     basicGet('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', sanitize($server_serial_no), 'server_', 'server_serial_no');
     if (!$fmdb->num_rows) {
         return sprintf(_('%d is not a valid serial number.'), $server_serial_no);
     }
     $server_details = $fmdb->last_result;
     extract(get_object_vars($server_details[0]), EXTR_SKIP);
     $response[] = $server_name;
     if ($server_installed != 'yes') {
         $response[] = ' --> ' . _('Failed: Client is not installed.');
     }
     if (count($response) == 1 && $server_status != 'active') {
         $response[] = ' --> ' . sprintf(_('Failed: Server is %s.'), $server_status);
     }
     if (count($response) == 1) {
         if (!isset($fm_module_servers)) {
             include_once ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_servers.php';
         }
         foreach (makePlainText($fm_module_servers->buildServerConfig($server_serial_no), true) as $line) {
             $response[] = ' --> ' . $line;
         }
     }
     $response[] = null;
     return implode("\n", $response);
 }
示例#21
0
    /**
     * Displays the form to add new server
     */
    function printForm($data = '', $action = 'add')
    {
        global $fmdb, $__FM_CONFIG;
        $server_id = 0;
        $server_name = $server_groups = $server_type = $server_port = null;
        $server_cred_user = $server_cred_password = $server_credentials = null;
        $server_type = 'database';
        $ucaction = ucfirst($action);
        /** Build groups options */
        basicGetList('fm_' . $__FM_CONFIG['fmSQLPass']['prefix'] . 'groups', 'group_name', 'group_');
        $group_options = null;
        $group_count = $fmdb->num_rows;
        $group_results = $fmdb->last_result;
        for ($i = 0; $i < $group_count; $i++) {
            $group_options[$i][] = $group_results[$i]->group_name;
            $group_options[$i][] = $group_results[$i]->group_id;
        }
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($data)) {
                extract($data);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        /** Check name field length */
        $server_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmSQLPass']['prefix'] . 'servers', 'server_name');
        $server_types = buildSelect('server_type', 'server_type', $this->getServerTypes(), $server_type);
        $groups = is_array($group_options) ? buildSelect('server_groups', 1, $group_options, $server_groups, 4, null, true) : __('Server Groups need to be defined first.');
        /** Handle credentials */
        if (isSerialized($server_credentials)) {
            $server_credentials = unserialize($server_credentials);
            list($server_cred_user, $server_cred_password) = $server_credentials;
            unset($server_credentials);
        }
        $popup_title = $action == 'add' ? __('Add Server') : __('Edit Server');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="">
		%s
			<input type="hidden" name="action" id="action" value="%s" />
			<input type="hidden" name="server_type" id="server_type" value="%s" />
			<input type="hidden" name="server_id" id="server_id" value="%d" />
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="server_name">%s</label></th>
					<td width="67&#37;"><input name="server_name" id="server_name" type="text" value="%s" size="40" maxlength="%s" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="server_type">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="server_port">%s</label></th>
					<td width="67&#37;"><input type="number" name="server_port" value="%d" placeholder="3306" onkeydown="return validateNumber(event)" maxlength="5" max="65535" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="server_groups">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="server_cred_user">%s</label></th>
					<td width="67&#37;"><input name="server_credentials[]" id="server_cred_user" type="text" value="%s" size="40" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="server_cred_password">%s</label></th>
					<td width="67&#37;"><input name="server_credentials[]" id="server_cred_password" type="password" value="%s" size="40" /></td>
				</tr>
			</table>
		%s
		</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					width: "200px",
					minimumResultsForSearch: 10
				});
			});
		</script>', $popup_header, $action, $server_type, $server_id, __('Hostname'), $server_name, $server_name_length, __('Server Type'), $server_types, __('Server Port'), $server_port, __('Groups'), $groups, __('Username'), $server_cred_user, __('Password'), $server_cred_password, $popup_footer);
        return $return_form;
    }
示例#22
0
 | 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                               |
 | fmDNS: Easily manage one or more ISC BIND servers                       |
 +-------------------------------------------------------------------------+
 | http://www.facilemanager.com/modules/fmdns/                             |
 +-------------------------------------------------------------------------+
 | Processes zone reloads                                                  |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
if (is_array($_POST) && count($_POST)) {
    include ABSPATH . 'fm-modules/fmDNS/classes/class_zones.php';
    /** Clean variable */
    $domain_id = intval($_POST['domain_id']);
    /** Ensure user is allowed to reload zone */
    $zone_access_allowed = zoneAccessIsAllowed(array($domain_id), 'reload');
    if ($domain_id && $zone_access_allowed) {
        echo buildPopup('header', __('Zone Reload Results'));
        if (isset($_POST['domain_id']) && !empty($_POST['domain_id'])) {
            $response = $fm_dns_zones->buildZoneConfig($_POST['domain_id']);
        }
        echo $response . "<br />\n";
    } else {
        echo buildPopup('header', __('Error'));
        printf('<p>%s</p>' . "\n", __('You are not authorized to reload this zone.'));
    }
}
示例#23
0
    /**
     * Displays the form to add new zone
     */
    function printForm($data = '', $action = 'create', $map = 'forward', $show = array('popup', 'template_menu', 'create_template'))
    {
        global $fmdb, $__FM_CONFIG, $fm_dns_acls, $fm_module_options;
        $domain_id = $domain_view = $domain_name_servers = 0;
        $domain_type = $domain_clone_domain_id = $domain_name = $template_name = null;
        $disabled = $action == 'create' ? null : 'disabled';
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                $domain_id = $_POST[$action . 'Zone']['ZoneID'];
                extract($_POST[$action . 'Zone'][$domain_id]);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        } elseif (!empty($_POST) && array_key_exists('is_ajax', $_POST)) {
            extract($_POST);
            $domain_clone_dname = null;
            $domain_template_id = getNameFromID($domain_clone_domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id');
            if ($domain_template_id) {
                $domain_name_servers = getNameFromID($domain_template_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name_servers');
            } else {
                $domain_name_servers = getNameFromID($domain_clone_domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name_servers');
            }
        }
        $domain_name = function_exists('idn_to_utf8') ? idn_to_utf8($domain_name) : $domain_name;
        /** Process multiple views */
        if (strpos($domain_view, ';')) {
            $domain_view = explode(';', rtrim($domain_view, ';'));
            if (in_array('0', $domain_view)) {
                $domain_view = 0;
            }
        }
        /** Process multiple domain name servers */
        if (strpos($domain_name_servers, ';')) {
            $domain_name_servers = explode(';', rtrim($domain_name_servers, ';'));
            if (in_array('0', $domain_name_servers)) {
                $domain_name_servers = 0;
            }
        }
        /** Get field length */
        $domain_name_length = getColumnLength('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_name');
        $views = buildSelect('domain_view', 'domain_view', $this->availableViews(), $domain_view, 4, null, true);
        $zone_maps = buildSelect('domain_mapping', 'domain_mapping', enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_mapping'), $map, 1, $disabled);
        $domain_types = buildSelect('domain_type', 'domain_type', enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_type'), $domain_type, 1, $disabled);
        $clone = buildSelect('domain_clone_domain_id', 'domain_clone_domain_id', $this->availableCloneDomains($map, $domain_id), $domain_clone_domain_id, 1, $disabled);
        $name_servers = buildSelect('domain_name_servers', 'domain_name_servers', availableDNSServers('id'), $domain_name_servers, 1, null, true);
        $forwarders_show = $masters_show = 'none';
        $domain_forward_servers = $domain_master_servers = $domain_forward = null;
        $available_acls = json_encode(array());
        if ($domain_type == 'forward') {
            $forwarders_show = 'block';
            $domain_forward_servers = str_replace(';', "\n", rtrim(str_replace(' ', '', getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_', 'domain_id', 'cfg_data', null, "AND cfg_name='forwarders'")), ';'));
            $domain_forward = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_', 'domain_id', 'cfg_data', null, "AND cfg_name='forward'");
            $available_acls = $fm_dns_acls->buildACLJSON($domain_forward_servers, 0, 'none');
        } elseif (in_array($domain_type, array('slave', 'stub'))) {
            $masters_show = 'block';
            $domain_master_servers = str_replace(';', "\n", rtrim(str_replace(' ', '', getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_', 'domain_id', 'cfg_data', null, "AND cfg_name='masters'")), ';'));
            $available_acls = $fm_dns_acls->buildACLJSON($domain_master_servers, 0, 'none');
        }
        /** Build forward options */
        $query = "SELECT def_type,def_dropdown FROM fm_{$__FM_CONFIG[$_SESSION['module']]['prefix']}functions WHERE def_option = 'forward'";
        $fmdb->get_results($query);
        if ($fmdb->num_rows) {
            $forward_dropdown = $fm_module_options->populateDefTypeDropdown($fmdb->last_result[0]->def_type, $domain_forward, 'domain_forward');
        }
        if ($action == 'create') {
            $domain_template_id = $this->getDefaultZone();
            $zone_show = $domain_template_id ? 'none' : 'block';
            global $fm_dns_records;
            if (!isset($fm_dns_records)) {
                include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_records.php';
            }
            $soa_templates = '<tr id="define_soa">
					<th>SOA</th>
					<td>' . buildSelect('soa_id', 'soa_id', $fm_dns_records->availableSOATemplates($map), $fm_dns_records->getDefaultSOA()) . '</td></tr>';
        } else {
            $zone_show = 'block';
            $soa_templates = $domain_templates = null;
        }
        /** Clone options */
        if ($domain_clone_domain_id) {
            $clone_override_show = 'block';
            $clone_dname_checked = $domain_clone_dname ? 'checked' : null;
            $clone_dname_options_show = $domain_clone_dname ? 'block' : 'none';
            if (isset($no_template)) {
                $domain_template_id = 0;
                $zone_show = 'block';
            }
        } else {
            $clone_override_show = $clone_dname_options_show = 'none';
            $clone_dname_checked = null;
        }
        $clone_dname_dropdown = buildSelect('domain_clone_dname', 'domain_clone_dname', enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_clone_dname'), $domain_clone_dname);
        $additional_config_link = $action == 'create' || !in_array($domain_type, array('master', 'slave')) || !currentUserCan('manage_servers', $_SESSION['module']) ? null : sprintf('<tr class="include-with-template"><td></td><td><p><a href="config-options.php?domain_id=%d">%s</a></p></td></tr>', $domain_id, __('Configure Additional Options'));
        $popup_title = $action == 'create' ? __('Add Zone') : __('Edit Zone');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        if (array_search('create_template', $show) !== false) {
            $template_name_show_hide = 'none';
            $create_template = sprintf('<tr id="create_template">
			<th>%s</th>
			<td><input type="checkbox" id="domain_create_template" name="domain_template" value="yes" /><label for="domain_create_template"> %s</label></td>
		</tr>', __('Create Template'), __('yes'));
        } else {
            $template_name_show_hide = 'table-row';
            $create_template = <<<HTML
\t\t\t<input type="hidden" id="domain_create_template" name="domain_template" value="no" />
\t\t\t<input type="hidden" name="domain_default" value="no" />
HTML;
        }
        if (array_search('template_menu', $show) !== false) {
            $classes = 'zone-form';
            $select_template = '<tr id="define_template" class="include-with-template">
					<th>' . __('Template') . '</th>
					<td>' . buildSelect('domain_template_id', 'domain_template_id', $this->availableZoneTemplates(), $domain_template_id);
            if ($action == 'edit') {
                $select_template .= sprintf('<p>%s</p>', __('Changing the template will delete all config options for this zone.'));
            }
            $select_template .= '</td></tr>';
        } else {
            $classes = 'zone-template-form';
            $select_template = null;
        }
        if (array_search('template_name', $show) !== false) {
            $default_checked = $domain_id == $this->getDefaultZone() ? 'checked' : null;
            $template_name = sprintf('<tr id="domain_template_default" style="display: %s">
			<th></th>
			<td><input type="checkbox" id="domain_default" name="domain_default" value="yes" %s /><label for="domain_default"> %s</label></td>
			<input type="hidden" id="domain_create_template" name="domain_template" value="yes" />
		</tr>', $template_name_show_hide, $default_checked, __('Make Default Template'));
        }
        $return_form = array_search('popup', $show) !== false ? '<form name="manage" id="manage" method="post" action="">' . $popup_header : null;
        $return_form .= sprintf('<input type="hidden" name="action" value="%s" />
			<input type="hidden" name="domain_id" value="%d" />
			<table class="form-table %s">
				<tr class="include-with-template">
					<th><label for="domain_name">%s</label></th>
					<td><input type="text" id="domain_name" name="domain_name" size="40" value="%s" maxlength="%d" /></td>
				</tr>
				%s
				<tr>
					<th><label for="domain_view">%s</label></th>
					<td>%s</td>
				</tr>
				<tr>
					<th><label for="domain_mapping">%s</label></th>
					<td>%s</td>
				</tr>
				<tr>
					<th><label for="domain_type">%s</label></th>
					<td>
						%s
						<div id="define_forwarders" style="display: %s">
							<p>%s</p>
							<input type="hidden" name="domain_required_servers[forwarders]" id="domain_required_servers" class="address_match_element" data-placeholder="%s" value="%s" /><br />
							( address_match_element )
						</div>
						<div id="define_masters" style="display: %s">
							<input type="hidden" name="domain_required_servers[masters]" id="domain_required_servers" class="address_match_element" data-placeholder="%s" value="%s" /><br />
							( address_match_element )
						</div>
					</td>
				</tr>
				<tr>
					<th><label for="domain_clone_domain_id">%s</label></th>
					<td>
						%s
						<div id="clone_override" style="display: %s">
							<p><input type="checkbox" id="domain_clone_dname_override" name="domain_clone_dname_override" value="yes" %s /><label for="domain_clone_dname_override"> %s</label></p>
							<div id="clone_dname_options" style="display: %s">
								%s
							</div>
						</div>
					</td>
				</tr>
				<tr>
					<th><label for="domain_name_servers">%s</label></th>
					<td>%s</td>
				</tr>
				%s
			</table>', $action, $domain_id, $classes, __('Domain Name'), $domain_name, $domain_name_length, $select_template, __('Views'), $views, __('Zone Map'), $zone_maps, __('Zone Type'), $domain_types, $forwarders_show, $forward_dropdown, __('Define forwarders'), $domain_forward_servers, $masters_show, __('Define masters'), $domain_master_servers, __('Clone Of (optional)'), $clone, $clone_override_show, $clone_dname_checked, __('Override DNAME Resource Record Setting'), $clone_dname_options_show, $clone_dname_dropdown, __('DNS Servers'), $name_servers, $soa_templates . $additional_config_link . $create_template . $template_name);
        $return_form .= array_search('popup', $show) !== false ? $popup_footer . '</form>' : null;
        $return_form .= <<<HTML
\t\t<script>
\t\t\t\$(document).ready(function() {
\t\t\t\t\$("#manage select").select2({
\t\t\t\t\twidth: '100%',
\t\t\t\t\tminimumResultsForSearch: 10,
\t\t\t\t\tallowClear: true
\t\t\t\t});
\t\t\t\t\$(".address_match_element").select2({
\t\t\t\t\tcreateSearchChoice:function(term, data) { 
\t\t\t\t\t\tif (\$(data).filter(function() { 
\t\t\t\t\t\t\treturn this.text.localeCompare(term)===0; 
\t\t\t\t\t\t}).length===0) 
\t\t\t\t\t\t{return {id:term, text:term};} 
\t\t\t\t\t},
\t\t\t\t\tmultiple: true,
\t\t\t\t\twidth: '300px',
\t\t\t\t\ttokenSeparators: [",", " ", ";"],
\t\t\t\t\tdata: {$available_acls}
\t\t\t\t});
\t\t\t\t\$("#domain_clone_dname_override").click(function() {
\t\t\t\t\tif (\$(this).is(':checked')) {
\t\t\t\t\t\t\$('#clone_dname_options').show('slow');
\t\t\t\t\t} else {
\t\t\t\t\t\t\$('#clone_dname_options').slideUp();
\t\t\t\t\t}
\t\t\t\t});
\t\t\t\t\$("#domain_create_template").click(function() {
\t\t\t\t\tif (\$(this).is(':checked')) {
\t\t\t\t\t\t\$('#domain_template_name').show('slow');
\t\t\t\t\t} else {
\t\t\t\t\t\t\$('#domain_template_name').slideUp();
\t\t\t\t\t}
\t\t\t\t});
\t\t\t\tif (\$('#domain_template_id').val() != '') {
\t\t\t\t\t\$('.zone-form > tbody > tr:not(.include-with-template, #domain_template_default)').slideUp();
\t\t\t\t} else {
\t\t\t\t\t\$('.zone-form > tbody > tr:not(.include-with-template, #domain_template_default)').show('slow');
\t\t\t\t}
\t\t\t\tif (\$('#domain_clone_domain_id').val() != '') {
\t\t\t\t\t\$('.zone-form > tbody > tr#define_soa').slideUp();
\t\t\t\t\t\$('.zone-form > tbody > tr#create_template').slideUp();
\t\t\t\t} else {
\t\t\t\t\tif(\$('#domain_template_id').val() == '') {
\t\t\t\t\t\t\$('.zone-form > tbody > tr#define_soa').show('slow');
\t\t\t\t\t\t\$('.zone-form > tbody > tr#create_template').show('slow');
\t\t\t\t\t}
\t\t\t\t}
\t\t\t});
\t\t</script>
HTML;
        return $return_form;
    }
示例#24
0
    /**
     * Displays the form to add new option
     */
    function printForm($data = '', $action = 'add', $cfg_type = 'global', $cfg_type_id = null)
    {
        global $fmdb, $__FM_CONFIG, $fm_dns_zones;
        $cfg_id = $domain_id = 0;
        if (!$cfg_type_id) {
            $cfg_type_id = 0;
        }
        $cfg_name = $cfg_root_dir = $cfg_zones_dir = $cfg_comment = null;
        $ucaction = ucfirst($action);
        $server_serial_no_field = $cfg_isparent = $cfg_parent = $cfg_data = null;
        switch (strtolower($cfg_type)) {
            case 'global':
            case 'ratelimit':
                if (isset($_POST['item_sub_type'])) {
                    $cfg_id_name = sanitize($_POST['item_sub_type']);
                } else {
                    $cfg_id_name = isset($_POST['view_id']) ? 'view_id' : 'domain_id';
                }
                $data_holder = null;
                $server_serial_no = isset($_REQUEST['request_uri']['server_serial_no']) && (intval($_REQUEST['request_uri']['server_serial_no']) > 0 || $_REQUEST['request_uri']['server_serial_no'][0] == 'g') ? sanitize($_REQUEST['request_uri']['server_serial_no']) : 0;
                $server_serial_no_field = '<input type="hidden" name="server_serial_no" value="' . $server_serial_no . '" />';
                $request_uri = 'config-options.php';
                if (isset($_REQUEST['request_uri'])) {
                    $request_uri .= '?';
                    foreach ($_REQUEST['request_uri'] as $key => $val) {
                        $request_uri .= $key . '=' . sanitize($val) . '&';
                    }
                    $request_uri = rtrim($request_uri, '&');
                }
                $disabled = $action == 'add' ? null : 'disabled';
                break;
            case 'logging':
                $name_holder = 'severity';
                $name_note = null;
                $data_holder = 'dynamic';
                $data_note = null;
                break;
            case 'keys':
                $name_holder = 'key';
                $name_note = null;
                $data_holder = 'rndc-key';
                $data_note = null;
                break;
        }
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        $cfg_isparent = buildSelect('cfg_isparent', 'cfg_isparent', enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_isparent'), $cfg_isparent, 1);
        $cfg_parent = buildSelect('cfg_parent', 'cfg_parent', $this->availableParents($cfg_id, $cfg_type), $cfg_parent);
        $avail_options_array = $this->availableOptions($action, $server_serial_no, $cfg_type, $cfg_name);
        $cfg_avail_options = buildSelect('cfg_name', 'cfg_name', $avail_options_array, $cfg_name, 1, $disabled, false, 'displayOptionPlaceholder()');
        $query = "SELECT def_type FROM fm_{$__FM_CONFIG['fmDNS']['prefix']}functions WHERE def_function='{$cfg_type}' AND \n\t\t\t\tdef_option=";
        if ($action != 'add') {
            $query .= "'{$cfg_name}'";
        } else {
            $query .= "'{$avail_options_array[0]}'";
        }
        $fmdb->get_results($query);
        if ($fmdb->num_rows) {
            $results = $fmdb->last_result;
            $data_holder = $results[0]->def_type;
        }
        $cfg_data = sanitize($cfg_data);
        $popup_title = $action == 'add' ? __('Add Option') : __('Edit Option');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $addl_options = null;
        if ($cfg_type == 'ratelimit') {
            $available_zones = $fm_dns_zones->buildZoneJSON($cfg_data);
            $addl_options = sprintf('<tr>
					<th width="33&#37;" scope="row"><label for="cfg_name">%s</label></th>
					<td width="67&#37;"><input type="hidden" name="domain_id" class="domain_name" value="%d" /><br />
					<script>
					$(".domain_name").select2({
						createSearchChoice:function(term, data) { 
							if ($(data).filter(function() { 
								return this.text.localeCompare(term)===0; 
							}).length===0) 
							{return {id:term, text:term};} 
						},
						multiple: false,
						width: "200px",
						tokenSeparators: [",", " ", ";"],
						data: %s
					});
					$(".domain_name").change(function(){
						var $swap = $(this).parent().parent().next().find("td");
						var form_data = {
							server_serial_no: getUrlVars()["server_serial_no"],
							cfg_type: getUrlVars()["option_type"],
							cfg_name: $(this).parent().parent().next().find("td").find("select").val(),
							get_available_options: true,
							item_sub_type: "domain_id",
							item_id: $(this).val(),
							view_id: getUrlVars()["view_id"],
							is_ajax: 1
						};

						$.ajax({
							type: "POST",
							url: "fm-modules/fmDNS/ajax/getData.php",
							data: form_data,
							success: function(response) {
								$swap.html(response);
								
								$("#manage select").select2({
									width: "200px",
									minimumResultsForSearch: 10
								});
							}
						});
					});
					</script>
				</tr>', __('Domain'), $domain_id, $available_zones);
        }
        $return_form = sprintf('<script>
			displayOptionPlaceholder("%s");
		</script>
		<form name="manage" id="manage" method="post" action="%s">
		%s
			<input type="hidden" name="action" value="%s" />
			<input type="hidden" name="cfg_id" value="%d" />
			<input type="hidden" name="cfg_type" value="%s" />
			<input type="hidden" name="%s" value="%s" />
			%s
			<table class="form-table">
				%s
				<tr>
					<th width="33&#37;" scope="row"><label for="cfg_name">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr class="value_placeholder">
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="cfg_comment">%s</label></th>
					<td width="67&#37;"><textarea id="cfg_comment" name="cfg_comment" rows="4" cols="30">%s</textarea></td>
				</tr>
			</table>
		%s
		</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					width: "200px",
					minimumResultsForSearch: 10
				});
			});
		</script>', $cfg_data, $request_uri, $popup_header, $action, $cfg_id, $cfg_type, $cfg_id_name, $cfg_type_id, $server_serial_no_field, $addl_options, __('Option Name'), $cfg_avail_options, __('Comment'), $cfg_comment, $popup_footer);
        return $return_form;
    }
示例#25
0
    /**
     * Displays the form to add new user
     *
     * @since 1.0
     * @package facileManager
     */
    function printUsersForm($data = '', $action = 'add', $form_bits = array(), $button_text = 'Save', $button_id = 'submit', $action_page = 'admin-users.php', $print_form_head = true, $display_type = 'popup')
    {
        global $__FM_CONFIG, $fm_name, $fm_login;
        $user_id = 0;
        $user_login = $user_password = $cpassword = null;
        $ucaction = ucfirst($action);
        $disabled = isset($_GET['id']) && $_SESSION['user']['id'] == $_GET['id'] ? 'disabled' : null;
        $button_disabled = null;
        $user_email = $user_default_module = null;
        $hidden = $user_perm_form = $return_form_rows = null;
        $user_force_pwd_change = $user_template_only = null;
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
            $user_password = null;
        }
        $popup_title = $action == 'add' ? __('Add User') : __('Edit User');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        if (in_array('user_login', $form_bits)) {
            /** Get field length */
            $field_length = getColumnLength('fm_users', 'user_login');
            $username_form = $action == 'add' ? '<input name="user_login" id="user_login" type="text" value="' . $user_login . '" size="40" maxlength="' . $field_length . '" />' : '<span id="form_username">' . $user_login . '</span>';
            $hidden = '<input type="hidden" name="user_id" value="' . $user_id . '" />';
            $hidden .= $action != 'add' ? '<input type="hidden" name="user_login" value="' . $user_login . '" />' : null;
            $return_form_rows .= '<tr>
					<th width="33%" scope="row"><label for="user_login">' . _('User Login') . '</label></th>
					<td width="67%">' . $username_form . '</td>
				</tr>';
        }
        if (in_array('user_email', $form_bits)) {
            /** Get field length */
            $field_length = getColumnLength('fm_users', 'user_login');
            $return_form_rows .= '<tr>
					<th width="33%" scope="row"><label for="user_email">' . _('User Email') . '</label></th>
					<td width="67%"><input name="user_email" id="user_email" type="email" value="' . $user_email . '" size="32" maxlength="' . $field_length . '" ' . $disabled . ' /></td>
				</tr>';
        }
        if (in_array('user_auth_method', $form_bits) && getOption('auth_method')) {
            if (!isset($user_auth_type)) {
                $user_auth_type = 1;
            }
            $auth_method_types = $__FM_CONFIG['options']['auth_method'];
            if (array_shift($auth_method_types) && count($auth_method_types) > 1) {
                $return_form_rows .= '<tr>
					<th width="33%" scope="row"><label for="user_email">' . _('Authentication Method') . '</label></th>
					<td width="67%">' . buildSelect('user_auth_type', 'user_auth_type', $auth_method_types, $user_auth_type) . '</td>
				</tr>';
            }
        }
        if (in_array('user_password', $form_bits) || array_key_exists('user_password', $form_bits)) {
            if ($action == 'add') {
                $button_disabled = 'disabled';
            }
            $strength = $GLOBALS['PWD_STRENGTH'];
            if (array_key_exists('user_password', $form_bits)) {
                $strength = $form_bits['user_password'];
            }
            $return_form_rows .= '<tr class="user_password">
					<th width="33%" scope="row"><label for="user_password">' . _('User Password') . '</label></th>
					<td width="67%"><input name="user_password" id="user_password" type="password" value="" size="40" onkeyup="javascript:checkPasswd(\'user_password\', \'' . $button_id . '\', \'' . $strength . '\');" /></td>
				</tr>
				<tr class="user_password">
					<th width="33%" scope="row"><label for="cpassword">' . _('Confirm Password') . '</label></th>
					<td width="67%"><input name="cpassword" id="cpassword" type="password" value="" size="40" onkeyup="javascript:checkPasswd(\'cpassword\', \'' . $button_id . '\', \'' . $strength . '\');" /></td>
				</tr>
				<tr class="user_password">
					<th width="33%" scope="row">' . _('Password Validity') . '</th>
					<td width="67%"><div id="passwd_check">' . _('No Password') . '</div></td>
				</tr>
				<tr class="pwdhint user_password">
					<th width="33%" scope="row">' . _('Hint') . '</th>
					<td width="67%">' . $__FM_CONFIG['password_hint'][$strength][1] . '</td>
				</tr>';
        }
        if (in_array('user_module', $form_bits)) {
            $active_modules = $user_id == $_SESSION['user']['id'] ? getActiveModules(true) : getActiveModules();
            $user_module_options = buildSelect('user_default_module', 'user_default_module', $active_modules, $user_default_module);
            unset($active_modules);
            $return_form_rows .= '<tr>
					<th width="33%" scope="row">' . _('Default Module') . '</th>
					<td width="67%">' . $user_module_options . '</td>
				</tr>';
        }
        if (in_array('user_options', $form_bits)) {
            $force_pwd_check = $user_force_pwd_change == 'yes' ? 'checked disabled' : null;
            $user_template_only_check = $user_template_only == 'yes' ? 'checked' : null;
            $return_form_rows .= '<tr>
					<th width="33%" scope="row">' . _('Options') . '</th>
					<td width="67%">
						<input name="user_force_pwd_change" id="user_force_pwd_change" value="yes" type="checkbox" ' . $force_pwd_check . '/><label for="user_force_pwd_change">' . _('Force Password Change at Next Login') . '</label><br />
						<input name="user_template_only" id="user_template_only" value="yes" type="checkbox" ' . $user_template_only_check . '/><label for="user_template_only">' . _('Template User') . '</label>
					</td>
				</tr>';
        }
        if (in_array('verbose', $form_bits)) {
            $hidden .= '<input type="hidden" name="verbose" value="0" />' . "\n";
            $return_form_rows .= '<tr>
					<th width="33%" scope="row">' . _('Options') . '</th>
					<td width="67%"><input name="verbose" id="verbose" type="checkbox" value="1" checked /><label for="verbose">' . _('Verbose Output') . '</label></td>
				</tr>';
        }
        do {
            if (in_array('user_perms', $form_bits)) {
                /** Cannot edit perms of super-admin if logged in user is not a super-admin */
                if (userCan($user_id, 'do_everything') && !currentUserCan('do_everything')) {
                    break;
                }
                $user_is_super_admin = userCan($user_id, 'do_everything');
                $fm_perm_boxes = $perm_boxes = null;
                $i = 1;
                $fm_user_caps = getAvailableUserCapabilities();
                foreach ($fm_user_caps[$fm_name] as $key => $title) {
                    if ($key != 'do_everything' && $user_is_super_admin) {
                        $checked = null;
                    } else {
                        $checked = userCan($user_id, $key) ? 'checked' : null;
                    }
                    if ($key == 'do_everything') {
                        $title = "<b>{$title}</b>";
                    }
                    $fm_perm_boxes .= ' <input name="user_caps[' . $fm_name . '][' . $key . ']" id="fm_perm_' . $key . '" type="checkbox" value="1" ' . $checked . '/> <label for="fm_perm_' . $key . '">' . $title . '</label>' . "\n";
                    /** Display checkboxes three per row */
                    if ($i == 3) {
                        $fm_perm_boxes .= "<br />\n";
                        $i = 0;
                    }
                    $i++;
                }
                if (!empty($fm_perm_boxes)) {
                    $perm_boxes .= <<<PERM
\t\t\t\t<tr id="userperms">
\t\t\t\t\t<th width="33%" scope="row">{$fm_name}</th>
\t\t\t\t\t<td width="67%">
\t\t\t\t\t\t<input type="hidden" name="process_user_caps" value="1" />
\t\t\t\t\t\t{$fm_perm_boxes}
\t\t\t\t\t</td>
\t\t\t\t</tr>

PERM;
                }
                /** Process module permissions */
                $active_modules = getActiveModules();
                foreach ($active_modules as $module_name) {
                    $module_perm_boxes = null;
                    $i = 1;
                    if (array_key_exists($module_name, $fm_user_caps)) {
                        foreach ($fm_user_caps[$module_name] as $key => $title) {
                            $checked = userCan($user_id, $key, $module_name) && !$user_is_super_admin ? 'checked' : null;
                            $module_perm_boxes .= ' <input name="user_caps[' . $module_name . '][' . $key . ']" id="fm_perm_' . $module_name . '_' . $key . '" type="checkbox" value="1" ' . $checked . '/> <label for="fm_perm_' . $module_name . '_' . $key . '">' . $title . '</label>' . "\n";
                            /** Display checkboxes three per row */
                            if ($i == 3) {
                                $module_perm_boxes .= "<br />\n";
                                $i = 0;
                            }
                            $i++;
                        }
                        $module_extra_functions = ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $module_name . DIRECTORY_SEPARATOR . 'functions.extra.php';
                        if (file_exists($module_extra_functions)) {
                            include $module_extra_functions;
                            $function = 'print' . $module_name . 'UsersForm';
                            if (function_exists($function)) {
                                $module_perm_boxes .= $function(getUserCapabilities($user_id), $module_name);
                            }
                        }
                    }
                    if (!empty($module_perm_boxes)) {
                        $perm_boxes .= <<<PERM
\t\t\t\t\t<tr id="userperms">
\t\t\t\t\t\t<th width="33%" scope="row">{$module_name}</th>
\t\t\t\t\t\t<td width="67%">
\t\t\t\t\t\t{$module_perm_boxes}
\t\t\t\t\t\t</td>
\t\t\t\t\t</tr>
\t
PERM;
                    }
                }
                if (!empty($perm_boxes)) {
                    $user_perm_form = sprintf('<tr><td colspan="2"><br /><br /><i>%s</i></td></tr>', _('User Permissions')) . $perm_boxes;
                }
            }
        } while (false);
        $return_form = $print_form_head ? '<form name="manage" id="manage" method="post" action="' . $action_page . '">' . "\n" : null;
        if ($display_type == 'popup') {
            $return_form .= $popup_header;
        }
        $return_form .= '
			<div>
			<form id="fm_user_profile">
			<input type="hidden" name="action" value="' . $action . '" />' . $hidden . '
			<table class="form-table" width="495px">
				<tr><td colspan="2"><i>' . _('User Details') . '</i></td></tr>' . $return_form_rows . $user_perm_form;
        $return_form .= '</table></div>';
        if ($display_type == 'popup') {
            $return_form .= '
		</div>
		<div class="popup-footer">
			<input type="submit" id="' . $button_id . '" name="submit" value="' . $button_text . '" class="button primary" ' . $button_disabled . '/>
			<input type="button" value="' . _('Cancel') . '" class="button left" id="cancel_button" />
		</div>
		</form>
		<script>
			$(document).ready(function() {
				$("select").select2({
					containerCss: { "min-width": "165px" },
					minimumResultsForSearch: -1
				});
				$("select.wide_select").select2({
					width: "300px",
					minimumResultsForSearch: -1
				});
			});
		</script>';
        }
        return $return_form;
    }
示例#26
0
    /**
     * Displays the form to add new server
     */
    function printForm($data = '', $action = 'add')
    {
        global $__FM_CONFIG;
        $server_id = 0;
        $server_name = $runas = $server_type = $server_update_port = null;
        $server_update_method = $server_config_file = $server_os = null;
        $ucaction = ucfirst($action);
        $server_installed = false;
        if (!empty($_POST) && !array_key_exists('is_ajax', $_POST)) {
            if (is_array($_POST)) {
                extract($_POST);
            }
        } elseif (@is_object($data[0])) {
            extract(get_object_vars($data[0]));
        }
        /** Show/hide divs */
        if (isset($server_run_as_predefined) && $server_run_as_predefined == 'as defined:') {
            $runashow = 'block';
        } else {
            $runashow = 'none';
            $server_run_as = null;
        }
        $server_update_port_style = $server_update_method == 'cron' ? 'style="display: none;"' : 'style="display: block;"';
        $disabled = $server_installed == 'yes' ? 'disabled' : null;
        if ($server_installed == 'yes') {
            if (strpos($server_update_method, 'http') === false) {
                $server_update_method_choices = array($server_update_method);
            } else {
                $server_update_method_choices = array('http', 'https');
            }
        } else {
            $server_update_method_choices = enumMYSQLSelect('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_update_method');
        }
        $available_server_types = $this->getAvailableFirewalls(enumMYSQLSelect('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_type'), $server_os);
        $server_type = buildSelect('server_type', 'server_type', $available_server_types, $server_type, 1);
        $server_update_method = buildSelect('server_update_method', 'server_update_method', $server_update_method_choices, $server_update_method, 1);
        $popup_title = $action == 'add' ? __('Add Firewall') : __('Edit Firewall');
        $popup_header = buildPopup('header', $popup_title);
        $popup_footer = buildPopup('footer');
        $alternative_help = $action == 'add' && getOption('client_auto_register') ? sprintf('<p><b>%s</b> %s</p>', __('Note:'), __('The client installer can automatically generate this entry.')) : null;
        $server_name_length = getColumnLength('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_name');
        $return_form = sprintf('<form name="manage" id="manage" method="post" action="">
		%s
			<input type="hidden" name="action" value="%s" />
			<input type="hidden" name="server_id" value="%d" />
			%s
			<table class="form-table">
				<tr>
					<th width="33&#37;" scope="row"><label for="server_name">%s</label></th>
					<td width="67&#37;"><input name="server_name" id="server_name" type="text" value="%s" size="40" placeholder="fw1.local" maxlength="%d" /></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="server_type">%s</label></th>
					<td width="67&#37;">%s</td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="server_update_method">%s</label></th>
					<td width="67&#37;">%s<div id="server_update_port_option" %s><input type="number" name="server_update_port" value="%s" placeholder="80" onkeydown="return validateNumber(event)" maxlength="5" max="65535" /></div></td>
				</tr>
				<tr>
					<th width="33&#37;" scope="row"><label for="server_config_file">%s</label></th>
					<td width="67&#37;"><input name="server_config_file" id="server_config_file" type="text" value="%s" size="40" /></td>
				</tr>
			</table>
		%s
		</form>
		<script>
			$(document).ready(function() {
				$("#manage select").select2({
					width: "200px",
					minimumResultsForSearch: 10
				});
			});
		</script>', $popup_header, $action, $server_id, $alternative_help, __('Server Name'), $server_name, $server_name_length, __('Firewall Type'), $server_type, __('Update Method'), $server_update_method, $server_update_port_style, $server_update_port, __('Config File'), $server_config_file, $popup_footer);
        return $return_form;
    }
示例#27
0
if (!function_exists('returnUnAuth')) {
    include ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $fm_name . DIRECTORY_SEPARATOR . 'ajax' . DIRECTORY_SEPARATOR . 'functions.php';
}
$unpriv_message = _('You do not have sufficient privileges.');
/** Handle password changes */
if (is_array($_POST) && array_key_exists('item_type', $_POST) && $_POST['item_type'] == 'set_mysql_password') {
    if (!currentUserCan('manage_passwords', $_SESSION['module'])) {
        returnUnAuth(true);
    }
    include ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $_SESSION['module'] . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'class_passwords.php';
    if ($_POST['verbose']) {
        echo buildPopup('header', _('Password Change Results')) . '<pre>';
    }
    echo $fm_sqlpass_passwords->setPassword();
    if ($_POST['verbose']) {
        echo '</pre>' . buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'));
    }
    exit;
    /** Handle everything else */
} elseif (is_array($_POST) && count($_POST) && currentUserCan('manage_servers', $_SESSION['module'])) {
    $table = 'sqlpass_' . $_POST['item_type'];
    $item_type = $_POST['item_type'];
    $prefix = substr($item_type, 0, -1) . '_';
    $field = $prefix . 'id';
    $type_map = null;
    $id = sanitize($_POST['item_id']);
    $type = isset($_POST['item_sub_type']) ? sanitize($_POST['item_sub_type']) : null;
    /* Determine which class we need to deal with */
    switch ($_POST['item_type']) {
        case 'groups':
            $post_class = $fm_sqlpass_groups;