示例#1
0
/**
 * Builds the dashboard for display
 *
 * @since 1.0
 * @package facileManager
 * @subpackage fmSQLPass
 */
function buildModuleDashboard()
{
    global $fmdb, $__FM_CONFIG;
    /** Server stats */
    basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_id', 'server_');
    $summary = '<li>You have <b>' . $fmdb->num_rows . '</b> database server';
    if ($fmdb->num_rows != 1) {
        $summary .= 's';
    }
    $summary .= ' configured.</li>' . "\n";
    /** Group stats */
    basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'groups', 'group_id', 'group_');
    $summary .= '<li>You have <b>' . $fmdb->num_rows . '</b> group';
    if ($fmdb->num_rows != 1) {
        $summary .= 's';
    }
    $summary .= ' defined.</li>' . "\n";
    $dashboard = <<<DASH
\t<div class="fm-half">
\t<div id="shadow_box">
\t\t<div id="shadow_container">
\t\t<h3>Summary</h3>
\t\t{$summary}
\t\t</div>
\t</div>
\t</div>
DASH;
    return $dashboard;
}
示例#2
0
 /**
  * Tests server connectivity
  */
 function connectTests()
 {
     global $fmdb, $__FM_CONFIG;
     $return = null;
     /** Get server list */
     $result = basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_name', 'server_');
     if (!$fmdb->num_rows) {
         return __('There are no servers defined.');
     }
     /** Process server list */
     $num_rows = $fmdb->num_rows;
     $results = $fmdb->last_result;
     for ($x = 0; $x < $num_rows; $x++) {
         $return .= sprintf(__("Running tests for %s\n"), $results[$x]->server_name);
         /** ping tests */
         $return .= "\t" . str_pad(__('Ping:'), 15);
         if (pingTest($results[$x]->server_name)) {
             $return .= __('success');
         } else {
             $return .= __('failed');
         }
         $return .= "\n";
         /** SQL tests */
         $return .= "\t" . str_pad($results[$x]->server_type . ':', 15);
         $port = $results[$x]->server_port ? $results[$x]->server_port : $__FM_CONFIG['fmSQLPass']['default']['ports'][$results[$x]->server_type];
         if (socketTest($results[$x]->server_name, $port, 10)) {
             $return .= __('success') . ' (tcp/' . $port . ')';
         } else {
             $return .= __('failed') . ' (tcp/' . $port . ')';
         }
         $return .= "\n\n";
     }
     return $return;
 }
示例#3
0
/**
 * Checks if an email address is valid
 *
 * @since 1.0
 * @package facileManager
 *
 * @param string $address Email address to validate
 * @return boolean
 */
