Project

General

Profile

Download (7.7 KB) Statistics
| Branch: | Tag: | Revision:
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
##|+PRIV
33
##|*IDENT=page-system-staticroutes
34
##|*NAME=System: Static Routes page
35
##|*DESCR=Allow access to the 'System: Static Routes' page.
36
##|*MATCH=system_routes.php*
37
##|-PRIV
38

    
39

    
40
require("guiconfig.inc");
41

    
42
if (!is_array($config['staticroutes']['route']))
43
	$config['staticroutes']['route'] = array();
44

    
45
if (!is_array($config['gateways']['gateway_item']))
46
	$config['gateways']['gateway_item'] = array();
47

    
48
staticroutes_sort();
49
$a_routes = &$config['staticroutes']['route'];
50
$a_gateways = &$config['gateways']['gateway_item'];
51
$changedesc = "Static Routes: ";
52

    
53
if ($_POST) {
54

    
55
	$pconfig = $_POST;
56

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

    
59
		$retval = 0;
60

    
61
		$retval = system_routing_configure();
62
		$retval |= filter_configure();
63
		/* reconfigure our gateway monitor */
64
		setup_gateways_monitor();
65

    
66
		$savemsg = get_std_save_message($retval);
67
		if ($retval == 0) {
68
			if (file_exists($d_staticroutesdirty_path)) {
69
				config_lock();
70
				unlink($d_staticroutesdirty_path);
71
				config_unlock();
72
			}
73
		}
74
	} else {
75
		if ($_POST['enablefastrouting'] == "") {
76
			/* Only update config if something changed */
77
			if (isset($config['staticroutes']['enablefastrouting'])) {
78
				$changedesc .= " disable fast routing";
79
				unset($config['staticroutes']['enablefastrouting']);
80
				write_config($changedesc);
81
			}
82
		} else {
83
			/* Only update config if something changed */
84
			if (!isset($config['staticroutes']['enablefastrouting'])) {
85
				$changedesc .= " enable fast routing";
86
				$config['staticroutes']['enablefastrouting'] = "enabled";
87
				write_config($changedesc);
88
			}
89
		}
90
	}
91
}
92

    
93
if ($_GET['act'] == "del") {
94
	if ($a_routes[$_GET['id']]) {
95
		$changedesc .= "removed route to " . $a_routes[$_GET['id']['route']];
96
		unset($a_routes[$_GET['id']]);
97
		write_config($changedesc);
98
		touch($d_staticroutesdirty_path);
99
		header("Location: system_routes.php");
100
		exit;
101
	}
102
}
103

    
104
$pgtitle = array("System","Static Routes");
105
include("head.inc");
106

    
107
?>
108

    
109
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
110
<?php include("fbegin.inc"); ?>
111
<form action="system_routes.php" method="post">
112
<input type="hidden" name="y1" value="1">
113
<?php if ($savemsg) print_info_box($savemsg); ?>
114
<?php if (file_exists($d_staticroutesdirty_path)): ?><p>
115
<?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>
116
<?php endif; ?>
117

    
118
	     <?php if($config['system']['disablefilter'] <> "") :?>
119
	       <table width="100%" border="0" cellpadding="0" cellspacing="0">
120

    
121
		<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>
122

    
123
		<tr><td colspan=2><hr><input type="submit" value="Save"></td></tr>
124
	       </table><br>
125
	     <?php endif; ?>
126

    
127
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
128
		<tr>
129
		  <td>
130
<?php
131
		$tab_array = array();
132
		$tab_array[0] = array("Gateways", false, "system_gateways.php");
133
		$tab_array[1] = array("Routes", true, "system_routes.php");
134
		$tab_array[2] = array("Groups", false, "system_gateway_groups.php");
135
		$tab_array[3] = array("Settings", false, "system_gateways_settings.php");
136
		display_top_tabs($tab_array);
137
?>
138
</td></tr>
139
 <tr>
140
   <td>
141
	<div id="mainarea">
142
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
143
                <tr>
144
                  <td width="25%" class="listhdrr">Network</td>
145
                  <td width="20%" class="listhdrr">Gateway</td>
146
                  <td width="15%" class="listhdrr">Interface</td>
147
                  <td width="30%" class="listhdr">Description</td>
148
                  <td width="10%" class="list">
149
			<table border="0" cellspacing="0" cellpadding="1">
150
			   <tr>
151
				<td width="17"></td>
152
				<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>
153
			   </tr>
154
			</table>
155
		  </td>
156
		</tr>
157
                <tr>
158
			<?php $i = 0; foreach ($a_routes as $route): ?>
159
                  <td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
160
                    <?=strtolower($route['network']);?>
161
                  </td>
162
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
163
			<?php
164
				echo $route['gateway'] . " ";
165
			?>
166
                  </td>
167
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
168
			<?php
169
				foreach($a_gateways as $gateway) {
170
					if($gateway['name'] == $route['gateway']) {
171
						echo strtoupper($gateway['interface']) . " ";
172
					}
173
				}
174

    
175
			?>
176
                  </td>
177
                  <td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
178
                    <?=htmlspecialchars($route['descr']);?>&nbsp;
179
                  </td>
180
                  <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
				<td><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>
185
			   </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
		  </td>
192
		</tr>
193
			  <?php $i++; endforeach; ?>
194
                <tr>
195
                  <td class="list" colspan="4"></td>
196
                  <td class="list">
197
			<table border="0" cellspacing="0" cellpadding="1">
198
			   <tr>
199
				<td width="17"></td>
200
				<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
		                    </table>
203
				  </td>
204
		                </tr>
205
			</table>
206
			</div>
207
			</td>
208
		  </tr>
209
		</table>
210
            </form>
211
			<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>
212
<?php include("fend.inc"); ?>
213
</body>
214
</html>
(175-175/203)