示例#1
0
                    setBuildUpdateConfigFlag($server_serial_no, 'yes', 'build');
                    header('Location: ' . $GLOBALS['basename'] . $uri_params);
                }
            }
    }
}
printHeader();
@printMenu();
$avail_types = buildSubMenu(strtolower($option_type));
$avail_servers = buildServerSubMenu($server_serial_no);
$sort_direction = null;
$sort_field = 'cfg_name';
if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) {
    extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
}
echo printPageHeader($response, $display_option_type . ' ' . getPageTitle(), currentUserCan('manage_servers', $_SESSION['module']), $name, $rel);
echo <<<HTML
<div id="pagination_container" class="submenus">
\t<div>
\t<div class="stretch"></div>
\t{$avail_types}
\t{$avail_servers}
\t</div>
</div>

HTML;
$result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', array('domain_id', $sort_field, 'cfg_name'), 'cfg_', "AND cfg_type='{$display_option_type_sql}' AND server_serial_no='{$server_serial_no}'", null, false, $sort_direction);
$fm_module_options->rows($result);
printFooter();
function buildSubMenu($option_type = 'global')
{
示例#2
0
function buildRecordTypes($record_type = null, $all_domain_ids = null, $map = 'forward', $supported_record_types, $search_query = null)
{
    global $fmdb, $__FM_CONFIG;
    $menu_selects = $menu_sub_selects = null;
    $q = isset($_GET['q']) ? '&q=' . sanitize($_GET['q']) : null;
    if (isset($record_type) && $all_domain_ids != null) {
        $domain_id = $all_domain_ids[0];
        $query = "SELECT DISTINCT `record_type` FROM fm_{$__FM_CONFIG['fmDNS']['prefix']}records WHERE `record_status`!='deleted' AND\n\t\t\t`account_id`={$_SESSION['user']['account_id']} AND `domain_id` IN (" . implode(',', $all_domain_ids) . ") {$search_query}";
        $fmdb->get_results($query);
        $used_record_types = array();
        if ($fmdb->num_rows) {
            $type_result = $fmdb->last_result;
            for ($i = 0; $i < $fmdb->num_rows; $i++) {
                $used_record_types[] = $type_result[$i]->record_type;
            }
        }
        @sort($used_record_types);
        $used_record_types[] = 'SOA';
        foreach ($used_record_types as $type) {
            if (empty($type)) {
                continue;
            }
            if (in_array($type, $__FM_CONFIG['records']['require_zone_rights']) && !currentUserCan('manage_zones', $_SESSION['module'])) {
                continue;
            }
            if ($type == 'SOA') {
                /** Skip clones */
                if (getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_clone_domain_id')) {
                    continue;
                }
                /** Skip templates */
                if (getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id')) {
                    continue;
                }
            }
            $select = $record_type == $type ? ' class="selected"' : '';
            $menu_selects .= "<span{$select}><a{$select} href=\"zone-records.php?map={$map}&domain_id={$domain_id}&record_type={$type}{$q}\">{$type}</a></span>\n";
        }
        /** More record types menu */
        if (count($used_record_types) < count($supported_record_types)) {
            foreach ($supported_record_types as $type) {
                if (!in_array($type, $used_record_types)) {
                    if ($record_type == $type) {
                        $menu_selects .= "<span class=\"selected\"><a class=\"selected\" href=\"zone-records.php?map={$map}&domain_id={$domain_id}&record_type={$type}\">{$type}</a></span>\n";
                    } else {
                        $menu_sub_selects .= "<li><a href=\"zone-records.php?map={$map}&domain_id={$domain_id}&record_type={$type}{$q}\"><span>{$type}</span></a></li>\n";
                    }
                }
            }
            $menu_selects = <<<MENU
\t\t\t{$menu_selects}
\t\t\t</div>
\t\t\t<div id="configtypesmenu" class="nopadding dropdown">
\t\t\t\t<div id="recordmenu">
\t\t\t\t<ul>
\t\t\t\t\t<li class="has-sub"><a href="#"><span>...</span></a>
\t\t\t\t\t\t<ul>
\t\t\t\t\t\t{$menu_sub_selects}
\t\t\t\t\t\t</ul>
\t\t\t\t\t</li>
\t\t\t\t</ul>
\t\t\t\t</div>

MENU;
        }
    }
    return '<div id="configtypesmenu" class="submenus">' . $menu_selects . '</div>';
}
示例#3
0
/**
 * Gets the count for servers requiring a config build
 *
 * @since 2.0
 * @package facileManager
 *
 * @return integer Record count
 */
function countServerUpdates()
{
    global $fmdb, $__FM_CONFIG;
    if (currentUserCan('manage_servers', $_SESSION['module'])) {
        basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_id', 'server_', 'AND (server_build_config!="no" OR server_client_version!="' . getOption('client_version', 0, $_SESSION['module']) . '") AND server_status="active" AND server_installed="yes"', null, false, null, true);
        if ($fmdb->num_rows) {
            return $fmdb->last_result[0]->count;
        }
    }
    return 0;
}
示例#4
0
 | Displays module forms                                                   |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
if (!defined('AJAX')) {
    define('AJAX', true);
}
require_once '../../../fm-init.php';
include ABSPATH . 'fm-modules/fmSQLPass/classes/class_groups.php';
include ABSPATH . 'fm-modules/fmSQLPass/classes/class_servers.php';
if (is_array($_GET) && array_key_exists('action', $_GET) && ($_GET['action'] = 'display-process-all')) {
    echo 0;
    exit;
}
/** Edits */
if (is_array($_POST) && count($_POST) && currentUserCan('manage_servers', $_SESSION['module'])) {
    if (array_key_exists('add_form', $_POST)) {
        $id = isset($_POST['item_id']) ? sanitize($_POST['item_id']) : null;
        $add_new = true;
    } elseif (array_key_exists('item_id', $_POST)) {
        $id = sanitize($_POST['item_id']);
        $view_id = isset($_POST['view_id']) ? sanitize($_POST['view_id']) : null;
        $add_new = false;
    } else {
        returnError();
    }
    $table = $__FM_CONFIG['fmSQLPass']['prefix'] . $_POST['item_type'];
    $item_type = $_POST['item_type'];
    $prefix = substr($item_type, 0, -1) . '_';
    $field = $prefix . 'id';
    $type_map = null;
 | This program is free software; you can redistribute it and/or           |
 | modify it under the terms of the GNU General Public License             |
 | as published by the Free Software Foundation; either version 2          |
 | of the License, or (at your option) any later version.                  |
 |                                                                         |
 | This program is distributed in the hope that it will be useful,         |
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | facileManager: Easy System Administration                               |
 | fmSQLPass: Change database user passwords across multiple servers.      |
 +-------------------------------------------------------------------------+
 | http://www.facilemanager.com/modules/fmsqlpass/                         |
 +-------------------------------------------------------------------------+
 | Processes password management page                                      |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
if (!currentUserCan(array('manage_passwords', 'view_all'), $_SESSION['module'])) {
    unAuth();
}
$response = isset($response) ? $response : null;
printHeader();
@printMenu();
include ABSPATH . 'fm-modules/fmSQLPass/classes/class_passwords.php';
include ABSPATH . 'fm-modules/facileManager/classes/class_users.php';
echo printPageHeader($response);
$result = basicGetList('fm_' . $__FM_CONFIG['fmSQLPass']['prefix'] . 'groups', 'group_name', 'group_', 'active');
$fm_sqlpass_passwords->rows($result);
printFooter();
示例#6
0
 /**
  * Backs up the database
  *
  * @since 1.0
  * @package facileManager
  */
 function backupDatabase()
 {
     global $__FM_CONFIG, $fm_name;
     if (!currentUserCan('run_tools')) {
         return sprintf('<p class="error">%s</p>', _('You are not authorized to run these tools.'));
     }
     /** Temporary fix for MySQL 5.6 warnings */
     $exclude_warnings = array('Warning: Using a password on the command line interface can be insecure.' . "\n");
     $curdate = date("Y-m-d_H.i.s");
     $sql_file = sys_get_temp_dir() . '/' . $__FM_CONFIG['db']['name'] . '_' . $curdate . '.sql';
     $error_log = str_replace('.sql', '.err', $sql_file);
     $mysqldump = findProgram('mysqldump');
     if (!$mysqldump) {
         return sprintf('<p class="error">' . _('mysqldump is not found on %s.') . '</p>', php_uname('n'));
     }
     $command_string = "{$mysqldump} --opt -Q -h {$__FM_CONFIG['db']['host']} -u {$__FM_CONFIG['db']['user']} -p{$__FM_CONFIG['db']['pass']} {$__FM_CONFIG['db']['name']} > " . sys_get_temp_dir() . "/{$__FM_CONFIG['db']['name']}_{$curdate}.sql 2>{$error_log}";
     @system($command_string, $retval);
     $retarr = @file_get_contents($error_log);
     if ($retval) {
         @unlink($error_log);
         @unlink($sql_file);
         return '<p class="error">' . nl2br(str_replace($exclude_warnings, '', $retarr)) . '</p>';
     }
     compressFile($sql_file, @file_get_contents($sql_file));
     @unlink($error_log);
     @unlink($sql_file);
     addLogEntry(_('Backed up the database.'), $fm_name);
     sendFileToBrowser($sql_file . '.gz');
 }
示例#7
0
    function displayRow($row, $type)
    {
        global $__FM_CONFIG;
        $disabled_class = $row->policy_status == 'disabled' ? ' class="disabled"' : null;
        $edit_status = $edit_actions = null;
        if (currentUserCan('manage_servers', $_SESSION['module'])) {
            $edit_status = '<a class="edit_form_link" name="' . $type . '" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            $edit_status .= '<a class="status_form_link" href="#" rel="';
            $edit_status .= $row->policy_status == 'active' ? 'disabled' : 'active';
            $edit_status .= '">';
            $edit_status .= $row->policy_status == 'active' ? $__FM_CONFIG['icons']['disable'] : $__FM_CONFIG['icons']['enable'];
            $edit_status .= '</a>';
            $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>';
            $edit_status = '<td id="edit_delete_img">' . $edit_status . '</td>';
        }
        $log = $row->policy_options & $__FM_CONFIG['fw']['policy_options']['log']['bit'] ? str_replace(array('__action__', '__Action__'), array('log', 'Log'), $__FM_CONFIG['icons']['action'][$row->policy_status]) : null;
        $action = str_replace(array('__action__', '__Action__'), array($row->policy_action, ucfirst($row->policy_action)), $__FM_CONFIG['icons']['action'][$row->policy_status]);
        $source = $row->policy_source ? $this->formatPolicyIDs($row->policy_source) : 'any';
        $destination = $row->policy_destination ? $this->formatPolicyIDs($row->policy_destination) : 'any';
        $services = $row->policy_services ? $this->formatPolicyIDs($row->policy_services) : 'any';
        $interface = $row->policy_interface ? $row->policy_interface : 'any';
        $policy_time = $row->policy_time ? getNameFromID($row->policy_time, 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'time', 'time_', 'time_id', 'time_name') : 'any';
        $source_not = $row->policy_source_not ? '!' : null;
        $destination_not = $row->policy_destination_not ? '!' : null;
        $service_not = $row->policy_services_not ? '!' : null;
        $comments = nl2br($row->policy_comment);
        echo <<<HTML
\t\t<tr id="{$row->policy_id}"{$disabled_class}>
\t\t\t<td style="white-space: nowrap; text-align: right;">{$log} {$action}</td>
\t\t\t<td>{$source_not} {$source}</td>
\t\t\t<td>{$destination_not} {$destination}</td>
\t\t\t<td>{$service_not} {$services}</td>
\t\t\t<td>{$interface}</td>
\t\t\t<td>{$row->policy_direction}</td>
\t\t\t<td>{$policy_time}</td>
\t\t\t<td>{$comments}</td>
\t\t\t{$edit_status}
\t\t</tr>

HTML;
    }
示例#8
0
 | of the License, or (at your option) any later version.                  |
 |                                                                         |
 | This program is distributed in the hope that it will be useful,         |
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | facileManager: Easy System Administration                               |
 +-------------------------------------------------------------------------+
 | http://www.facilemanager.com/                                           |
 +-------------------------------------------------------------------------+
 | Processes admin logs page                                               |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
if (!currentUserCan('view_logs')) {
    unAuth();
}
printHeader();
@printMenu();
$response = isset($response) ? $response : null;
$search_sql = $list = $log_search_query = $log_search_date_b = $log_search_date_e = null;
extract($_POST);
/** Module search */
if (isset($log_search_module) && is_array($log_search_module) && !in_array('All Modules', $log_search_module)) {
    foreach ($log_search_module as $search_module) {
        $list .= "'{$search_module}',";
    }
    $search_sql .= 'AND log_module IN (' . rtrim($list, ',') . ') ';
}
/** User search */
示例#9
0
    /**
     * Imports records from a zone file and presents a confirmation
     */
    function zoneImportWizard()
    {
        global $__FM_CONFIG, $fm_name;
        if (!currentUserCan('manage_records', $_SESSION['module'])) {
            return $this->unAuth('zone');
        }
        if (!zoneAccessIsAllowed(array($_POST['domain_id']))) {
            return $this->unAuth('zone');
        }
        $raw_contents = file_get_contents($_FILES['import-file']['tmp_name']);
        /** Strip commented lines */
        $clean_contents = preg_replace('/^;.*\\n?/m', '', $raw_contents);
        /** Strip blank lines */
        $clean_contents = preg_replace('/^\\n?/m', '', $clean_contents);
        /** Strip $GENERATE lines */
        $clean_contents = preg_replace('/^\\$GENERATE.*\\n?/m', '', $clean_contents, -1, $generate_count);
        /** Strip $ORIGIN lines */
        $clean_contents = preg_replace('/^\\$ORIGIN.*\\n?/m', '', $clean_contents, -1, $origin_count);
        /** Handle unsupported message */
        if ($generate_count || $origin_count) {
            $unsupported[] = sprintf('<h4>%s:</h4>', __('Unsupported Entries'));
            $unsupported[] = '<p class="soa_import">' . sprintf(__('%s currently does not support importing $GENERATE and $ORIGIN entries which were found in your zone file.'), $fm_name) . '</p>';
            $unsupported = implode("\n", $unsupported);
        } else {
            $unsupported = null;
        }
        $domain_name = getNameFromID($_POST['domain_id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name');
        $domain_map = getNameFromID($_POST['domain_id'], 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_mapping');
        $count = 1;
        /** Detect SOA */
        if (!getSOACount($_POST['domain_id']) && strpos($clean_contents, ' SOA ') !== false && (in_array('SOA', $__FM_CONFIG['records']['require_zone_rights']) && currentUserCan('manage_zones', $_SESSION['module']))) {
            $raw_soa = preg_replace("/SOA(.+?)\\)/esim", "str_replace(PHP_EOL, ' ', '\\1')", $clean_contents);
            preg_match("/SOA(.+?)\\)/esim", $clean_contents, $raw_soa);
            preg_match("/TTL(.+?)\$/esim", $clean_contents, $raw_ttl);
            if (is_array($raw_ttl)) {
                $soa_array['soa_ttl'] = trim(preg_replace('/;(.+?)+/', '', $raw_ttl[1]));
            }
            if (is_array($raw_soa)) {
                $raw_soa = preg_replace('/;(.+?)+/', '', $raw_soa[1]);
                $soa = str_replace(array("\n", "\t", '(', ')', '  '), ' ', preg_replace('/\\s\\s+/', ' ', $raw_soa));
                $soa = str_replace(' ', '|', trim($soa));
                $soa_fields = explode('|', str_replace('||', '|', $soa));
                list($soa_array['soa_master_server'], $soa_array['soa_email_address'], $tmp_serial, $soa_array['soa_refresh'], $soa_array['soa_retry'], $soa_array['soa_expire'], $tmp_neg_cache) = $soa_fields;
                if (strpos($soa_array['soa_master_server'], $domain_name) !== false) {
                    $soa_array['soa_master_server'] = str_replace('.' . trimFullStop($domain_name) . '.', '', $soa_array['soa_master_server']);
                    $soa_array['soa_email_address'] = str_replace('.' . trimFullStop($domain_name) . '.', '', $soa_array['soa_email_address']);
                    $soa_array['soa_append'] = 'yes';
                } else {
                    $soa_array['soa_append'] = 'no';
                }
            }
            $soa_row = '<h4>SOA:</h4><p class="soa_import">' . trimFullStop($domain_name) . '. IN SOA ' . $soa_array['soa_master_server'];
            if ($soa_array['soa_append'] == 'yes') {
                $soa_row .= '.' . trimFullStop($domain_name) . '.';
            }
            $soa_row .= ' ' . $soa_array['soa_email_address'];
            if ($soa_array['soa_append'] == 'yes') {
                $soa_row .= '.' . trimFullStop($domain_name) . '.';
            }
            $soa_row .= ' ( &lt;autogen_serial&gt; ' . $soa_array['soa_refresh'] . ' ' . $soa_array['soa_retry'] . ' ' . $soa_array['soa_expire'] . ' ' . $soa_array['soa_ttl'] . ' )';
            $soa_row = <<<HTML
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_master_server]" value="{$soa_array['soa_master_server']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_email_address]" value="{$soa_array['soa_email_address']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_refresh]" value="{$soa_array['soa_refresh']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_retry]" value="{$soa_array['soa_retry']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_expire]" value="{$soa_array['soa_expire']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_ttl]" value="{$soa_array['soa_ttl']}" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][record_type]" value="SOA" />
\t\t\t\t\t\t<input type="hidden" name="create[{$count}][soa_append]" value="{$soa_array['soa_append']}" />
\t\t\t\t\t\t{$soa_row}
\t\t\t\t\t\t<span><label><input type="checkbox" name="create[{$count}][record_skip]" />Skip Import</label></span>
\t\t\t\t\t\t</p>
\t\t\t\t\t\t
\t\t\t\t\t\t<h4>Records:</h4>

HTML;
            $count++;
        } else {
            $soa_row = null;
        }
        $clean_contents = str_replace('.' . trimFullStop($domain_name) . '.', '', $clean_contents);
        $clean_contents = str_replace(trimFullStop($domain_name) . '.', '', $clean_contents);
        $available_record_types = array_filter(enumMYSQLSelect('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', 'record_type'), 'removeRestrictedRR');
        sort($available_record_types);
        /** Loop through the lines */
        $lines = explode(PHP_EOL, $clean_contents);
        $failed = 0;
        $rows = null;
        $valid_hashes = array(';', '//', '#');
        foreach ($lines as $line) {
            $null_keys = array('record_ttl', 'record_priority', 'record_weight', 'record_port');
            foreach ($null_keys as $key) {
                $array[$key] = null;
            }
            if (!strlen(trim($line))) {
                continue;
            }
            foreach ($valid_hashes as $tmp_hash) {
                if (strpos($line, $tmp_hash)) {
                    $hash = $tmp_hash;
                    break;
                } else {
                    $hash = null;
                }
            }
            if ($hash == '//') {
                $hash = '\\/\\/';
            }
            /** Break up the line for comments */
            if ($hash) {
                $comment_parts = preg_split("/{$hash}+/", $line);
                $array['record_comment'] = trim($comment_parts[1]) ? trim($comment_parts[1]) : 'none';
            } else {
                $comment_parts[0] = $line;
                $array['record_comment'] = 'none';
            }
            /** Break up the line for parts */
            $parts = preg_split('/\\s+/', trim($comment_parts[0]));
            if ($domain_map == 'forward') {
                if (in_array('MX', $parts)) {
                    switch (array_search('MX', $parts)) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if (is_numeric($parts[0])) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_priority'], $array['record_value']) = $parts;
                    }
                } elseif (in_array('SRV', $parts)) {
                    switch (array_search('SRV', $parts)) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if (is_numeric($parts[0])) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_priority'], $array['record_weight'], $array['record_port'], $array['record_value']) = $parts;
                    }
                } elseif (in_array('TXT', $parts)) {
                    $key = array_search('TXT', $parts);
                    $txt_record = null;
                    for ($i = $key + 1; $i < count($parts); $i++) {
                        $txt_record .= $parts[$i] . ' ';
                    }
                    $parts[$key + 1] = rtrim($txt_record);
                    switch ($key) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if (is_numeric($parts[0])) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                    }
                    $array['record_value'] = str_replace('"', '', $array['record_value']);
                } elseif (in_array('A', $parts) || in_array('CNAME', $parts) || in_array('AAAA', $parts)) {
                    if (in_array('AAAA', $parts)) {
                        $key = array_search('AAAA', $parts);
                    } else {
                        $key = in_array('A', $parts) ? array_search('A', $parts) : array_search('CNAME', $parts);
                    }
                    switch ($key) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if (is_numeric($parts[0])) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                    }
                }
            } else {
                if (in_array('PTR', $parts)) {
                    switch (array_search('PTR', $parts)) {
                        case 3:
                            list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            break;
                        case 2:
                            if ($parts[0] > 255) {
                                $array['record_name'] = isset($current_name) ? $current_name : '@';
                                list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            } else {
                                list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                            }
                            break;
                        case 1:
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                    }
                }
            }
            if (in_array('NS', $parts) && in_array('NS', $__FM_CONFIG['records']['require_zone_rights']) && currentUserCan('manage_zones', $_SESSION['module'])) {
                switch (array_search('NS', $parts)) {
                    case 3:
                        list($array['record_name'], $array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                        break;
                    case 2:
                        if (is_numeric($parts[0])) {
                            $array['record_name'] = isset($current_name) ? $current_name : '@';
                            list($array['record_ttl'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                        } else {
                            list($array['record_name'], $array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                        }
                        break;
                    case 1:
                        $array['record_name'] = isset($current_name) ? $current_name : '@';
                        list($array['record_class'], $array['record_type'], $array['record_value']) = $parts;
                }
            }
            if (empty($array['record_name']) && !empty($array['record_comment'])) {
                continue;
            }
            $array['record_append'] = substr($array['record_value'], -1) == '.' ? 'no' : 'yes';
            /** Set current_name to check for blanks on next run */
            $current_name = $array['record_name'];
            /** Automatically skip duplicates */
            $checked = $this->checkDuplicates($array, $_POST['domain_id']);
            $rows .= <<<ROW
\t\t\t\t\t<tr class="import_swap">
\t\t\t\t\t\t<td><span id="name{$count}" onclick="exchange(this);">{$array['record_name']}</span><input onblur="exchange(this);" type="text" id="name{$count}b" name="create[{$count}][record_name]" value="{$array['record_name']}" /></td>
\t\t\t\t\t\t<td><span id="ttl{$count}" onclick="exchange(this);">{$array['record_ttl']}</span><input onblur="exchange(this);" type="number" id="ttl{$count}b" name="create[{$count}][record_ttl]" value="{$array['record_ttl']}" /></td>
\t\t\t\t\t\t<td><input type="hidden" name="create[{$count}][record_class]" value="{$array['record_class']}" />{$array['record_class']}</td>
\t\t\t\t\t\t<td><input type="hidden" name="create[{$count}][record_type]" value="{$array['record_type']}" />{$array['record_type']}</td>
\t\t\t\t\t\t<td><span id="priority{$count}" onclick="exchange(this);">{$array['record_priority']}</span><input onblur="exchange(this);" type="number" id="priority{$count}b" name="create[{$count}][record_priority]" value="{$array['record_priority']}" /></td>
\t\t\t\t\t\t<td><span id="value{$count}" onclick="exchange(this);">{$array['record_value']}</span><input onblur="exchange(this);" type="text" id="value{$count}b" name="create[{$count}][record_value]" value="{$array['record_value']}" /></td>
\t\t\t\t\t\t<td><span id="weight{$count}" onclick="exchange(this);">{$array['record_weight']}</span><input onblur="exchange(this);" type="number" id="weight{$count}b" name="create[{$count}][record_weight]" value="{$array['record_weight']}" /></td>
\t\t\t\t\t\t<td><span id="port{$count}" onclick="exchange(this);">{$array['record_port']}</span><input onblur="exchange(this);" type="number" id="port{$count}b" name="create[{$count}][record_port]" value="{$array['record_port']}" /></td>
\t\t\t\t\t\t<td><span id="comment{$count}" onclick="exchange(this);">{$array['record_comment']}</span><input onblur="exchange(this);" type="text" id="comment{$count}b" name="create[{$count}][record_comment]" value="{$array['record_comment']}" /></td>
\t\t\t\t\t\t<td style="text-align: center;" nowrap><input type="hidden" name="create[{$count}][record_append]" value="{$array['record_append']}" />{$array['record_append']}</td>
\t\t\t\t\t\t<td style="text-align: center;"><label><input type="checkbox" name="create[{$count}][record_skip]" {$checked} />Skip Import</label></td>
\t\t\t\t\t</tr>

ROW;
            $count++;
        }
        $table_info = array('class' => 'display_results', 'id' => 'table_edits', 'name' => 'views');
        $title_array = array(__('Record'), __('TTL'), __('Class'), __('Type'), __('Priority'), __('Value'), __('Weight'), __('Port'), __('Comment'));
        $title_array[] = array('title' => __('Append Domain'), 'style' => 'text-align: center;', 'nowrap' => null);
        $title_array[] = array('title' => __('Actions'), 'class' => 'header-actions');
        $table_header = displayTableHeader($table_info, $title_array);
        $popup_header = buildPopup('header', __('Import Verification'));
        $popup_footer = buildPopup('footer', __('Import'), array('import' => 'submit', 'cancel_button' => 'cancel'));
        $body = <<<BODY
\t\t<form method="post" action="zone-records-write.php">
\t\t{$popup_header}
\t\t\t<p>Domain: {$domain_name}</p>
\t\t\t<input type="hidden" name="domain_id" value="{$_POST['domain_id']}">
\t\t\t<input type="hidden" name="map" value="{$domain_map}">
\t\t\t<input type="hidden" name="import_records" value="true">
\t\t\t<input type="hidden" name="import_file" value="{$_FILES['import-file']['name']}">
\t\t\t{$unsupported}
\t\t\t{$soa_row}
\t\t\t{$table_header}
\t\t\t\t{$rows}
\t\t\t\t</tbody>
\t\t\t</table>
\t\t\t<br />
\t\t{$popup_footer}
\t\t</form>
BODY;
        return $body;
    }
示例#10
0
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;
    }
    $table = $__FM_CONFIG[$_SESSION['module']]['prefix'] . sanitize($_POST['item_type']);
    $id = sanitize($_POST['item_id']);
    $server_serial_no = isset($_POST['server_serial_no']) ? sanitize($_POST['server_serial_no']) : null;
    $type = isset($_POST['item_sub_type']) ? sanitize($_POST['item_sub_type']) : null;
    $table = $__FM_CONFIG[$_SESSION['module']]['prefix'] . $_POST['item_type'];
    $item_type = $_POST['item_type'];
    $prefix = substr($item_type, 0, -1) . '_';
    /* Determine which class we need to deal with */
    switch ($_POST['item_type']) {
        case 'servers':
            $post_class = $fm_module_servers;
示例#11
0
    function displayRow($row)
    {
        global $__FM_CONFIG;
        $disabled_class = $row->object_status == 'disabled' ? ' class="disabled"' : null;
        $edit_status = null;
        if (currentUserCan('manage_objects', $_SESSION['module'])) {
            $edit_status = '<a class="edit_form_link" name="' . $row->object_type . '" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            if (!isItemInPolicy($row->object_id, 'object')) {
                $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>';
            }
            $edit_status = '<td id="edit_delete_img">' . $edit_status . '</td>';
        }
        $edit_name = $row->object_name;
        $netmask = $row->object_type != 'address' ? "<td>{$row->object_mask}</td>" : null;
        $comments = nl2br($row->object_comment);
        echo <<<HTML
\t\t\t<tr id="{$row->object_id}"{$disabled_class}>
\t\t\t\t<td>{$row->object_name}</td>
\t\t\t\t<td>{$row->object_address}</td>
\t\t\t\t{$netmask}
\t\t\t\t<td>{$comments}</td>
\t\t\t\t{$edit_status}
\t\t\t</tr>

HTML;
    }
示例#12
0
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
define('AJAX', true);
require_once '../../../fm-init.php';
$response = null;
include ABSPATH . 'fm-modules/facileManager/classes/class_tools.php';
$shared_tools_file = ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . 'shared' . DIRECTORY_SEPARATOR . 'ajax' . DIRECTORY_SEPARATOR . 'processTools.php';
if (file_exists($shared_tools_file) && $_SESSION['module'] != $fm_name) {
    include $shared_tools_file;
}
$module_tools_file = ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $_SESSION['module'] . DIRECTORY_SEPARATOR . 'ajax' . DIRECTORY_SEPARATOR . 'processTools.php';
if (file_exists($module_tools_file) && $_SESSION['module'] != $fm_name) {
    include $module_tools_file;
}
if (is_array($_POST) && count($_POST) && currentUserCan('run_tools')) {
    if (isset($_POST['task']) && !empty($_POST['task'])) {
        switch ($_POST['task']) {
            case 'module_install':
                $module_name = isset($_POST['item']) ? sanitize($_POST['item']) : null;
                $response = buildPopup('header', _('Installing Module'));
                $response .= $fm_tools->installModule($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 'module_upgrade':
                $module_name = isset($_POST['item']) ? sanitize($_POST['item']) : null;
示例#13
0
    function displayRow($row)
    {
        global $__FM_CONFIG;
        $disabled_class = $row->time_status == 'disabled' ? ' class="disabled"' : null;
        $edit_status = null;
        if (currentUserCan('manage_time', $_SESSION['module'])) {
            $edit_status = '<a class="edit_form_link" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            $edit_status .= '<a class="status_form_link" href="#" rel="';
            $edit_status .= $row->time_status == 'active' ? 'disabled' : 'active';
            $edit_status .= '">';
            $edit_status .= $row->time_status == 'active' ? $__FM_CONFIG['icons']['disable'] : $__FM_CONFIG['icons']['enable'];
            $edit_status .= '</a>';
            if (!isItemInPolicy($row->time_id, 'time')) {
                $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>';
            }
            $edit_status = '<td id="edit_delete_img">' . $edit_status . '</td>';
        }
        /** Format date range */
        $date_range = $this->formatDates($row->time_start_date, $row->time_end_date);
        /** Format weekdays */
        $weekdays = $this->formatDays($row->time_weekdays);
        $comments = nl2br($row->time_comment);
        echo <<<HTML
\t\t\t<tr id="{$row->time_id}"{$disabled_class}>
\t\t\t\t<td>{$row->time_name}</td>
\t\t\t\t<td>{$date_range}</td>
\t\t\t\t<td>{$row->time_start_time} &rarr; {$row->time_end_time}</td>
\t\t\t\t<td>{$weekdays}</td>
\t\t\t\t<td>{$comments}</td>
\t\t\t\t{$edit_status}
\t\t\t</tr>

HTML;
    }
示例#14
0
            $user_info = getUserInfo($_GET['id']);
            if ($user_info) {
                if ($user_info['user_template_only'] == 'no') {
                    if (updateStatus('fm_users', $_GET['id'], 'user_', $_GET['status'], 'user_id')) {
                        addLogEntry(sprintf(_("Set user '%s' status to %s."), $user_info['user_login'], $_GET['status']), $fm_name);
                        header('Location: ' . $GLOBALS['basename'] . '?type=' . $_POST['type']);
                    }
                }
            }
            $response = sprintf(_('This user could not be set to %s.') . "\n", $_GET['status']);
        }
}
printHeader();
@printMenu();
$avail_types = buildSubMenu($type);
echo printPageHeader($response, $display_type, currentUserCan('manage_users'), $type);
$sort_field = $type == 'users' ? 'user_login' : 'group_name';
$sort_direction = null;
if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) {
    extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
}
echo <<<HTML
<div id="pagination_container" class="submenus">
\t<div>
\t<div class="stretch"></div>
\t{$avail_types}
\t</div>
</div>

HTML;
$result = $type == 'users' ? basicGetList('fm_users', $sort_field, 'user_', null, null, false, $sort_direction) : basicGetList('fm_groups', $sort_field, 'group_', null, null, false, $sort_direction);
示例#15
0
    function displayRow($row)
    {
        global $fmdb, $__FM_CONFIG, $fm_dns_acls;
        if (!class_exists('fm_dns_acls')) {
            include ABSPATH . 'fm-modules/fmDNS/classes/class_acls.php';
        }
        $disabled_class = $row->cfg_status == 'disabled' ? ' class="disabled"' : null;
        if (currentUserCan('manage_servers', $_SESSION['module'])) {
            $edit_uri = strpos($_SERVER['REQUEST_URI'], '?') ? $_SERVER['REQUEST_URI'] . '&' : $_SERVER['REQUEST_URI'] . '?';
            $edit_status = '<td id="edit_delete_img">';
            $edit_status .= '<a class="edit_form_link" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            $edit_status .= '<a class="status_form_link" href="#" rel="';
            $edit_status .= $row->cfg_status == 'active' ? 'disabled' : 'active';
            $edit_status .= '">';
            $edit_status .= $row->cfg_status == 'active' ? $__FM_CONFIG['icons']['disable'] : $__FM_CONFIG['icons']['enable'];
            $edit_status .= '</a>';
            $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>';
            $edit_status .= '</td>';
        } else {
            $edit_status = null;
        }
        $comments = nl2br($row->cfg_comment);
        /** Parse address_match_element configs */
        $cfg_data = $this->parseDefType($row->cfg_name, $row->cfg_data);
        $zone_row = null;
        if (isset($_GET['option_type']) && sanitize($_GET['option_type']) == 'ratelimit') {
            $domain_name = $row->domain_id ? getNameFromID($row->domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name') : '<span>All Zones</span>';
            $zone_row = '<td>' . $domain_name . '</td>';
            unset($domain_name);
        }
        echo <<<HTML
\t\t<tr id="{$row->cfg_id}"{$disabled_class}>
\t\t\t{$zone_row}
\t\t\t<td>{$row->cfg_name}</td>
\t\t\t<td>{$cfg_data}</td>
\t\t\t<td>{$comments}</td>
\t\t\t{$edit_status}
\t\t</tr>
HTML;
    }
示例#16
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);
 }
示例#17
0
 /**
  * Purges the fM logs table
  *
  * @since 2.1
  * @package facileManager
  *
  * @return string
  */
 function purgeLogs()
 {
     global $fmdb, $fm_name;
     if (!currentUserCan('do_everything')) {
         return sprintf('<p class="error">%s</p>', _('You are not authorized to run these tools.'));
     }
     $query = "TRUNCATE fm_logs";
     $fmdb->query($query);
     if ($fmdb->sql_errors) {
         return $fmdb->last_error;
     }
     addLogEntry(_('Purged all logs from the database.'), $fm_name);
     return _('Purged all logs from the database.');
 }
示例#18
0
 | of the License, or (at your option) any later version.                  |
 |                                                                         |
 | This program is distributed in the hope that it will be useful,         |
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | facileManager: Easy System Administration                               |
 | fmDNS: Easily manage one or more ISC BIND servers                       |
 +-------------------------------------------------------------------------+
 | http://www.facilemanager.com/modules/fmdns/                             |
 +-------------------------------------------------------------------------+
 | Add more form elements                                                  |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
if (!defined('AJAX')) {
    define('AJAX', true);
}
require_once '../../../fm-init.php';
$zone_access_allowed = true;
include ABSPATH . 'fm-modules/fmDNS/classes/class_records.php';
if (is_array($_POST) && count($_POST)) {
    if (currentUserCan('manage_records', $_SESSION['module'])) {
        if (array_key_exists('domain_id', $_POST) && array_key_exists('record_type', $_POST)) {
            extract($_POST);
            $additional_lines = $fm_dns_records->getInputForm($record_type, true, $domain_id, null, $clicks * 4 + 5);
            echo $additional_lines;
        }
    }
}
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
include ABSPATH . 'fm-modules/fmDNS/classes/class_records.php';
if (empty($_POST)) {
    header('Location: ' . $GLOBALS['RELPATH']);
}
extract($_POST);
/** Should the user be here? */
if (!currentUserCan('manage_records', $_SESSION['module'])) {
    unAuth();
}
if (!zoneAccessIsAllowed(array($domain_id))) {
    unAuth();
}
if (in_array($record_type, $__FM_CONFIG['records']['require_zone_rights']) && !currentUserCan('manage_zones', $_SESSION['module'])) {
    unAuth();
}
/** Make sure we can handle all of the variables */
checkMaxInputVars();
$domain_info['id'] = $domain_id;
$domain_info['name'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_name');
$domain_info['map'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_mapping');
$domain_info['clone_of'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_clone_domain_id');
$domain_info['template_id'] = getNameFromID($domain_id, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_', 'domain_id', 'domain_template_id');
if (isset($_POST['update'])) {
    if ($_POST['update']['soa_template_chosen']) {
        global $fm_dns_records;
        /** Save the soa_template_chosen in domains table and end */
        include_once ABSPATH . 'fm-modules/fmDNS/classes/class_records.php';
        $fm_dns_records->assignSOA($_POST['update']['soa_template_chosen'], $domain_id);
示例#20
0
            $response = $fm_tools->cleanupDatabase();
            break;
        case _('Backup Database'):
            $response = $fm_tools->backupDatabase();
            if (!$response) {
                header('Location: ' . $GLOBALS['basename']);
            }
            break;
    }
}
printHeader();
@printMenu();
$backup_button = findProgram('mysqldump') ? sprintf('<p class="step"><input id="db-backup" name="submit" type="submit" value="%s" class="button" /></p>', _('Backup Database')) : sprintf(_('<p>The required mysqldump utility is not found on %s.</p>'), php_uname('n'));
$tools_option[] = '<h2>' . _('Backup Database') . '</h2>
			<p>' . _('Run an ad hoc backup of your database.') . "</p>\n\t\t\t{$backup_button}\n\t\t\t<br />";
$purge_logs = currentUserCan('do_everything') ? ' <input id="purge-logs" name="submit" type="submit" value="' . _('Purge Logs') . '" class="button double-click" />' : null;
$tools_option[] = '<h2>' . _('Clean Up Database') . '</h2>
			<p>' . _('You should periodically clean up your database to permanently remove deleted items. Make sure you backup your database first!') . '</p>
			<p class="step"><input id="db-cleanup" name="submit" type="submit" value="' . _('Clean Up Database') . '" class="button" />' . $purge_logs . '</p>
			<br />';
/** Get available module tools */
$module_var_file = ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $_SESSION['module'] . DIRECTORY_SEPARATOR . 'variables.inc.php';
if (file_exists($module_var_file)) {
    include $module_var_file;
}
$shared_tools_file = ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . 'shared' . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . 'admin-tools.inc.php';
if (file_exists($shared_tools_file)) {
    include $shared_tools_file;
}
$module_tools_file = ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $_SESSION['module'] . DIRECTORY_SEPARATOR . 'pages' . DIRECTORY_SEPARATOR . 'admin-tools.inc.php';
if (file_exists($module_tools_file)) {
示例#21
0
            } else {
                header('Location: ' . $GLOBALS['basename']);
            }
            break;
    }
}
define('FM_INCLUDE_SEARCH', true);
printHeader();
@printMenu();
$search_query = createSearchSQL(array('name', 'mapping', 'type'), 'domain_');
/** Check if any servers need their configs built first */
$reload_allowed = reloadAllowed();
if (!$reload_allowed && !$response) {
    $response = '<p>' . sprintf(__('You currently have no name servers hosting zones. <a href="%s">Click here</a> to manage one or more servers.'), getMenuURL(__('Servers'))) . '</p>';
}
echo printPageHeader($response, null, currentUserCan('manage_zones', $_SESSION['module']), $map);
$sort_direction = null;
$sort_field = 'domain_name';
if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) {
    extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
}
/** Get zones based on access */
$user_capabilities = getUserCapabilities($_SESSION['user']['id'], 'all');
$limited_domain_ids = array_key_exists('access_specific_zones', $user_capabilities[$_SESSION['module']]) && !array_key_exists('view_all', $user_capabilities[$_SESSION['module']]) && $user_capabilities[$_SESSION['module']]['access_specific_zones'][0] ? "AND domain_id IN (" . implode(',', $user_capabilities[$_SESSION['module']]['access_specific_zones']) . ")" : null;
/** Process domain_view filtering */
if (isset($_GET['domain_view']) && !in_array(0, $_GET['domain_view'])) {
    foreach ((array) $_GET['domain_view'] as $view_id) {
        $view_id = sanitize($view_id);
        (string) ($domain_view_sql .= " (domain_view='{$view_id}' OR domain_view LIKE '{$view_id};%' OR domain_view LIKE '%;{$view_id};%' OR domain_view LIKE '%;{$view_id}') OR");
    }
    if ($domain_view_sql) {
示例#22
0
    function displayRow($row)
    {
        global $fmdb, $__FM_CONFIG;
        $disabled_class = $row->group_status == 'disabled' ? ' class="disabled"' : null;
        $assoc_servers = 'None';
        $query = "SELECT server_name from fm_{$__FM_CONFIG['fmSQLPass']['prefix']}servers WHERE server_status!='deleted' AND account_id={$_SESSION['user']['account_id']}\n\t\t\t\t\tAND (server_groups={$row->group_id} OR server_groups LIKE '{$row->group_id};%' OR server_groups LIKE '%;{$row->group_id};%' \n\t\t\t\t\tOR server_groups LIKE '%;{$row->group_id}')";
        if ($result = $fmdb->query($query)) {
            $assoc_servers = null;
            $result = $fmdb->last_result;
            for ($i = 0; $i < $fmdb->num_rows; $i++) {
                $assoc_servers .= $result[$i]->server_name . ', ';
            }
            $assoc_servers = rtrim($assoc_servers, ', ');
        }
        if (currentUserCan('manage_servers', $_SESSION['module'])) {
            $edit_status = '<td id="edit_delete_img">';
            $edit_status .= '<a class="edit_form_link" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            $edit_status .= '<a class="status_form_link" href="#" rel="';
            $edit_status .= $row->group_status == 'active' ? 'disabled' : 'active';
            $edit_status .= '">';
            $edit_status .= $row->group_status == 'active' ? $__FM_CONFIG['icons']['disable'] : $__FM_CONFIG['icons']['enable'];
            $edit_status .= '</a>';
            $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>';
            $edit_status .= '</td>';
        } else {
            $edit_status = null;
        }
        echo <<<HTML
\t\t<tr id="{$row->group_id}"{$disabled_class}>
\t\t\t<td>{$row->group_name}</td>
\t\t\t<td>{$assoc_servers}</td>
\t\t\t{$edit_status}
\t\t</tr>
HTML;
    }
示例#23
0
 +-------------------------------------------------------------------------+
 | Copyright (C) 2013 The facileManager Team                               |
 |                                                                         |
 | This program is free software; you can redistribute it and/or           |
 | modify it under the terms of the GNU General Public License             |
 | as published by the Free Software Foundation; either version 2          |
 | of the License, or (at your option) any later version.                  |
 |                                                                         |
 | This program is distributed in the hope that it will be useful,         |
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | facileManager: Easy System Administration                               |
 +-------------------------------------------------------------------------+
 | http://www.facilemanager.com/                                           |
 +-------------------------------------------------------------------------+
 | Processes settings management page                                      |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
if (!currentUserCan('manage_settings')) {
    unAuth();
}
include ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . $fm_name . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'class_settings.php';
printHeader();
@printMenu();
echo printPageHeader();
echo $fm_settings->printForm();
echo '</div>' . "\n";
printFooter();
示例#24
0
            } else {
                header('Location: ' . $GLOBALS['basename']);
            }
        }
        if (isset($_GET['status'])) {
            if ($_GET['id'] == 1) {
                $_GET['id'] = 0;
            }
            $user_info = getUserInfo($_GET['id']);
            if ($user_info) {
                if ($user_info['user_template_only'] == 'no') {
                    if (updateStatus('fm_users', $_GET['id'], 'user_', $_GET['status'], 'user_id')) {
                        addLogEntry(sprintf(_("Set user '%s' status to %s."), $user_info['user_login'], $_GET['status']), $fm_name);
                        header('Location: ' . $GLOBALS['basename']);
                    }
                }
            }
            $response = sprintf(_('This user could not be set to %s.') . "\n", $_GET['status']);
        }
}
printHeader();
@printMenu();
echo printPageHeader($response, null, currentUserCan('manage_users'));
$sort_field = 'user_login';
$sort_direction = null;
if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) {
    extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
}
$result = basicGetList('fm_users', $sort_field, 'user_', null, null, false, $sort_direction);
$fm_users->rows($result);
printFooter();
示例#25
0
 /**
  * Generates the zone configs (not files)
  *
  * @since 1.0
  * @package fmDNS
  */
 function buildZoneConfig($post_data)
 {
     global $fmdb, $__FM_CONFIG, $fm_module_servers, $fm_login;
     $server_serial_no = sanitize($post_data['SERIALNO']);
     extract($post_data);
     if (!isset($fm_login)) {
         require_once ABSPATH . 'fm-modules/facileManager/classes/class_logins.php';
     }
     if ($fm_login->isLoggedIn()) {
         if (!currentUserCan(array('access_specific_zones', 'view_all'), $_SESSION['module'], array(0, $domain_id))) {
             unAuth();
         }
     }
     basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'servers', $server_serial_no, 'server_', 'server_serial_no');
     if ($fmdb->num_rows || $SERIALNO == -1) {
         if ($SERIALNO != -1) {
             $data = $fmdb->last_result[0];
             extract(get_object_vars($data), EXTR_SKIP);
         }
         if (!$domain_id) {
             /** Build all zone files */
             list($data->files, $message) = $this->buildZoneDefinitions($server_zones_dir, $server_serial_no);
         } else {
             /** Build zone files for $domain_id */
             $query = "SELECT * FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains` WHERE `domain_status`='active' AND (`domain_id`=" . sanitize($domain_id) . " OR `domain_clone_domain_id`=" . sanitize($domain_id) . ") ";
             if ($SERIALNO != -1) {
                 $server_id = getServerID($server_serial_no, $_SESSION['module']);
                 $query .= " AND (`domain_name_servers`='0' OR `domain_name_servers`='s_{$server_id}' OR `domain_name_servers` LIKE 's_{$server_id};%' OR `domain_name_servers` LIKE '%;s_{$server_id};%'";
                 /** Get the associated server groups */
                 if (!isset($fm_module_servers)) {
                     include ABSPATH . 'fm-modules/' . $_SESSION['module'] . '/classes/class_servers.php';
                 }
                 if ($server_group_ids = $fm_module_servers->getServerGroupIDs($server_id)) {
                     foreach ($server_group_ids as $group_id) {
                         $query .= " OR `domain_name_servers`='g_{$group_id}' OR `domain_name_servers` LIKE 'g_{$group_id};%' OR `domain_name_servers` LIKE '%;g_{$group_id};%'";
                     }
                 }
                 $query .= ')';
             }
             $query .= " ORDER BY `domain_clone_domain_id`,`domain_name`";
             $result = $fmdb->query($query);
             if ($fmdb->num_rows) {
                 $count = $fmdb->num_rows;
                 $zone_result = $fmdb->last_result;
                 for ($i = 0; $i < $count; $i++) {
                     /** Is this a clone id? */
                     if ($zone_result[$i]->domain_clone_domain_id) {
                         $zone_result[$i] = $this->mergeZoneDetails($zone_result[$i], 'clone');
                     } elseif ($zone_result[$i]->domain_template_id) {
                         $zone_result[$i] = $this->mergeZoneDetails($zone_result[$i], 'template');
                     }
                     if (getSOACount($zone_result[$i]->domain_id)) {
                         $domain_name = $this->getDomainName($zone_result[$i]->domain_mapping, trimFullStop($zone_result[$i]->domain_name));
                         $file_ext = $zone_result[$i]->domain_mapping == 'forward' ? 'hosts' : 'rev';
                         /** Are there multiple zones with the same name? */
                         if (isset($zone_result[$i]->parent_domain_id)) {
                             basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $zone_result[$i]->domain_name, 'domain_', 'domain_name', 'AND domain_id!=' . $zone_result[$i]->parent_domain_id);
                             if ($fmdb->num_rows) {
                                 $file_ext = $zone_result[$i]->parent_domain_id . ".{$file_ext}";
                             }
                         } else {
                             $zone_result[$i]->parent_domain_id = $zone_result[$i]->domain_id;
                             basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $zone_result[$i]->domain_name, 'domain_', 'domain_name', 'AND domain_id!=' . $zone_result[$i]->domain_id);
                             if ($fmdb->num_rows) {
                                 $file_ext = $zone_result[$i]->domain_id . ".{$file_ext}";
                             }
                         }
                         //							basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $zone_result[$i]->domain_name, 'domain_', 'domain_name', 'AND domain_clone_domain_id=0 AND domain_id!=' . $zone_result[$i]->domain_id);
                         //							if ($fmdb->num_rows) $file_ext = $zone_result[$i]->domain_id . ".$file_ext";
                         /** Build zone file */
                         $data->files[$server_zones_dir . '/' . $zone_result[$i]->domain_type . '/db.' . $domain_name . $file_ext] = $this->buildZoneFile($zone_result[$i], $server_serial_no);
                     }
                 }
                 if (isset($data->files)) {
                     /** set the server_update_config flag */
                     if (!$dryrun) {
                         setBuildUpdateConfigFlag($server_serial_no, 'yes', 'update');
                     }
                     return array(get_object_vars($data), null);
                 }
             }
             /** Bad domain id */
             $error = "Domain ID {$domain_id} is not found or is not hosted on this server.\n";
         }
     } else {
         /** Bad DNS server */
         $error = "DNS server is not found.\n";
     }
     if ($compress) {
         echo gzcompress(serialize($error));
     } else {
         echo serialize($error);
     }
 }