function printfmDNSUsersForm($user_module_perms, $module_name)
{
    global $__FM_CONFIG, $fmdb;
    if (!array_key_exists($module_name, $__FM_CONFIG)) {
        /** Include module variables */
        @(include dirname(__FILE__) . '/variables.inc.php');
    }
    $available_zones_perms = 0;
    if (isSerialized($user_module_perms)) {
        $user_module_perms = unserialize($user_module_perms);
    }
    $available_zones_perms = isset($user_module_perms[$module_name]['access_specific_zones']) ? $user_module_perms[$module_name]['access_specific_zones'] : 0;
    /** Get available zones */
    $available_zones[0][] = 'All Zones';
    $available_zones[0][] = '0';
    basicGetList('fm_' . $__FM_CONFIG[$module_name]['prefix'] . 'domains', 'domain_mapping`,`domain_name', 'domain_', 'AND domain_clone_domain_id=0');
    if ($fmdb->num_rows) {
        $results = $fmdb->last_result;
        for ($i = 0; $i < $fmdb->num_rows; $i++) {
            $available_zones[$i + 1][] = !function_exists('displayFriendlyDomainName') ? $results[$i]->domain_name : displayFriendlyDomainName($results[$i]->domain_name);
            $available_zones[$i + 1][] = $results[$i]->domain_id;
        }
    }
    $zones_list = buildSelect("user_caps[{$module_name}][access_specific_zones]", 1, $available_zones, $available_zones_perms, 5, null, true, null, 'wide_select', __('Select one or more zones'));
    return sprintf('
							<tr class="user_permissions">
								<th></th>
								<td><strong>%s</strong><br />%s</td>
							</tr>
', __('Limit access to the following zones:'), $zones_list);
}
示例#4
0
 /**
  * Generates the server config and updates the firewall server
  *
  * @since 1.0
  * @package fmFirewall
  */
 function buildServerConfig($post_data)
 {
     global $fmdb, $__FM_CONFIG;
     /** Get datetime formatting */
     $date_format = getOption('date_format', $_SESSION['user']['account_id']);
     $time_format = getOption('time_format', $_SESSION['user']['account_id']);
     setTimezone();
     $files = array();
     $server_serial_no = sanitize($post_data['SERIALNO']);
     extract($post_data);
     $data->server_build_all = true;
     basicGet('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', $server_serial_no, 'server_', 'server_serial_no');
     if ($fmdb->num_rows) {
         $server_result = $fmdb->last_result;
         $data = $server_result[0];
         extract(get_object_vars($data), EXTR_SKIP);
         /** Disabled server */
         if ($server_status != 'active') {
             $error = "Server is {$server_status}.\n";
             if ($compress) {
                 echo gzcompress(serialize($error));
             } else {
                 echo serialize($error);
             }
             exit;
         }
         include ABSPATH . 'fm-includes/version.php';
         $config = '# This file was built using ' . $_SESSION['module'] . ' ' . $__FM_CONFIG[$_SESSION['module']]['version'] . ' on ' . date($date_format . ' ' . $time_format . ' e') . "\n\n";
         basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'policies', 'policy_order_id', 'policy_', "AND server_serial_no={$server_serial_no} AND policy_status='active'");
         if ($fmdb->num_rows) {
             $policy_count = $fmdb->num_rows;
             $policy_result = $fmdb->last_result;
             $function = $server_type . 'BuildConfig';
             $config .= $this->{$function}($policy_result, $policy_count);
         }
         $data->files[$server_config_file] = $config;
         if (is_array($files)) {
             $data->files = array_merge($data->files, $files);
         }
         return array(get_object_vars($data), null);
     }
     /** Bad server */
     $error = "Server is not found.\n";
     if ($compress) {
         echo gzcompress(serialize($error));
     } else {
         echo serialize($error);
     }
 }
示例#5
0
            }
            break;
        case 'edit':
            if (!empty($_POST)) {
                $result = $fm_dns_controls->update($_POST);
                if ($result !== true) {
                    $response = $result;
                    $form_data = $_POST;
                } else {
                    setBuildUpdateConfigFlag($server_serial_no, 'yes', 'build');
                    header('Location: ' . $GLOBALS['basename'] . $server_serial_no_uri);
                }
            }
    }
}
printHeader();
@printMenu();
$avail_servers = buildServerSubMenu($server_serial_no);
echo printPageHeader($response, null, currentUserCan('manage_servers', $_SESSION['module']));
echo <<<HTML
<div id="pagination_container" class="submenus">
\t<div>
\t<div class="stretch"></div>
\t{$avail_servers}
\t</div>
</div>

HTML;
$result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'controls', 'control_id', 'control_', "AND server_serial_no='{$server_serial_no}'");
$fm_dns_controls->rows($result);
printFooter();
示例#6
0
 +-------------------------------------------------------------------------+
 | http://www.facilemanager.com/modules/fmdns/                             |
 +-------------------------------------------------------------------------+
 | Processes server keys management page                                   |
 | Author: Jon LaBass                                                      |
 +-------------------------------------------------------------------------+
