Project

General

Profile

Download (5.27 KB) Statistics
| Branch: | Tag: | Revision:
1 94ac0ffc Bill Marquette
<?php
2 577c9191 Bill Marquette
/* $Id$ */
3 94ac0ffc Bill Marquette
/*
4
	load_balancer_pool.php
5 d1ec51ba Chris Buechler
	part of pfSense (https://www.pfsense.org/)
6 94ac0ffc Bill Marquette
7 50d86c13 Bill Marquette
	Copyright (C) 2005-2008 Bill Marquette <bill.marquette@gmail.com>.
8 94ac0ffc Bill Marquette
	All rights reserved.
9
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31 7ac5a4cb Scott Ullrich
/*
32
	pfSense_MODULE:	routing
33
*/
34 94ac0ffc Bill Marquette
35 6b07c15a Matthew Grooms
##|+PRIV
36
##|*IDENT=page-loadbalancer-pool
37
##|*NAME=Load Balancer: Pool page
38
##|*DESCR=Allow access to the 'Load Balancer: Pool' page.
39
##|*MATCH=load_balancer_pool.php*
40
##|-PRIV
41
42 3327ac10 Ermal
require_once("guiconfig.inc");
43 7a927e67 Scott Ullrich
require_once("functions.inc");
44
require_once("filter.inc");
45
require_once("shaper.inc");
46 94ac0ffc Bill Marquette
47 a9c6f68a Bill Marquette
if (!is_array($config['load_balancer']['lbpool'])) {
48
	$config['load_balancer']['lbpool'] = array();
49 94ac0ffc Bill Marquette
}
50 a9c6f68a Bill Marquette
$a_pool = &$config['load_balancer']['lbpool'];
51 94ac0ffc Bill Marquette
52 50d86c13 Bill Marquette
53 94ac0ffc Bill Marquette
if ($_POST) {
54
	$pconfig = $_POST;
55
56
	if ($_POST['apply']) {
57
		$retval = 0;
58 920b3bb0 Scott Ullrich
		$retval |= filter_configure();
59 17623ab5 Bill Marquette
		$retval |= relayd_configure();
60 920b3bb0 Scott Ullrich
61 94ac0ffc Bill Marquette
		$savemsg = get_std_save_message($retval);
62 a368a026 Ermal Lu?i
		clear_subsystem_dirty('loadbalancer');
63 94ac0ffc Bill Marquette
	}
64
}
65
66
if ($_GET['act'] == "del") {
67 3b15c32c jim-p
	if (array_key_exists($_GET['id'], $a_pool)) {
68 94ac0ffc Bill Marquette
		/* make sure no virtual servers reference this entry */
69
		if (is_array($config['load_balancer']['virtual_server'])) {
70
			foreach ($config['load_balancer']['virtual_server'] as $vs) {
71 6e9b046e jim-p
				if ($vs['poolname'] == $a_pool[$_GET['id']]['name']) {
72 019db2a3 Carlos Eduardo Ramos
					$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one virtual server.");
73 94ac0ffc Bill Marquette
					break;
74
				}
75
			}
76
		}
77
78
		if (!$input_errors) {
79
			unset($a_pool[$_GET['id']]);
80
			write_config();
81 a368a026 Ermal Lu?i
			mark_subsystem_dirty('loadbalancer');
82 94ac0ffc Bill Marquette
			header("Location: load_balancer_pool.php");
83
			exit;
84
		}
85
	}
86
}
87
88 50d86c13 Bill Marquette
/* Index monitor_type array for easy hyperlinking */
89
$mondex = array();
90
for ($i = 0; isset($config['load_balancer']['monitor_type'][$i]); $i++) {
91
	$mondex[$config['load_balancer']['monitor_type'][$i]['name']] = $i;
92
}
93
for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) {
94
	$a_pool[$i]['monitor'] = "<a href=\"/load_balancer_monitor_edit.php?id={$mondex[$a_pool[$i]['monitor']]}\">{$a_pool[$i]['monitor']}</a>";
95
}
96
97 019db2a3 Carlos Eduardo Ramos
$pgtitle = array(gettext("Services"), gettext("Load Balancer"),gettext("Pool"));
98 b32dd0a6 jim-p
$shortcut_section = "relayd";
99 e234921a jim-p
100 94ac0ffc Bill Marquette
include("head.inc");
101
102
?>
103
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
104
<?php include("fbegin.inc"); ?>
105
<form action="load_balancer_pool.php" method="post">
106
<?php if ($input_errors) print_input_errors($input_errors); ?>
107
<?php if ($savemsg) print_info_box($savemsg); ?>
108 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('loadbalancer')): ?><p>
109 902f86b9 Carlos Eduardo Ramos
<?php print_info_box_np(sprintf(gettext("The load balancer configuration has been changed%sYou must apply the changes in order for them to take effect."), "<br>"));?><br>
110 94ac0ffc Bill Marquette
<?php endif; ?>
111
<table width="100%" border="0" cellpadding="0" cellspacing="0">
112
  <tr><td class="tabnavtbl">
113
  <?php
114
        /* active tabs */
115
        $tab_array = array();
116 019db2a3 Carlos Eduardo Ramos
        $tab_array[] = array(gettext("Pools"), true, "load_balancer_pool.php");
117
        $tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php");
118 3e2165b6 jim-p
        $tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php");
119 259f606e Pierre POMES
        $tab_array[] = array(gettext("Settings"), false, "load_balancer_setting.php");
120 94ac0ffc Bill Marquette
        display_top_tabs($tab_array);
121
  ?>
122
  </td></tr>
123
  <tr>
124
    <td>
125
	<div id="mainarea">
126 50d86c13 Bill Marquette
<?
127
			$t = new MainTable();
128
			$t->edit_uri('load_balancer_pool_edit.php');
129
			$t->my_uri('load_balancer_pool.php');
130 d5bcf950 Carlos Eduardo Ramos
			$t->add_column(gettext('Name'),'name',10);
131 e0c27075 jim-p
			$t->add_column(gettext('Mode'),'mode',10);
132 d5bcf950 Carlos Eduardo Ramos
			$t->add_column(gettext('Servers'),'servers',15);
133
			$t->add_column(gettext('Port'),'port',10);
134 e0c27075 jim-p
			$t->add_column(gettext('Monitor'),'monitor',10);
135 e988813d jim-p
			$t->add_column(gettext('Description'),'descr',25);
136 50d86c13 Bill Marquette
			$t->add_button('edit');
137
			$t->add_button('dup');
138
			$t->add_button('del');
139
			$t->add_content_array($a_pool);
140
			$t->display();
141
?>
142
143
	</div>
144
    </td>
145
  </tr>
146 d89fdda0 jim-p
  <tr><td>
147
	<br/><span class="red"><strong><?=gettext("Hint:");?></strong></span><br/>
148
	<?= sprintf(gettext("The Load Balancer in %s 2.0 is for server load balancing, not Multi-WAN. For load balancing or failover for multiple WANs, use "), $g['product_name']);?>
149
	<a href="/system_gateway_groups.php"><?= gettext("Gateway Groups"); ?></a>
150
  </td></tr>
151 50d86c13 Bill Marquette
</table>
152
</form>
153 94ac0ffc Bill Marquette
<?php include("fend.inc"); ?>
154
</body>
155
</html>