Projet

Général

Profil

Télécharger (7,86 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / system_routes.php @ 7e736f38

1
<?php
2
/* $Id$ */
3
/*
4
	system_routes.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	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
/*
32
	pfSense_MODULE:	routing
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-system-staticroutes
37
##|*NAME=System: Static Routes page
38
##|*DESCR=Allow access to the 'System: Static Routes' page.
39
##|*MATCH=system_routes.php*
40
##|-PRIV
41

    
42
require("guiconfig.inc");
43
require_once("functions.inc");
44
require_once("filter.inc");
45
require_once("shaper.inc");
46

    
47
if (!is_array($config['staticroutes']['route']))
48
	$config['staticroutes']['route'] = array();
49

    
50
$a_routes = &$config['staticroutes']['route'];
51
$a_gateways = return_gateways_array(true, true);
52
$changedesc = gettext("Static Routes") . ": ";
53

    
54
if ($_POST) {
55

    
56
	$pconfig = $_POST;
57

    
58
	if ($_POST['apply']) {
59

    
60
		$retval = 0;
61

    
62
		if (file_exists("{$g['tmp_path']}/.system_routes.apply")) {
63
			$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.system_routes.apply"));
64
			foreach ($toapplylist as $toapply)
65
				mwexec("{$toapply}");
66

    
67
			@unlink("{$g['tmp_path']}/.system_routes.apply");
68
		}
69

    
70
		$retval = system_routing_configure();
71
		$retval |= filter_configure();
72
		/* reconfigure our gateway monitor */
73
		setup_gateways_monitor();
74

    
75
		$savemsg = get_std_save_message($retval);
76
		if ($retval == 0)
77
			clear_subsystem_dirty('staticroutes');
78
	}
79
}
80

    
81
if ($_GET['act'] == "del") {
82
	if ($a_routes[$_GET['id']]) {
83
		$changedesc .= gettext("removed route to") . " " . $a_routes[$_GET['id']]['network'];
84

    
85
		$targets = array();
86
		if (is_alias($a_routes[$_GET['id']]['network'])) {
87
			foreach (filter_expand_alias_array($a_routes[$_GET['id']]['network']) as $tgt) {
88
				if (is_ipaddrv4($tgt))
89
					$tgt .= "/32";
90
				else if (is_ipaddrv6($tgt))
91
					$tgt .= "/128";
92
				if (!is_subnet($tgt))
93
					continue;
94
				$targets[] = $tgt;
95
			}
96
		} else {
97
			$targets[] = $a_routes[$_GET['id']]['network'];
98
		}
99

    
100
		foreach ($targets as $tgt) {
101
			$family = (is_subnetv6($tgt) ? "-inet6" : "-inet");
102
			mwexec("/sbin/route delete {$family} " . escapeshellarg($tgt));
103
		}
104

    
105
		unset($a_routes[$_GET['id']]);
106
		unset($targets);
107
		write_config($changedesc);
108
		header("Location: system_routes.php");
109
		exit;
110
	}
111
}
112

    
113
$pgtitle = array(gettext("System"),gettext("Static Routes"));
114
$shortcut_section = "routing";
115

    
116
include("head.inc");
117

    
118
?>
119

    
120
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
121
<?php include("fbegin.inc"); ?>
122
<form action="system_routes.php" method="post">
123
<input type="hidden" name="y1" value="1" />
124
<?php if ($savemsg) print_info_box($savemsg); ?>
125
<?php if (is_subsystem_dirty('staticroutes')): ?><p>
126
<?php print_info_box_np(sprintf(gettext("The static route configuration has been changed.%sYou must apply the changes in order for them to take effect."), "<br/>"));?><br/></p>
127
<?php endif; ?>
128

    
129
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="system routes">
130
	<tr>
131
		<td>
132
		<?php
133
			$tab_array = array();
134
			$tab_array[0] = array(gettext("Gateways"), false, "system_gateways.php");
135
			$tab_array[1] = array(gettext("Routes"), true, "system_routes.php");
136
			$tab_array[2] = array(gettext("Groups"), false, "system_gateway_groups.php");
137
			display_top_tabs($tab_array);
138
		?>
139
		</td>
140
	</tr>
141
	<tr>
142
		<td>
143
			<div id="mainarea">
144
				<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area">
145
					<tr>
146
						<td width="25%" class="listhdrr"><?=gettext("Network");?></td>
147
						<td width="20%" class="listhdrr"><?=gettext("Gateway");?></td>
148
						<td width="15%" class="listhdrr"><?=gettext("Interface");?></td>
149
						<td width="30%" class="listhdr"><?=gettext("Description");?></td>
150
						<td width="10%" class="list">
151
							<table border="0" cellspacing="0" cellpadding="1" summary="add">
152
								<tr>
153
									<td width="17"></td>
154
									<td><a href="system_routes_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a></td>
155
								</tr>
156
							</table>
157
						</td>
158
					</tr>
159
					<?php $i = 0; foreach ($a_routes as $route): ?>
160
					<tr>
161
					<?php
162
						if (isset($route['disabled'])) {
163
							$textss = "<span class=\"gray\">";
164
							$textse = "</span>";
165
						} else
166
						$textss = $textse = "";
167
					?>
168
						<td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
169
							<?=$textss;?><?=strtolower($route['network']);?><?=$textse;?>
170
						</td>
171
						<td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
172
							<?=$textss;?>
173
							<?php
174
								echo htmlentities($a_gateways[$route['gateway']]['name']) . " - " . htmlentities($a_gateways[$route['gateway']]['gateway']);
175
							?>
176
							<?=$textse;?>
177
						</td>
178
						<td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
179
							<?=$textss;?>
180
							<?php
181
								echo convert_friendly_interface_to_friendly_descr($a_gateways[$route['gateway']]['friendlyiface']) . " ";
182
							?>
183
							<?=$textse;?>
184
						</td>
185
						<td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
186
							<?=$textss;?><?=htmlspecialchars($route['descr']);?>&nbsp;<?=$textse;?>
187
						</td>
188
						<td valign="middle" class="list nowrap">
189
							<table border="0" cellspacing="0" cellpadding="1" summary="edit">
190
								<tr>
191
									<td><a href="system_routes_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" alt="edit" /></a>
192
									<td><a href="system_routes.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this route?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="delete" /></a></td>
193
								</tr>
194
								<tr>
195
									<td width="17"></td>
196
									<td><a href="system_routes_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="add" /></a></td>
197
								</tr>
198
							</table>
199
						</td>
200
					</tr>
201
					<?php $i++; endforeach; ?>
202
					<tr>
203
						<td class="list" colspan="4"></td>
204
						<td class="list">
205
							<table border="0" cellspacing="0" cellpadding="1" summary="edit">
206
								<tr>
207
									<td width="17"></td>
208
									<td><a href="system_routes_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="edit" /></a></td>
209
								</tr>
210
							</table>
211
						</td>
212
					</tr>
213
				</table>
214
			</div>
215
		</td>
216
	</tr>
217
</table>
218
</form>
219
<p><b><?=gettext("Note:");?></b>  <?=gettext("Do not enter static routes for networks assigned on any interface of this firewall.  Static routes are only used for networks reachable via a different router, and not reachable via your default gateway.");?></p>
220
<?php include("fend.inc"); ?>
221
</body>
222
</html>
(218-218/246)