示例#26
0
        case 'add':
            if (!empty($_POST)) {
                $result = $fm_module_services->add($_POST);
                if ($result !== true) {
                    $response = $result;
                    $form_data = $_POST;
                } else {
                    header('Location: ' . $GLOBALS['basename'] . '?type=' . $_POST['service_type']);
                }
            }
            break;
        case 'edit':
            if (!empty($_POST)) {
                $result = $fm_module_services->update($_POST);
                if ($result !== true) {
                    $response = $result;
                    $form_data = $_POST;
                } else {
                    header('Location: ' . $GLOBALS['basename'] . '?type=' . $_POST['service_type']);
                }
            }
            break;
    }
}
printHeader();
@printMenu();
//$allowed_to_add = ($type == 'custom' && currentUserCan('manage_services', $_SESSION['module'])) ? true : false;
echo printPageHeader($response, null, currentUserCan('manage_services', $_SESSION['module']), $type);
$result = basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'services', 'service_name', 'service_', "AND service_type='{$type}'");
$fm_module_services->rows($result, $type);
printFooter();
示例#27
0
 * facileManager Upgrader
 *
 * @package facileManager
 * @subpackage Administration
 *
 */
/** Define ABSPATH as this files directory */
define('ABSPATH', dirname(__FILE__) . '/');
/** Set installation variable */
define('UPGRADE', true);
/** Enforce authentication */
require_once ABSPATH . 'fm-modules/facileManager/classes/class_logins.php';
require_once 'fm-init.php';
ini_set('display_errors', false);
error_reporting(0);
if (!$fm_login->isLoggedIn() || !currentUserCan('do_everything') && getOption('fm_db_version') >= 32) {
    header('Location: ' . dirname($_SERVER['PHP_SELF']));
}
/** Ensure we meet the requirements */
require_once ABSPATH . 'fm-includes/init.php';
require_once ABSPATH . 'fm-includes/version.php';
$app_compat = checkAppVersions(false);
if ($app_compat) {
    bailOut($app_compat);
}
$step = isset($_GET['step']) ? $_GET['step'] : 0;
if (array_key_exists('backup', $_GET)) {
    if (!class_exists('fm_tools')) {
        include ABSPATH . 'fm-modules' . DIRECTORY_SEPARATOR . 'facileManager' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'class_tools.php';
    }
    $fm_tools->backupDatabase();
示例#28
0
                $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));
                if ($delete_status !== true) {
                    echo $delete_status;
                } else {
示例#29
0
    function displayRow($row)
    {
        global $__FM_CONFIG;
        $class = $row->server_status == 'disabled' ? 'disabled' : null;
        $os_image = setOSIcon($row->server_os_distro);
        $edit_status = $edit_actions = null;
        $edit_actions = $row->server_status == 'active' ? '<a href="preview.php" onclick="javascript:void window.open(\'preview.php?server_serial_no=' . $row->server_serial_no . '\',\'1356124444538\',\'width=700,height=500,toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1,left=0,top=0\');return false;">' . $__FM_CONFIG['icons']['preview'] . '</a>' : null;
        $checkbox = currentUserCan(array('manage_servers', 'build_server_configs'), $_SESSION['module']) ? '<td><input type="checkbox" name="server_list[]" value="' . $row->server_serial_no . '" /></td>' : null;
        if (currentUserCan('build_server_configs', $_SESSION['module']) && $row->server_installed == 'yes') {
            if ($row->server_build_config == 'yes' && $row->server_status == 'active' && $row->server_installed == 'yes') {
                $edit_actions .= $__FM_CONFIG['icons']['build'];
                $class = 'build';
            }
        }
        if (currentUserCan('manage_servers', $_SESSION['module'])) {
            $edit_status = '<a class="edit_form_link" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            if ($row->server_installed == 'yes') {
                $edit_status .= '<a class="status_form_link" href="#" rel="';
                $edit_status .= $row->server_status == 'active' ? 'disabled' : 'active';
                $edit_status .= '">';
                $edit_status .= $row->server_status == 'active' ? $__FM_CONFIG['icons']['disable'] : $__FM_CONFIG['icons']['enable'];
                $edit_status .= '</a>';
            }
            $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>';
        }
        $edit_name = currentUserCan(array('manage_policies', 'view_all'), $_SESSION['module']) ? '<a href="config-policy.php?server_serial_no=' . $row->server_serial_no . '">' . $row->server_name . '</a>' : $row->server_name;
        if (isset($row->server_client_version) && version_compare($row->server_client_version, getOption('client_version', 0, $_SESSION['module']), '<')) {
            $edit_actions = __('Client Upgrade Available') . '<br />';
            $class = 'attention';
        }
        if ($row->server_installed != 'yes') {
            $edit_actions = __('Client Install Required') . '<br />';
            $edit_name = $row->server_name;
        }
        $edit_status = $edit_actions . $edit_status;
        $port = $row->server_update_method != 'cron' ? '(tcp/' . $row->server_update_port . ')' : null;
        if ($class) {
            $class = 'class="' . $class . '"';
        }
        echo <<<HTML
\t\t<tr id="{$row->server_id}" {$class}>
\t\t\t{$checkbox}
\t\t\t<td>{$os_image}</td>
\t\t\t<td title="{$row->server_serial_no}">{$edit_name}</td>
\t\t\t<td>{$row->server_update_method} {$port}</td>
\t\t\t<td>{$row->server_type}</td>
\t\t\t<td>{$row->server_version}</td>
\t\t\t<td>{$row->server_config_file}</td>
\t\t\t<td id="edit_delete_img">{$edit_status}</td>
\t\t</tr>

HTML;
    }
