Project

General

Profile

Download (6.37 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
32
require("guiconfig.inc");
33
34
if (!is_array($config['staticroutes']['route']))
35
	$config['staticroutes']['route'] = array();
36
37
staticroutes_sort();
38
$a_routes = &$config['staticroutes']['route'];
39 2b87adae Bill Marquette
$changedesc = "Static Routes: ";
40 5b237745 Scott Ullrich
41
if ($_POST) {
42
43
	$pconfig = $_POST;
44
45
	if ($_POST['apply']) {
46 691dade5 Scott Ullrich
47 5b237745 Scott Ullrich
		$retval = 0;
48 3851094f Scott Ullrich
49
		$retval = system_routing_configure();
50
		$retval |= filter_configure();
51
52 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
53
		if ($retval == 0) {
54
			if (file_exists($d_staticroutesdirty_path)) {
55
				config_lock();
56
				unlink($d_staticroutesdirty_path);
57
				config_unlock();
58
			}
59
		}
60 2b87adae Bill Marquette
	} else {
61
		if ($_POST['enablefastrouting'] == "") {
62
			/* Only update config if something changed */
63
			if (isset($config['staticroutes']['enablefastrouting'])) {
64
				$changedesc .= " disable fast routing";
65
				unset($config['staticroutes']['enablefastrouting']);
66
				write_config($changedesc);
67
			}
68
		} else {
69
			/* Only update config if something changed */
70
			if (!isset($config['staticroutes']['enablefastrouting'])) {
71
				$changedesc .= " enable fast routing";
72
				$config['staticroutes']['enablefastrouting'] = "enabled";
73
				write_config($changedesc);
74
			}
75
		}
76 5b237745 Scott Ullrich
	}
77
}
78
79
if ($_GET['act'] == "del") {
80
	if ($a_routes[$_GET['id']]) {
81 59d922dc Bill Marquette
		$changedesc .= "removed route to {$_GET['id']}";
82 5b237745 Scott Ullrich
		unset($a_routes[$_GET['id']]);
83 59d922dc Bill Marquette
		write_config($changedesc);
84 5b237745 Scott Ullrich
		touch($d_staticroutesdirty_path);
85
		header("Location: system_routes.php");
86
		exit;
87
	}
88
}
89 7f43ca88 Scott Ullrich
90
$pgtitle = "System: Static Routes";
91
include("head.inc");
92
93 5b237745 Scott Ullrich
?>
94
95
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
96
<?php include("fbegin.inc"); ?>
97 74f446e8 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
98 5b237745 Scott Ullrich
<form action="system_routes.php" method="post">
99 691dade5 Scott Ullrich
<input type="hidden" name="y1" value="1">
100 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
101
<?php if (file_exists($d_staticroutesdirty_path)): ?><p>
102
<?php print_info_box_np("The static route configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
103
<?php endif; ?>
104 0f282d7a Scott Ullrich
105 5de92d20 Scott Ullrich
	     <?php if($config['system']['disablefilter'] <> "") :?>
106
	       <table width="100%" border="0" cellpadding="0" cellspacing="0">
107
108 691dade5 Scott Ullrich
		<tr><td width="2%"><input type="checkbox" name="enablefastrouting" id="enablefastrouting" <?php if($config['staticroutes']['enablefastrouting'] == "enabled") echo " checked"; ?>></td><td><b>Enable fast routing</td></tr>
109 5de92d20 Scott Ullrich
110 0f282d7a Scott Ullrich
		<tr><td colspan=2><hr><input type="submit" value="Save"></td></tr>
111 5de92d20 Scott Ullrich
	       </table><br>
112 0831bc86 Scott Ullrich
	     <?php endif; ?>
113 0f282d7a Scott Ullrich
114 5b237745 Scott Ullrich
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
115
                <tr>
116
                  <td width="15%" class="listhdrr">Interface</td>
117
                  <td width="25%" class="listhdrr">Network</td>
118
                  <td width="20%" class="listhdrr">Gateway</td>
119
                  <td width="30%" class="listhdr">Description</td>
120
                  <td width="10%" class="list"></td>
121
				</tr>
122
			  <?php $i = 0; foreach ($a_routes as $route): ?>
123
                <tr>
124 e68492cc Bill Marquette
                  <td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
125 5b237745 Scott Ullrich
                    <?php
126
				  $iflabels = array('lan' => 'LAN', 'wan' => 'WAN', 'pptp' => 'PPTP');
127
				  for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
128
				  	$iflabels['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
129
				  echo htmlspecialchars($iflabels[$route['interface']]); ?>
130
                  </td>
131 e68492cc Bill Marquette
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
132 5b237745 Scott Ullrich
                    <?=strtolower($route['network']);?>
133
                  </td>
134 e68492cc Bill Marquette
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
135 fef3a8ef Scott Ullrich
				  <?php
136
					if(isset($route['interfacegateway'])) {
137
						echo strtoupper($route['interface']) . " ";
138
					} else {
139
						echo strtolower($route['gateway']) . " ";
140
					}
141
				  ?>
142 5b237745 Scott Ullrich
                  </td>
143 e68492cc Bill Marquette
                  <td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
144 8450bc24 Scott Ullrich
                    <font color="#FFFFFF"><?=htmlspecialchars($route['descr']);?>&nbsp;
145 5b237745 Scott Ullrich
                  </td>
146 677c0869 Erik Kristensen
                  <td valign="middle" nowrap class="list"> <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>
147
                     &nbsp;<a href="system_routes.php?act=del&id=<?=$i;?>" onclick="return confirm('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>
148 5b237745 Scott Ullrich
				</tr>
149
			  <?php $i++; endforeach; ?>
150 8450bc24 Scott Ullrich
                <tr>
151 5b237745 Scott Ullrich
                  <td class="list" colspan="4"></td>
152 677c0869 Erik Kristensen
                  <td class="list"> <a href="system_routes_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
153 5b237745 Scott Ullrich
				</tr>
154
              </table>
155
            </form>
156 f3bfeeea Scott Ullrich
			<p><b>Note:</b>  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>
157 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
158
</body>
159
</html>