Project

General

Profile

Download (7.13 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
	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);
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']['route']];
84
		mwexec("/sbin/route delete " . escapeshellarg($a_routes[$_GET['id']]['network']));
85
		unset($a_routes[$_GET['id']]);
86
		write_config($changedesc);
87
		header("Location: system_routes.php");
88
		exit;
89
	}
90
}
91

    
92
$pgtitle = array(gettext("System"),gettext("Static Routes"));
93
$statusurl = "diag_routes.php";
94

    
95
include("head.inc");
96

    
97
?>
98

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

    
108
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
109
		<tr>
110
		  <td>
111
<?php
112
		$tab_array = array();
113
		$tab_array[0] = array(gettext("Gateways"), false, "system_gateways.php");
114
		$tab_array[1] = array(gettext("Routes"), true, "system_routes.php");
115
		$tab_array[2] = array(gettext("Groups"), false, "system_gateway_groups.php");
116
		display_top_tabs($tab_array);
117
?>
118
</td></tr>
119
 <tr>
120
   <td>
121
	<div id="mainarea">
122
             <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
123
                <tr>
124
                  <td width="25%" class="listhdrr"><?=gettext("Network");?></td>
125
                  <td width="20%" class="listhdrr"><?=gettext("Gateway");?></td>
126
                  <td width="15%" class="listhdrr"><?=gettext("Interface");?></td>
127
                  <td width="30%" class="listhdr"><?=gettext("Description");?></td>
128
                  <td width="10%" class="list">
129
			<table border="0" cellspacing="0" cellpadding="1">
130
			   <tr>
131
				<td width="17"></td>
132
				<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>
133
			   </tr>
134
			</table>
135
		  </td>
136
		</tr>
137
                <tr>
138
			<?php $i = 0; foreach ($a_routes as $route): ?>
139
                  <td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
140
                    <?=strtolower($route['network']);?>
141
                  </td>
142
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
143
			<?php
144
				echo htmlentities($a_gateways[$route['gateway']]['name']) . " - " . htmlentities($a_gateways[$route['gateway']]['gateway']);
145
			?>
146
                  </td>
147
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
148
			<?php
149
				echo convert_friendly_interface_to_friendly_descr($a_gateways[$route['gateway']]['friendlyiface']) . " ";
150
			?>
151
                  </td>
152
                  <td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
153
                    <?=htmlspecialchars($route['descr']);?>&nbsp;
154
                  </td>
155
                  <td valign="middle" nowrap class="list">
156
			<table border="0" cellspacing="0" cellpadding="1">
157
			   <tr>
158
				<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>
159
				<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>
160
			   </tr>
161
			   <tr>
162
				<td width="17"></td>
163
				<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>
164
			   </tr>
165
			</table>
166
		  </td>
167
		</tr>
168
			  <?php $i++; endforeach; ?>
169
                <tr>
170
                  <td class="list" colspan="4"></td>
171
                  <td class="list">
172
			<table border="0" cellspacing="0" cellpadding="1">
173
			   <tr>
174
				<td width="17"></td>
175
				<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>
176
			   </tr>
177
		                    </table>
178
				  </td>
179
		                </tr>
180
			</table>
181
			</div>
182
			</td>
183
		  </tr>
184
		</table>
185
            </form>
186
			<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>
187
<?php include("fend.inc"); ?>
188
</body>
189
</html>
(199-199/228)