Project

General

Profile

Download (4.72 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
	part of pfSense (http://www.pfsense.com/)
6
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
	if ($a_pool[$_GET['id']]) {
68
		/* 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
				if ($vs['pool'] == $a_pool[$_GET['id']]['name']) {
72
					$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one virtual server.";
73
					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 f20f9461 Ermal Luçi
$pgtitle = array("Services", "Load Balancer","Pool");
98 477dcf13 Chris Buechler
#$statusurl = "status_lb_vs.php";
99
$statusurl = "status_lb_pool.php";
100 e234921a jim-p
$logurl = "diag_logs_relayd.php";
101
102 94ac0ffc Bill Marquette
include("head.inc");
103
104
?>
105
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
106
<?php include("fbegin.inc"); ?>
107
<form action="load_balancer_pool.php" method="post">
108
<?php if ($input_errors) print_input_errors($input_errors); ?>
109
<?php if ($savemsg) print_info_box($savemsg); ?>
110 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('loadbalancer')): ?><p>
111 94ac0ffc Bill Marquette
<?php print_info_box_np("The load balancer configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
112
<?php endif; ?>
113
<table width="100%" border="0" cellpadding="0" cellspacing="0">
114
  <tr><td class="tabnavtbl">
115
  <?php
116
        /* active tabs */
117
        $tab_array = array();
118 c47d0c30 Scott Ullrich
        $tab_array[] = array("Monitors", false, "load_balancer_monitor.php");
119 94ac0ffc Bill Marquette
        $tab_array[] = array("Pools", true, "load_balancer_pool.php");
120
        $tab_array[] = array("Virtual Servers", false, "load_balancer_virtual_server.php");
121
        display_top_tabs($tab_array);
122
  ?>
123
  </td></tr>
124
  <tr>
125
    <td>
126
	<div id="mainarea">
127 50d86c13 Bill Marquette
<?
128
			$t = new MainTable();
129
			$t->edit_uri('load_balancer_pool_edit.php');
130
			$t->my_uri('load_balancer_pool.php');
131
			$t->add_column('Name','name',10);
132
			$t->add_column('Servers','servers',15);
133
			$t->add_column('Port','port',10);
134
			$t->add_column('Monitor','monitor',15);
135
			$t->add_column('Description','desc',30);
136
			$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
</table>
147
</form>
148 94ac0ffc Bill Marquette
<?php include("fend.inc"); ?>
149
</body>
150
</html>