Project

General

Profile

Download (6.25 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php
2
<?php
3 b46bfcf5 Bill Marquette
/* $Id$ */
4 5b237745 Scott Ullrich
/*
5
	system_routes.php
6
	part of m0n0wall (http://m0n0.ch/wall)
7 8450bc24 Scott Ullrich
8 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10 8450bc24 Scott Ullrich
11 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13 8450bc24 Scott Ullrich
14 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16 8450bc24 Scott Ullrich
17 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20 8450bc24 Scott Ullrich
21 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
require("guiconfig.inc");
34
35
if (!is_array($config['staticroutes']['route']))
36
	$config['staticroutes']['route'] = array();
37
38
staticroutes_sort();
39
$a_routes = &$config['staticroutes']['route'];
40 2b87adae Bill Marquette
$changedesc = "Static Routes: ";
41 5b237745 Scott Ullrich
42
if ($_POST) {
43
44
	$pconfig = $_POST;
45
46
	if ($_POST['apply']) {
47 691dade5 Scott Ullrich
48 5b237745 Scott Ullrich
		$retval = 0;
49
		if (!file_exists($d_sysrebootreqd_path)) {
50
			$retval = system_routing_configure();
51
			$retval |= filter_configure();
52
		}
53
		$savemsg = get_std_save_message($retval);
54
		if ($retval == 0) {
55
			if (file_exists($d_staticroutesdirty_path)) {
56
				config_lock();
57
				unlink($d_staticroutesdirty_path);
58
				config_unlock();
59
			}
60
		}
61 2b87adae Bill Marquette
	} else {
62
		if ($_POST['enablefastrouting'] == "") {
63
			/* Only update config if something changed */
64
			if (isset($config['staticroutes']['enablefastrouting'])) {
65
				$changedesc .= " disable fast routing";
66
				unset($config['staticroutes']['enablefastrouting']);
67
				write_config($changedesc);
68
			}
69
		} else {
70
			/* Only update config if something changed */
71
			if (!isset($config['staticroutes']['enablefastrouting'])) {
72
				$changedesc .= " enable fast routing";
73
				$config['staticroutes']['enablefastrouting'] = "enabled";
74
				write_config($changedesc);
75
			}
76
		}
77 5b237745 Scott Ullrich
	}
78
}
79
80
if ($_GET['act'] == "del") {
81
	if ($a_routes[$_GET['id']]) {
82 59d922dc Bill Marquette
		$changedesc .= "removed route to {$_GET['id']}";
83 5b237745 Scott Ullrich
		unset($a_routes[$_GET['id']]);
84 59d922dc Bill Marquette
		write_config($changedesc);
85 5b237745 Scott Ullrich
		touch($d_staticroutesdirty_path);
86
		header("Location: system_routes.php");
87
		exit;
88
	}
89
}
90
?>
91
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
92
<html>
93
<head>
94
<title><?=gentitle("System: Static routes");?></title>
95
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
96
<link href="gui.css" rel="stylesheet" type="text/css">
97
</head>
98
99
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
100
<?php include("fbegin.inc"); ?>
101
<p class="pgtitle">System: Static routes</p>
102
<form action="system_routes.php" method="post">
103 691dade5 Scott Ullrich
<input type="hidden" name="y1" value="1">
104 5b237745 Scott Ullrich
<?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
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
108
<?php endif; ?>
109 0f282d7a Scott Ullrich
110 5de92d20 Scott Ullrich
	     <?php if($config['system']['disablefilter'] <> "") :?>
111
	       <table width="100%" border="0" cellpadding="0" cellspacing="0">
112
113 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>
114 5de92d20 Scott Ullrich
115 0f282d7a Scott Ullrich
		<tr><td colspan=2><hr><input type="submit" value="Save"></td></tr>
116 5de92d20 Scott Ullrich
	       </table><br>
117
	     <?php endif ?>
118 0f282d7a Scott Ullrich
119 5b237745 Scott Ullrich
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
120
                <tr>
121
                  <td width="15%" class="listhdrr">Interface</td>
122
                  <td width="25%" class="listhdrr">Network</td>
123
                  <td width="20%" class="listhdrr">Gateway</td>
124
                  <td width="30%" class="listhdr">Description</td>
125
                  <td width="10%" class="list"></td>
126
				</tr>
127
			  <?php $i = 0; foreach ($a_routes as $route): ?>
128
                <tr>
129 e68492cc Bill Marquette
                  <td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
130 5b237745 Scott Ullrich
                    <?php
131
				  $iflabels = array('lan' => 'LAN', 'wan' => 'WAN', 'pptp' => 'PPTP');
132
				  for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
133
				  	$iflabels['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
134
				  echo htmlspecialchars($iflabels[$route['interface']]); ?>
135
                  </td>
136 e68492cc Bill Marquette
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
137 5b237745 Scott Ullrich
                    <?=strtolower($route['network']);?>
138
                  </td>
139 e68492cc Bill Marquette
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
140 5b237745 Scott Ullrich
                    <?=strtolower($route['gateway']);?>
141
                  </td>
142 e68492cc Bill Marquette
                  <td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
143 8450bc24 Scott Ullrich
                    <font color="#FFFFFF"><?=htmlspecialchars($route['descr']);?>&nbsp;
144 5b237745 Scott Ullrich
                  </td>
145
                  <td valign="middle" nowrap class="list"> <a href="system_routes_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
146
                     &nbsp;<a href="system_routes.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this route?')"><img src="x.gif" width="17" height="17" border="0"></a></td>
147
				</tr>
148
			  <?php $i++; endforeach; ?>
149 8450bc24 Scott Ullrich
                <tr>
150 5b237745 Scott Ullrich
                  <td class="list" colspan="4"></td>
151
                  <td class="list"> <a href="system_routes_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
152
				</tr>
153
              </table>
154
            </form>
155
<?php include("fend.inc"); ?>
156
</body>
157
</html>