*/
if (!isset($template_type)) {
    header('Location: ' . $GLOBALS['RELPATH']);
}
$tpl_perms = array('manage_zones', 'view_all');
if (isset($tpl_extra_perm)) {
    $tpl_perms[] = $tpl_extra_perm;
}
if (!currentUserCan($tpl_perms, $_SESSION['module'])) {
    unAuth();
}
include ABSPATH . 'fm-modules/fmDNS/classes/class_templates.php';
$response = isset($response) ? $response : null;
printHeader();
@printMenu();
echo printPageHeader($response, null, currentUserCan('manage_zones', $_SESSION['module']));
$sort_direction = null;
$sort_field = $template_type . '_name';
$table = !isset($table) ? $template_type : $table;
if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) {
    extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
}
$result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . $table, array($sort_field, $template_type . '_name'), $template_type . '_', "AND {$template_type}_template='yes' " . (string) $limited_domain_ids, null, false, $sort_direction);
$fm_module_templates->rows($result, $template_type);
printFooter();
示例#7
0
             $classes = 'wide';
         }
     }
     break;
 case 'dump-cache':
 case 'clear-cache':
     $response = buildPopup('header', __('Cache Management Results'));
     if (!currentUserCan('manage_servers')) {
         $_POST = array();
         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>';
示例#8
0
$avail_types = buildSubMenu($type, $server_serial_no_uri);
$avail_servers = buildServerSubMenu($server_serial_no);
echo printPageHeader($response, getPageTitle() . ' ' . $display_type, currentUserCan('manage_servers', $_SESSION['module']), $type);
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;
$sort_direction = null;
$sort_field = 'cfg_data';
if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) {
    extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
}
$result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', array($sort_field, 'cfg_data'), 'cfg_', 'AND cfg_type="logging" AND cfg_name="' . $channel_category . '" AND server_serial_no="' . $server_serial_no . '"', null, false, $sort_direction);
$fm_module_logging->rows($result, $channel_category);
printFooter();
function buildSubMenu($option_type = 'channel', $server_serial_no_uri = null)
{
    global $__FM_CONFIG;
    $menu_selects = null;
    foreach ($__FM_CONFIG['logging']['avail_types'] as $general => $type) {
        $select = $option_type == $general ? ' class="selected"' : '';
        $menu_selects .= "<span{$select}><a{$select} href=\"{$GLOBALS['basename']}?type={$general}{$server_serial_no_uri}\">{$type}</a></span>\n";
    }
    return '<div id="configtypesmenu">' . $menu_selects . '</div>';
}
示例#9
0
 /**
  * Updates the selected policy
  */
 function update($post)
 {
     global $fmdb, $__FM_CONFIG;
     /** Update sort order */
     if ($post['action'] == 'update_sort') {
         /** Make new order in array */
         $new_sort_order = explode(';', rtrim($post['sort_order'], ';'));
         /** Get policy listing for server */
         basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'policies', 'policy_order_id', 'policy_', 'AND server_serial_no=' . $post['server_serial_no']);
         $count = $fmdb->num_rows;
         $policy_result = $fmdb->last_result;
         for ($i = 0; $i < $count; $i++) {
             $order_id = array_search($policy_result[$i]->policy_id, $new_sort_order);
             if ($order_id === false) {
                 return __('The sort order could not be updated due to an invalid request.');
             }
             $query = "UPDATE `fm_{$__FM_CONFIG[$_SESSION['module']]['prefix']}policies` SET `policy_order_id`={$order_id} WHERE `policy_id`={$policy_result[$i]->policy_id} AND `server_serial_no`={$post['server_serial_no']} AND `account_id`='{$_SESSION['user']['account_id']}'";
             $result = $fmdb->query($query);
             if ($result === false) {
                 return __('Could not update the policy order because a database error occurred.');
             }
         }
         setBuildUpdateConfigFlag($post['server_serial_no'], 'yes', 'build');
         addLogEntry('Updated firewall policy order for ' . getNameFromID($post['server_serial_no'], 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_serial_no', 'server_name'));
         return true;
     }
     /** Validate entries */
     $post = $this->validatePost($post);
     if (!is_array($post)) {
         return $post;
     }
     $exclude = array('submit', 'action', 'policy_id', 'compress', 'AUTHKEY', 'module_name', 'module_type', 'config', 'SERIALNO');
     $sql_edit = null;
     $log_message = "Updated a firewall policy for " . getNameFromID($post['server_serial_no'], 'fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_', 'server_serial_no', 'server_name') . " with the following details:\n";
     foreach ($post as $key => $data) {
         if (!in_array($key, $exclude)) {
             $clean_data = sanitize($data);
             $sql_edit .= $key . "='" . $clean_data . "',";
             if ($clean_data && !in_array($key, array('account_id', 'server_serial_no'))) {
                 if (in_array($key, array('policy_source', 'policy_destination', 'policy_services'))) {
                     $clean_data = str_replace("<br />\n", ', ', $this->formatPolicyIDs($clean_data));
                 }
                 $log_message .= formatLogKeyData('policy_', $key, $clean_data);
             }
         }
     }
     $sql = rtrim($sql_edit, ',');
     /** Update the policy */
     $query = "UPDATE `fm_{$__FM_CONFIG[$_SESSION['module']]['prefix']}policies` SET {$sql} WHERE `policy_id`={$post['policy_id']} AND `account_id`='{$_SESSION['user']['account_id']}'";
     $result = $fmdb->query($query);
     if (!$fmdb->result) {
         return __('Could not update the firewall policy because a database error occurred.');
     }
     /** Return if there are no changes */
     if (!$fmdb->rows_affected) {
         return true;
     }
     setBuildUpdateConfigFlag($post['server_serial_no'], 'yes', 'build');
     addLogEntry($log_message);
     return true;
 }
function buildSQLRecords($record_type, $domain_id)
{
    global $fmdb, $__FM_CONFIG;
    if ($record_type == 'SOA') {
        $soa_query = "SELECT * FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}soa` WHERE `account_id`='{$_SESSION['user']['account_id']}' AND\n\t\t\t`soa_id`=(SELECT `soa_id` FROM `fm_{$__FM_CONFIG['fmDNS']['prefix']}domains` WHERE `domain_id`='{$domain_id}') AND \n\t\t\t`soa_template`='no' AND `soa_status`='active'";
        $fmdb->get_results($soa_query);
        if ($fmdb->num_rows) {
            $result = $fmdb->last_result;
        } else {
            return null;
        }
        foreach (get_object_vars($result[0]) as $key => $val) {
            $sql_results[$result[0]->soa_id][$key] = $val;
        }
        array_shift($sql_results[$result[0]->soa_id]);
        array_shift($sql_results[$result[0]->soa_id]);
        return $sql_results;
    } else {
        $valid_domain_ids = 'IN (' . join(',', getZoneParentID($domain_id)) . ')';
        if (in_array($record_type, array('A', 'AAAA'))) {
            $record_sql = "AND domain_id {$valid_domain_ids} AND record_type IN ('A', 'AAAA')";
        } else {
            $record_sql = "AND domain_id {$valid_domain_ids} AND record_type='{$record_type}'";
        }
        $result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', 'record_name', 'record_', $record_sql);
        if ($result) {
            $results = $fmdb->last_result;
            for ($i = 0; $i < $result; $i++) {
                $static_array = array('record_name', 'record_ttl', 'record_class', 'record_value', 'record_comment', 'record_status');
                $optional_array = array('record_priority', 'record_weight', 'record_port', 'record_os', 'record_cert_type', 'record_key_tag', 'record_algorithm', 'record_flags', 'record_text', 'record_append');
                foreach ($static_array as $field) {
                    $sql_results[$results[$i]->record_id][$field] = $results[$i]->{$field};
                }
                foreach ($optional_array as $field) {
                    if ($results[$i]->{$field} != null) {
                        $sql_results[$results[$i]->record_id][$field] = $results[$i]->{$field};
                    }
                }
                /** Skipped record? */
                basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records_skipped', $results[$i]->record_id, 'record_', 'record_id', "AND domain_id={$domain_id}");
                $sql_results[$results[$i]->record_id]['record_skipped'] = $fmdb->num_rows ? 'on' : 'off';
            }
        }
        return $sql_results;
    }
}
示例#11
0
            if (!is_int($result)) {
                $output .= $result . "\n";
            }
        }
    }
    if (isset($output)) {
        $output = "<pre>{$output}</pre>\n";
    }
    $output .= "<p class=\"complete\">" . _('Complete') . '.</p>';
    echo buildPopup('header', ucwords($_POST['bulk_action']) . ' Results') . $output . buildPopup('footer', _('OK'), array('cancel_button' => 'cancel'), getMenuURL($page));
    /** Handle mass updates */
} elseif (is_array($_POST) && array_key_exists('action', $_POST) && $_POST['action'] == 'process-all-updates') {
    $result = "<pre>\n";
    /** Server config builds */
    if (currentUserCan('build_server_configs', $_SESSION['module'])) {
        basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_id', 'server_', 'AND server_status="active" AND server_installed="yes"');
        $server_count = $fmdb->num_rows;
        $server_results = $fmdb->last_result;
        for ($i = 0; $i < $server_count; $i++) {
            if (isset($server_results[$i]->server_client_version) && $server_results[$i]->server_client_version != getOption('client_version', 0, $_SESSION['module'])) {
                $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)) {
示例#12
0
/**
 * Gets the menu badge counts
 *
 * @since 1.0
 * @package facileManager
 * @subpackage fmFirewall
 *
 * @return boolean
 */
function getModuleBadgeCounts($type)
{
    global $fmdb, $__FM_CONFIG;
    if ($type == 'servers') {
        $badge_counts = null;
        $server_builds = array();
        /** Servers */
        basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_id', 'server_', "AND `server_installed`!='yes' OR (`server_status`='active' AND `server_build_config`='yes')");
        $server_count = $fmdb->num_rows;
        $server_results = $fmdb->last_result;
        for ($i = 0; $i < $server_count; $i++) {
            $server_builds[] = $server_results[$i]->server_name;
        }
        if (version_compare(getOption('version', 0, $_SESSION['module']), '1.0-b3', '>=')) {
            basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_id', 'server_', "AND `server_client_version`!='" . getOption($_SESSION['module'] . '_client_version') . "'");
            $server_count = $fmdb->num_rows;
            $server_results = $fmdb->last_result;
            for ($i = 0; $i < $server_count; $i++) {
                $server_builds[] = $server_results[$i]->server_name;
            }
        }
        $servers = array_unique($server_builds);
        $badge_counts = count($servers);
        unset($server_builds, $servers, $server_count, $server_results);
    }
    return $badge_counts;
}
示例#13
0
 /**
  * Tests server connectivity
  */
 function connectTests()
 {
     global $fmdb, $__FM_CONFIG;
     $return = null;
     /** Load ssh key for use */
     $ssh_key = getOption('ssh_key_priv', $_SESSION['user']['account_id']);
     $temp_ssh_key = sys_get_temp_dir() . '/fm_id_rsa';
     if ($ssh_key) {
         if (file_exists($temp_ssh_key)) {
             @unlink($temp_ssh_key);
         }
         $ssh_key_loaded = @file_put_contents($temp_ssh_key, $ssh_key);
         @chmod($temp_ssh_key, 0400);
     }
     $ssh_user = getOption('ssh_user', $_SESSION['user']['account_id']);
     /** Get server list */
     $result = basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'servers', 'server_name', 'server_');
     /** Process server list */
     $num_rows = $fmdb->num_rows;
     $results = $fmdb->last_result;
     for ($x = 0; $x < $num_rows; $x++) {
         $return .= sprintf(__("Running tests for %s\n"), $results[$x]->server_name);
         /** ping tests */
         $return .= "\t" . str_pad(__('Ping:'), 15);
         if (pingTest($results[$x]->server_name)) {
             $return .= __('success');
         } else {
             $return .= __('failed');
         }
         $return .= "\n";
         /** remote port tests */
         $return .= "\t" . str_pad(__('Remote Port:'), 15);
         if ($results[$x]->server_update_method != 'cron') {
             if (socketTest($results[$x]->server_name, $results[$x]->server_update_port, 10)) {
                 $return .= __('success') . ' (tcp/' . $results[$x]->server_update_port . ")\n";
                 if ($results[$x]->server_update_method == 'ssh') {
                     $return .= "\t" . str_pad(__('SSH Login:'******'no SSH key defined');
                     } elseif ($ssh_key_loaded === false) {
                         $return .= sprintf(__('could not load SSH key into %s'), $temp_ssh_key);
                     } elseif (!$ssh_user) {
                         $return .= __('no SSH user defined');
                     } else {
                         exec(findProgram('ssh') . " -t -i {$temp_ssh_key} -o 'StrictHostKeyChecking no' -p {$results[$x]->server_update_port} -l {$ssh_user} {$results[$x]->server_name} uptime", $post_result, $retval);
                         if ($retval) {
                             $return .= __('ssh key login failed');
                         } else {
                             $return .= __('success');
                         }
                     }
                 } else {
                     /** php tests */
                     $return .= "\t" . str_pad(__('http page:'), 15);
                     $php_result = getPostData($results[$x]->server_update_method . '://' . $results[$x]->server_name . '/' . $_SESSION['module'] . '/reload.php', null);
                     if ($php_result == 'Incorrect parameters defined.') {
                         $return .= __('success');
                     } else {
                         $return .= __('failed');
                     }
                 }
             } else {
                 $return .= __('failed') . ' (tcp/' . $results[$x]->server_update_port . ')';
             }
         } else {
             $return .= __('skipping (host updates via cron)');
         }
         $return .= "\n";
         /** dns tests */
         $return .= "\t" . str_pad(__('DNS:'), 15);
         $port = 53;
         if (socketTest($results[$x]->server_name, $port, 10)) {
             $return .= __('success') . ' (tcp/' . $port . ')';
         } else {
             $return .= __('failed') . ' (tcp/' . $port . ')';
         }
         $return .= "\n";
         $return .= "\n";
     }
     @unlink($temp_ssh_key);
     return $return;
 }
示例#14
0
if (currentUserCan('manage_servers', $_SESSION['module'])) {
    switch ($action) {
        case 'add':
            if (!empty($_POST)) {
                $result = $fm_module_servers->add($_POST);
                if ($result !== true) {
                    $response = $result;
                    $form_data = $_POST;
                } else {
                    header('Location: ' . $GLOBALS['basename']);
                }
            }
            break;
        case 'edit':
            if (!empty($_POST)) {
                $result = $fm_module_servers->update($_POST);
                if ($result !== true) {
                    $response = $result;
                    $form_data = $_POST;
                } else {
                    header('Location: ' . $GLOBALS['basename']);
                }
            }
    }
}
printHeader();
@printMenu();
echo printPageHeader($response, null, currentUserCan('manage_servers', $_SESSION['module']));
$result = basicGetList('fm_' . $__FM_CONFIG['fmSQLPass']['prefix'] . 'servers', 'server_name', 'server_');
$fm_module_servers->rows($result);
printFooter();
示例#15
0
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);
$fm_users->rows($result, $type);
printFooter();
function buildSubMenu($option_type = 'users')
{
    global $__FM_CONFIG;
    $menu_selects = $uri_params = null;
    foreach ($GLOBALS['URI'] as $param => $val) {
        if (in_array($param, array('type', 'action', 'id', 'status'))) {
            continue;
        }
        $uri_params .= "&{$param}={$val}";
    }
    foreach ($__FM_CONFIG['users']['avail_types'] as $general => $type) {
        $select = $option_type == $general ? ' class="selected"' : '';
        $menu_selects .= "<span{$select}><a{$select} href=\"{$GLOBALS['basename']}?type={$general}{$uri_params}\">" . ucfirst($type) . "</a></span>\n";
示例#16
0
$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')
{
    global $__FM_CONFIG;
    $menu_selects = $uri_params = null;
    foreach ($GLOBALS['URI'] as $param => $val) {
        if ($param == 'domain_id') {
            return null;
        }
        if ($param == 'option_type') {
            continue;
        }
        $uri_params .= "&{$param}={$val}";
    }
示例#17
0
 /**
  * Builds an array of available zone children
  *
  * @since 2.0
  * @package facileManager
  * @subpackage fmDNS
  *
  * @param int $domain_id Domain ID to get children
  * @return array
  */
 function getZoneCloneChildren($domain_id)
 {
     global $fmdb, $__FM_CONFIG;
     $children = array($domain_id);
     basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'domains', 'domain_id', 'domain_', 'AND domain_clone_domain_id=' . $domain_id);
     if ($fmdb->num_rows) {
         for ($x = 0; $x < $fmdb->num_rows; $x++) {
             $children[] = $fmdb->last_result[$x]->domain_id;
         }
     }
     return $children;
 }
示例#18
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();
示例#19
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();
示例#20
0
    }
}
printHeader();
@printMenu();
$avail_types = buildSubMenu($type, $server_serial_no);
$response = $form_data = $action = null;
echo printPageHeader($response, null, currentUserCan('manage_servers', $_SESSION['module']), $type);
/*
echo <<<HTML
<div id="pagination_container" class="submenus">
	<div>
	<div class="stretch"></div>
	$avail_types
	</div>
</div>

HTML;
*/
$result = basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'policies', 'policy_order_id', 'policy_', "AND server_serial_no={$server_serial_no} AND policy_type='{$type}'");
$fm_module_policies->rows($result, $type);
printFooter();
function buildSubMenu($option_type = 'policy', $server_serial_no = null)
{
    global $__FM_CONFIG;
    $menu_selects = null;
    foreach ($__FM_CONFIG['policy']['avail_types'] as $general => $type) {
        $select = $option_type == $general ? ' class="selected"' : '';
        $menu_selects .= "<span{$select}><a{$select} href=\"config-policy?type={$general}&server_serial_no={$server_serial_no}\">" . ucfirst($type) . "</a></span>\n";
    }
    return '<div id="configtypesmenu">' . $menu_selects . '</div>';
}
示例#21
0
 function availableViews()
 {
     global $fmdb, $__FM_CONFIG;
     $return[0][] = 'None';
     $return[0][] = '0';
     $result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'views', 'view_id', 'view_');
     if ($fmdb->num_rows) {
         $results = $fmdb->last_result;
         for ($i = 0; $i < $fmdb->num_rows; $i++) {
             $return[$i + 1][] = $results[$i]->view_name;
             $return[$i + 1][] = $results[$i]->view_id;
         }
     }
     return $return;
 }
