Project

General

Profile

Download (8.21 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 5b237745 Scott Ullrich
/*
4
	system_routes.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6 8450bc24 Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 8450bc24 Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 8450bc24 Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 8450bc24 Scott Ullrich
16 5b237745 Scott Ullrich
	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 8450bc24 Scott Ullrich
20 5b237745 Scott Ullrich
	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 1d333258 Scott Ullrich
/*
32
	pfSense_MODULE:	routing
33
*/
34 5b237745 Scott Ullrich
35 6b07c15a Matthew Grooms
##|+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 5b237745 Scott Ullrich
require("guiconfig.inc");
43 7a927e67 Scott Ullrich
require_once("functions.inc");
44
require_once("filter.inc");
45
require_once("shaper.inc");
46 5b237745 Scott Ullrich
47
if (!is_array($config['staticroutes']['route']))
48
	$config['staticroutes']['route'] = array();
49
50
$a_routes = &$config['staticroutes']['route'];
51 a529aced Ermal
$a_gateways = return_gateways_array(true);
52 79eaddf4 Renato Botelho
$changedesc = gettext("Static Routes") . ": ";
53 5b237745 Scott Ullrich
54
if ($_POST) {
55
56
	$pconfig = $_POST;
57
58
	if ($_POST['apply']) {
59 691dade5 Scott Ullrich
60 5b237745 Scott Ullrich
		$retval = 0;
61 3851094f Scott Ullrich
62 e8471084 Ermal
		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 3851094f Scott Ullrich
		$retval = system_routing_configure();
71
		$retval |= filter_configure();
72 13bbe450 Seth Mos
		/* reconfigure our gateway monitor */
73
		setup_gateways_monitor();
74 3851094f Scott Ullrich
75 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
76 a368a026 Ermal Lu?i
		if ($retval == 0)
77
			clear_subsystem_dirty('staticroutes');
78 2b87adae Bill Marquette
	} else {
79
		if ($_POST['enablefastrouting'] == "") {
80
			/* Only update config if something changed */
81
			if (isset($config['staticroutes']['enablefastrouting'])) {
82 40fb81a1 Carlos Eduardo Ramos
				$changedesc .= " " . gettext("disable fast routing");
83 2b87adae Bill Marquette
				unset($config['staticroutes']['enablefastrouting']);
84
				write_config($changedesc);
85
			}
86
		} else {
87
			/* Only update config if something changed */
88
			if (!isset($config['staticroutes']['enablefastrouting'])) {
89 40fb81a1 Carlos Eduardo Ramos
				$changedesc .= " " . gettext("enable fast routing");
90 2b87adae Bill Marquette
				$config['staticroutes']['enablefastrouting'] = "enabled";
91
				write_config($changedesc);
92
			}
93
		}
94 5b237745 Scott Ullrich
	}
95
}
96
97
if ($_GET['act'] == "del") {
98
	if ($a_routes[$_GET['id']]) {
99 40fb81a1 Carlos Eduardo Ramos
		$changedesc .= gettext("removed route to") . " " . $a_routes[$_GET['id']['route']];
100 a529aced Ermal
		mwexec("/sbin/route delete " . escapeshellarg($a_routes[$_GET['id']]['network']));
101 5b237745 Scott Ullrich
		unset($a_routes[$_GET['id']]);
102 59d922dc Bill Marquette
		write_config($changedesc);
103 5b237745 Scott Ullrich
		header("Location: system_routes.php");
104
		exit;
105
	}
106
}
107 7f43ca88 Scott Ullrich
108 a2927ebf Vinicius Coque
$pgtitle = array(gettext("System"),gettext("Static Routes"));
109 02ca24c9 jim-p
$statusurl = "diag_routes.php";
110
111 7f43ca88 Scott Ullrich
include("head.inc");
112
113 5b237745 Scott Ullrich
?>
114
115
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
116
<?php include("fbegin.inc"); ?>
117
<form action="system_routes.php" method="post">
118 691dade5 Scott Ullrich
<input type="hidden" name="y1" value="1">
119 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
120 a368a026 Ermal Lu?i
<?php if (is_subsystem_dirty('staticroutes')): ?><p>
121 40fb81a1 Carlos Eduardo Ramos
<?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>
122 5b237745 Scott Ullrich
<?php endif; ?>
123 0f282d7a Scott Ullrich
124 5de92d20 Scott Ullrich
	     <?php if($config['system']['disablefilter'] <> "") :?>
125
	       <table width="100%" border="0" cellpadding="0" cellspacing="0">
126
127 a2927ebf Vinicius Coque
		<tr><td width="2%"><input type="checkbox" name="enablefastrouting" id="enablefastrouting" <?php if($config['staticroutes']['enablefastrouting'] == "enabled") echo " checked"; ?>></td><td><b><?=gettext("Enable fast routing");?></td></tr>
128 5de92d20 Scott Ullrich
129 40fb81a1 Carlos Eduardo Ramos
		<tr><td colspan=2><hr><input type="submit" value="<?=gettext("Save"); ?>"></td></tr>
130 5de92d20 Scott Ullrich
	       </table><br>
131 0831bc86 Scott Ullrich
	     <?php endif; ?>
132 0f282d7a Scott Ullrich
133 5b237745 Scott Ullrich
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
134 d173230c Seth Mos
		<tr>
135
		  <td>
136
<?php
137 ba7ec830 Scott Ullrich
		$tab_array = array();
138 a2927ebf Vinicius Coque
		$tab_array[0] = array(gettext("Gateways"), false, "system_gateways.php");
139
		$tab_array[1] = array(gettext("Routes"), true, "system_routes.php");
140
		$tab_array[2] = array(gettext("Groups"), false, "system_gateway_groups.php");
141 ba7ec830 Scott Ullrich
		display_top_tabs($tab_array);
142 d173230c Seth Mos
?>
143 8e830f0f Scott Ullrich
</td></tr>
144
 <tr>
145
   <td>
146
	<div id="mainarea">
147
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
148 5b237745 Scott Ullrich
                <tr>
149 a2927ebf Vinicius Coque
                  <td width="25%" class="listhdrr"><?=gettext("Network");?></td>
150
                  <td width="20%" class="listhdrr"><?=gettext("Gateway");?></td>
151
                  <td width="15%" class="listhdrr"><?=gettext("Interface");?></td>
152
                  <td width="30%" class="listhdr"><?=gettext("Description");?></td>
153 d415d821 Seth Mos
                  <td width="10%" class="list">
154
			<table border="0" cellspacing="0" cellpadding="1">
155
			   <tr>
156 18f7352b Seth Mos
				<td width="17"></td>
157 d415d821 Seth Mos
				<td><a href="system_routes_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
158
			   </tr>
159
			</table>
160
		  </td>
161
		</tr>
162 5b237745 Scott Ullrich
                <tr>
163 d173230c Seth Mos
			<?php $i = 0; foreach ($a_routes as $route): ?>
164 e68492cc Bill Marquette
                  <td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
165 d173230c Seth Mos
                    <?=strtolower($route['network']);?>
166 5b237745 Scott Ullrich
                  </td>
167 e68492cc Bill Marquette
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
168 d173230c Seth Mos
			<?php
169 3a78180e Chris Buechler
				echo htmlentities($a_gateways[$route['gateway']]['name']) . " - " . htmlentities($a_gateways[$route['gateway']]['gateway']);
170 d173230c Seth Mos
			?>
171 5b237745 Scott Ullrich
                  </td>
172 e68492cc Bill Marquette
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
173 d173230c Seth Mos
			<?php
174 a529aced Ermal
				echo convert_friendly_interface_to_friendly_descr($a_gateways[$route['gateway']]['friendlyiface']) . " ";
175 d173230c Seth Mos
			?>
176 5b237745 Scott Ullrich
                  </td>
177 e68492cc Bill Marquette
                  <td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
178 33300c73 Scott Ullrich
                    <?=htmlspecialchars($route['descr']);?>&nbsp;
179 5b237745 Scott Ullrich
                  </td>
180 18f7352b Seth Mos
                  <td valign="middle" nowrap class="list">
181
			<table border="0" cellspacing="0" cellpadding="1">
182
			   <tr>
183
				<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"></a>
184 a2927ebf Vinicius Coque
				<td><a href="system_routes.php?act=del&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"></a></td>
185 18f7352b Seth Mos
			   </tr>
186
			   <tr>
187
				<td width="17"></td>
188
				<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"></a></td>
189
			   </tr>
190
			</table>
191 d173230c Seth Mos
		  </td>
192 18f7352b Seth Mos
		</tr>
193 5b237745 Scott Ullrich
			  <?php $i++; endforeach; ?>
194 8450bc24 Scott Ullrich
                <tr>
195 5b237745 Scott Ullrich
                  <td class="list" colspan="4"></td>
196 d415d821 Seth Mos
                  <td class="list">
197
			<table border="0" cellspacing="0" cellpadding="1">
198
			   <tr>
199 18f7352b Seth Mos
				<td width="17"></td>
200 d415d821 Seth Mos
				<td><a href="system_routes_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
201
			   </tr>
202 8e830f0f Scott Ullrich
		                    </table>
203
				  </td>
204
		                </tr>
205 d415d821 Seth Mos
			</table>
206 8e830f0f Scott Ullrich
			</div>
207
			</td>
208
		  </tr>
209
		</table>
210 5b237745 Scott Ullrich
            </form>
211 ea53e38f Renato Botelho
			<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>
212 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
213
</body>
214
</html>