示例#30
0
    function displayRow($row, $channel_category)
    {
        global $__FM_CONFIG;
        $disabled_class = $row->cfg_status == 'disabled' ? ' class="disabled"' : null;
        $edit_name = $row->cfg_parent ? '&nbsp;&nbsp;&nbsp;' : null;
        if (currentUserCan('manage_servers', $_SESSION['module'])) {
            $edit_status = '<td id="edit_delete_img">';
            $edit_status .= '<a class="edit_form_link" name="' . $channel_category . '" href="#">' . $__FM_CONFIG['icons']['edit'] . '</a>';
            $edit_status .= '<a class="status_form_link" href="#" rel="';
            $edit_status .= $row->cfg_status == 'active' ? 'disabled' : 'active';
            $edit_status .= '">';
            $edit_status .= $row->cfg_status == 'active' ? $__FM_CONFIG['icons']['disable'] : $__FM_CONFIG['icons']['enable'];
            $edit_status .= '</a>';
            if ($channel_category == 'channel' && is_array($this->getAssocCategories($row->cfg_id))) {
                $edit_status .= null;
            } else {
                $edit_status .= '<a href="#" class="delete">' . $__FM_CONFIG['icons']['delete'] . '</a>';
            }
            $edit_status .= '</td>';
        } else {
            $edit_status = null;
        }
        $edit_name .= $row->cfg_data;
        if ($channel_category == 'category') {
            $channels = null;
            $assoc_channels = $this->getAssocChannels($row->cfg_id);
            foreach ($assoc_channels as $channel) {
                if (is_numeric($channel)) {
                    $channel = getNameFromID($channel, 'fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_', 'cfg_id', 'cfg_data');
                }
                $channels .= "{$channel}, ";
            }
            $channels = rtrim($channels, ', ');
            $channels_row = '<td>' . $channels . '</td>';
        } else {
            $channels_row = null;
        }
        $comments = nl2br($row->cfg_comment);
        echo <<<HTML
\t\t<tr id="{$row->cfg_id}"{$disabled_class}>
\t\t\t<td>{$edit_name}</td>
\t\t\t{$channels_row}
\t\t\t<td>{$comments}</td>
\t\t\t{$edit_status}
\t\t</tr>
HTML;
    }