示例#22
0
 | 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();
function checkPTRZone($ip, $domain_id)
{
    global $fmdb, $__FM_CONFIG;
    $octet = explode('.', $ip);
    $zone = "'{$octet[2]}.{$octet[1]}.{$octet[0]}.in-addr.arpa', '{$octet[1]}.{$octet[0]}.in-addr.arpa', '{$octet[0]}.in-addr.arpa'";
    basicGet('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', $zone, 'domain_', 'domain_name', "OR domain_name IN ({$zone}) AND domain_status!='deleted'");
    if ($fmdb->num_rows) {
        $result = $fmdb->last_result;
        return array($result[0]->domain_id, null);
    } else {
        basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', 'domain_name', 'domain_', "AND domain_mapping='reverse' AND domain_name LIKE '%-%-%'");
        if ($fmdb->num_rows) {
            for ($i = 0; $i < $fmdb->num_rows; $i++) {
                $domain_name = $fmdb->last_result[$i]->domain_name;
                $range = array();
                foreach (array_reverse(explode('.', $domain_name)) as $key => $tmp_octect) {
                    if (in_array($key, array(0, 1))) {
                        continue;
                    }
                    if (strpos($tmp_octect, '-') !== false) {
                        list($start, $end) = explode('-', $tmp_octect);
                        $range['start'][] = $start;
                        $range['end'][] = $end;
                    } else {
                        $range['start'][] = $tmp_octect;
                        $range['end'][] = $tmp_octect;
                    }
                }
                $range['start'] = array_pad($range['start'], 4, 0);
                $range['end'] = array_pad($range['end'], 4, 255);
                if (ip2long(join('.', $range['start'])) <= ip2long($ip) && ip2long(join('.', $range['end'])) >= ip2long($ip)) {
                    return array($fmdb->last_result[$i]->domain_id, null);
                }
            }
        }
    }
    /** No match so auto create if allowed */
    if (getOption('auto_create_ptr_zones', $_SESSION['user']['account_id'], $_SESSION['module']) == 'yes') {
        return autoCreatePTRZone($zone, $domain_id);
    }
    return array(null, __('Reverse zone does not exist.'));
}
示例#24
0
            $sort_field = 'record_name';
            $ip_sort = false;
            break;
    }
    $record_sql = "AND domain_id IN (" . join(',', $parent_domain_ids) . ") AND record_type='{$record_type}'";
    $sort_direction = null;
    if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) {
        extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
    }
    if (in_array($record_type, array('A', 'AAAA')) && $sort_field == 'record_value') {
        $ip_sort = true;
    }
    if (isset($search_query)) {
        $record_sql .= $search_query;
    }
    $result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'records', array($sort_field, 'record_name'), 'record_', $record_sql, null, $ip_sort, $sort_direction);
    $total_pages = ceil($fmdb->num_rows / $_SESSION['user']['record_count']);
    if ($page > $total_pages) {
        $page = $total_pages;
    }
    $pagination = displayPagination($page, $total_pages);
    $body .= $pagination . '<div class="overflow-container">' . $form;
    $record_rows = $fm_dns_records->rows($result, $record_type, $domain_id, $page);
    if (currentUserCan('manage_records', $_SESSION['module']) && $zone_access_allowed) {
        $body .= '<div class="existing-container">' . $record_rows;
        $body .= sprintf('</div><div class="new-container">
	<a name="#manage"></a>
	<h2>%s</h2>
	%s
	<p><input type="submit" name="submit" value="%s" class="button" /></p>
</form></div>' . "\n", __('Add Record'), $fm_dns_records->printRecordsForm($form_data, $action, $record_type, $domain_id), __('Validate'));
示例#25
0
/** 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) {
        $domain_view_sql = 'AND (' . rtrim($domain_view_sql, ' OR') . ')';
    }
}
$result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'domains', array($sort_field, 'domain_name'), 'domain_', "AND domain_template='no' AND domain_mapping='{$map}' AND domain_clone_domain_id='0' {$limited_domain_ids} " . (string) $domain_view_sql . (string) $search_query, null, false, $sort_direction);
$total_pages = ceil($fmdb->num_rows / $_SESSION['user']['record_count']);
if ($page > $total_pages) {
    $page = $total_pages;
}
$fm_dns_zones->rows($result, $map, $reload_allowed, $page, $total_pages);
printFooter();
示例#26
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;
    }
示例#27
0
 /**
  * Attempts to resolve the master servers for the group
  *
  * @since 2.1
  * @package fmDNS
  *
  * @param integer $view_id The view_id of the zone
  * @param integer $server_serial_no The server serial number for overrides
  * @param array   $server_group_ids The array containing server group IDs for overrides
  * @return array
  */
 function getIncludeFiles($view_id, $server_serial_no, $server_group_ids = null)
 {
     global $fmdb, $__FM_CONFIG;
     if (is_array($server_group_ids)) {
         $server_group_ids = 'g_' . implode('","g_', $server_group_ids);
     }
     basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'config', 'cfg_id', 'cfg_', 'AND cfg_type="global" AND cfg_name="include" AND view_id=' . $view_id . ' AND domain_id=0 AND server_serial_no IN ("0", "' . $server_serial_no . '", "' . $server_group_ids . '") AND cfg_status="active"');
     if ($fmdb->num_rows) {
         $config_result = $fmdb->last_result;
         for ($i = 0; $i < $fmdb->num_rows; $i++) {
             $include_config['include'][] = array($config_result[$i]->cfg_data, $config_result[$i]->cfg_comment);
         }
     } else {
         $include_config = null;
     }
     if (is_array($include_config)) {
         $include_files = null;
         foreach ($include_config as $cfg_name => $value_array) {
             foreach ($value_array as $domain_name => $cfg_data) {
                 list($cfg_info, $cfg_comment) = $cfg_data;
                 $include_files .= $this->formatConfigOption($cfg_name, $cfg_info, $cfg_comment, "\t");
             }
         }
         return $include_files;
     } else {
         return null;
     }
 }
示例#28
0
                if ($result !== true) {
                    $response = $result;
                    $form_data = $_POST;
                } else {
                    setBuildUpdateConfigFlag($server_serial_no, 'yes', 'build');
                    header('Location: ' . $GLOBALS['basename'] . $server_serial_no_uri);
                }
            }
    }
}
printHeader();
@printMenu();
$avail_servers = buildServerSubMenu($server_serial_no);
echo printPageHeader($response, null, currentUserCan('manage_servers', $_SESSION['module']));
echo <<<HTML
<div id="pagination_container" class="submenus">
\t<div>
\t<div class="stretch"></div>
\t{$avail_servers}
\t</div>
</div>

