1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
load_balancer_pool.php
|
6
|
part of pfSense (http://www.pfsense.com/)
|
7
|
|
8
|
Copyright (C) 2005 Bill Marquette <bill.marquette@gmail.com>.
|
9
|
All rights reserved.
|
10
|
|
11
|
Redistribution and use in source and binary forms, with or without
|
12
|
modification, are permitted provided that the following conditions are met:
|
13
|
|
14
|
1. Redistributions of source code must retain the above copyright notice,
|
15
|
this list of conditions and the following disclaimer.
|
16
|
|
17
|
2. Redistributions in binary form must reproduce the above copyright
|
18
|
notice, this list of conditions and the following disclaimer in the
|
19
|
documentation and/or other materials provided with the distribution.
|
20
|
|
21
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
POSSIBILITY OF SUCH DAMAGE.
|
31
|
*/
|
32
|
|
33
|
require("guiconfig.inc");
|
34
|
|
35
|
if (!is_array($config['load_balancer']['lbpool'])) {
|
36
|
$config['load_balancer']['lbpool'] = array();
|
37
|
}
|
38
|
$a_pool = &$config['load_balancer']['lbpool'];
|
39
|
|
40
|
if ($_POST) {
|
41
|
$pconfig = $_POST;
|
42
|
|
43
|
if ($_POST['apply']) {
|
44
|
$retval = 0;
|
45
|
if (!file_exists($d_sysrebootreqd_path)) {
|
46
|
config_lock();
|
47
|
$retval |= filter_configure();
|
48
|
config_unlock();
|
49
|
}
|
50
|
$savemsg = get_std_save_message($retval);
|
51
|
//unlink_if_exists($d_poolconfdirty_path);
|
52
|
}
|
53
|
}
|
54
|
|
55
|
if ($_GET['act'] == "del") {
|
56
|
if ($a_pool[$_GET['id']]) {
|
57
|
/* make sure no virtual servers reference this entry */
|
58
|
if (is_array($config['load_balancer']['virtual_server'])) {
|
59
|
foreach ($config['load_balancer']['virtual_server'] as $vs) {
|
60
|
if ($vs['pool'] == $a_pool[$_GET['id']]['name']) {
|
61
|
$input_errors[] = "This entry cannot be deleted because it is still referenced by at least one virtual server.";
|
62
|
break;
|
63
|
}
|
64
|
}
|
65
|
}
|
66
|
|
67
|
if (!$input_errors) {
|
68
|
unset($a_pool[$_GET['id']]);
|
69
|
write_config();
|
70
|
touch($d_poolconfdirty_path);
|
71
|
header("Location: load_balancer_pool.php");
|
72
|
exit;
|
73
|
}
|
74
|
}
|
75
|
}
|
76
|
|
77
|
$pgtitle = "Load Balancer: Pool";
|
78
|
include("head.inc");
|
79
|
|
80
|
?>
|
81
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
82
|
<?php include("fbegin.inc"); ?>
|
83
|
<p class="pgtitle"><?=$pgtitle?></p>
|
84
|
<form action="load_balancer_pool.php" method="post">
|
85
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
86
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
87
|
<?php if (file_exists($d_vipconfdirty_path)): ?><p>
|
88
|
<?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>
|
89
|
<?php endif; ?>
|
90
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
91
|
<tr><td class="tabnavtbl">
|
92
|
<?php
|
93
|
/* active tabs */
|
94
|
$tab_array = array();
|
95
|
$tab_array[] = array("Pools", true, "load_balancer_pool.php");
|
96
|
$tab_array[] = array("Virtual Servers", false, "load_balancer_virtual_server.php");
|
97
|
display_top_tabs($tab_array);
|
98
|
?>
|
99
|
</td></tr>
|
100
|
<tr>
|
101
|
<td>
|
102
|
<div id="mainarea">
|
103
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
104
|
<tr>
|
105
|
<td width="10%" class="listhdrr">Name</td>
|
106
|
<td width="25%" class="listhdrr">Servers/Gateways</td>
|
107
|
<td width="10%" class="listhdrr">Port</td>
|
108
|
<td width="15%" class="listhdrr">Monitor</td>
|
109
|
<td width="30%" class="listhdr">Description</td>
|
110
|
<td width="10%" class="list"></td>
|
111
|
</tr>
|
112
|
<?php $i = 0; foreach ($a_pool as $vipent): ?>
|
113
|
<tr>
|
114
|
<td class="listlr" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
|
115
|
<?=$vipent['name'];?>
|
116
|
</td>
|
117
|
<td class="listlr" align="center" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
|
118
|
<?php foreach ($vipent['servers'] as $server): ?>
|
119
|
<?=$server;?><br>
|
120
|
<?php endforeach; ?>
|
121
|
</td>
|
122
|
<td class="listlr" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
|
123
|
<?=$vipent['port'];?>
|
124
|
</td>
|
125
|
<td class="listlr" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
|
126
|
<?=$vipent['monitor'];?>
|
127
|
</td>
|
128
|
<td class="listbg" ondblclick="document.location='load_balancer_pool_edit.php?id=<?=$i;?>';">
|
129
|
<font color="#FFFFFF"><?=$vipent['desc'];?></font>
|
130
|
</td>
|
131
|
<td class="list" nowrap>
|
132
|
<table border="0" cellspacing="0" cellpadding="1">
|
133
|
<tr>
|
134
|
<td valign="middle"><a href="load_balancer_pool_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
|
135
|
<td valign="middle"><a href="load_balancer_pool.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
|
136
|
</tr>
|
137
|
</table>
|
138
|
</td>
|
139
|
</tr>
|
140
|
<?php $i++; endforeach; ?>
|
141
|
<tr>
|
142
|
<td class="list" colspan="5"></td>
|
143
|
<td class="list">
|
144
|
<table border="0" cellspacing="0" cellpadding="1">
|
145
|
<tr>
|
146
|
<td valign="middle"><a href="load_balancer_pool_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
|
147
|
</tr>
|
148
|
</table>
|
149
|
</td>
|
150
|
</tr>
|
151
|
</table>
|
152
|
</div>
|
153
|
</table>
|
154
|
</form>
|
155
|
<?php include("fend.inc"); ?>
|
156
|
</body>
|
157
|
</html>
|