Project

General

Profile

Download (7.18 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
require("guiconfig.inc");
33

    
34
if (!is_array($config['staticroutes']['route']))
35
	$config['staticroutes']['route'] = array();
36

    
37
if (!is_array($config['gateways']['gateway_item']))
38
	$config['gateways']['gateway_item'] = array();
39

    
40
staticroutes_sort();
41
$a_routes = &$config['staticroutes']['route'];
42
$a_gateways = &$config['gateways']['gateway_item'];
43
$changedesc = "Static Routes: ";
44

    
45
if ($_POST) {
46

    
47
	$pconfig = $_POST;
48

    
49
	if ($_POST['apply']) {
50

    
51
		$retval = 0;
52

    
53
		$retval = system_routing_configure();
54
		$retval |= filter_configure();
55

    
56
		$savemsg = get_std_save_message($retval);
57
		if ($retval == 0) {
58
			if (file_exists($d_staticroutesdirty_path)) {
59
				config_lock();
60
				unlink($d_staticroutesdirty_path);
61
				config_unlock();
62
			}
63
		}
64
	} else {
65
		if ($_POST['enablefastrouting'] == "") {
66
			/* Only update config if something changed */
67
			if (isset($config['staticroutes']['enablefastrouting'])) {
68
				$changedesc .= " disable fast routing";
69
				unset($config['staticroutes']['enablefastrouting']);
70
				write_config($changedesc);
71
			}
72
		} else {
73
			/* Only update config if something changed */
74
			if (!isset($config['staticroutes']['enablefastrouting'])) {
75
				$changedesc .= " enable fast routing";
76
				$config['staticroutes']['enablefastrouting'] = "enabled";
77
				write_config($changedesc);
78
			}
79
		}
80
	}
81
}
82

    
83
if ($_GET['act'] == "del") {
84
	if ($a_routes[$_GET['id']]) {
85
		$changedesc .= "removed route to {$_GET['id']}";
86
		unset($a_routes[$_GET['id']]);
87
		write_config($changedesc);
88
		touch($d_staticroutesdirty_path);
89
		header("Location: system_routes.php");
90
		exit;
91
	}
92
}
93

    
94
$pgtitle = "System: Static Routes";
95
include("head.inc");
96

    
97
?>
98

    
99
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
100
<?php include("fbegin.inc"); ?>
101
<p class="pgtitle"><?=$pgtitle?></p>
102
<form action="system_routes.php" method="post">
103
<input type="hidden" name="y1" value="1">
104
<?php if ($savemsg) print_info_box($savemsg); ?>
105
<?php if (file_exists($d_staticroutesdirty_path)): ?><p>
106
<?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>
107
<?php endif; ?>
108

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

    
112
		<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>
113

    
114
		<tr><td colspan=2><hr><input type="submit" value="Save"></td></tr>
115
	       </table><br>
116
	     <?php endif; ?>
117

    
118
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
119
		<tr>
120
		  <td>
121
<?php
122
			$tab_array = array();
123
			$tab_array[0] = array("Gateways", false, "system_gateways.php");
124
			$tab_array[1] = array("Routes", true, "system_routes.php");
125
                        display_top_tabs($tab_array);
126
?>
127
		  </td>
128
		</tr>
129
                <tr>
130
                  <td width="25%" class="listhdrr">Network</td>
131
                  <td width="20%" class="listhdrr">Gateway</td>
132
                  <td width="15%" class="listhdrr">Interface</td>
133
                  <td width="30%" class="listhdr">Description</td>
134
                  <td width="10%" class="list">
135
			<table border="0" cellspacing="0" cellpadding="1">
136
			   <tr>
137
				<td width="17"></td>
138
				<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>
139
			   </tr>
140
			</table>
141
		  </td>
142
		</tr>
143
                <tr>
144
			<?php $i = 0; foreach ($a_routes as $route): ?>
145
                  <td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
146
                    <?=strtolower($route['network']);?>
147
                  </td>
148
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
149
			<?php
150
				echo $route['gateway'] . " ";
151
			?>
152
                  </td>
153
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
154
			<?php
155
				foreach($a_gateways as $gateway) {
156
					if($gateway['name'] == $route['gateway']) {
157
						echo strtoupper($gateway['interface']) . " ";
158
					}
159
				}
160

    
161
			?>
162
                  </td>
163
                  <td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
164
                    <font color="#FFFFFF"><?=htmlspecialchars($route['descr']);?>&nbsp;
165
                  </td>
166
                  <td valign="middle" nowrap class="list">
167
			<table border="0" cellspacing="0" cellpadding="1">
168
			   <tr>
169
				<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>
170
				<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>
171
			   </tr>
172
			   <tr>
173
				<td width="17"></td>
174
				<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>
175
			   </tr>
176
			</table>
177
		  </td>
178
		</tr>
179
			  <?php $i++; endforeach; ?>
180
                <tr>
181
                  <td class="list" colspan="4"></td>
182
                  <td class="list">
183
			<table border="0" cellspacing="0" cellpadding="1">
184
			   <tr>
185
				<td width="17"></td>
186
				<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>
187
			   </tr>
188
			</table>
189
		  </td>
190
		</tr>
191
              </table>
192
            </form>
193
			<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>
194
<?php include("fend.inc"); ?>
195
</body>
196
</html>
(153-153/186)