HTML;
$sort_direction = null;
$sort_field = 'acl_name';
if (isset($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']])) {
    extract($_SESSION[$_SESSION['module']][$GLOBALS['path_parts']['filename']], EXTR_OVERWRITE);
}
$result = basicGetList('fm_' . $__FM_CONFIG['fmDNS']['prefix'] . 'acls', array($sort_field, 'acl_name'), 'acl_', "AND server_serial_no='{$server_serial_no}'", null, false, $sort_direction);
$fm_dns_acls->rows($result);
printFooter();
示例#29
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;
}
示例#30
0
        case 'add':
            if (!empty($_POST)) {
                $result = $fm_module_objects->add($_POST);
                if ($result !== true) {
                    $response = $result;
                    $form_data = $_POST;
                } else {
                    header('Location: ' . $GLOBALS['basename'] . '?type=' . $_POST['object_type']);
                }
            }
            break;
        case 'edit':
            if (!empty($_POST)) {
                $result = $fm_module_objects->update($_POST);
                if ($result !== true) {
                    $response = $result;
                    $form_data = $_POST;
                } else {
                    header('Location: ' . $GLOBALS['basename'] . '?type=' . $_POST['object_type']);
                }
            }
            break;
    }
}
printHeader();
@printMenu();
//$allowed_to_add = ($type == 'custom' && currentUserCan('manage_objects', $_SESSION['module'])) ? true : false;
echo printPageHeader($response, null, currentUserCan('manage_objects', $_SESSION['module']), $type);
$result = basicGetList('fm_' . $__FM_CONFIG[$_SESSION['module']]['prefix'] . 'objects', 'object_name', 'object_', "AND object_type='{$type}'");
$fm_module_objects->rows($result, $type);
printFooter();