Project

General

Profile

Download (5.53 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php
2
<?php
3
/*
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
40
if ($_POST) {
41
42 691dade5 Scott Ullrich
	if ($_POST['enablefastrouting'] == "") {
43
		unset($config['staticroutes']['enablefastrouting']);
44
		write_config();
45
	} else {
46
		$config['staticroutes']['enablefastrouting'] = "enabled";
47
		write_config();
48
	}
49
50 5b237745 Scott Ullrich
	$pconfig = $_POST;
51
52
	if ($_POST['apply']) {
53 691dade5 Scott Ullrich
54 5b237745 Scott Ullrich
		$retval = 0;
55
		if (!file_exists($d_sysrebootreqd_path)) {
56
			$retval = system_routing_configure();
57
			$retval |= filter_configure();
58
		}
59
		$savemsg = get_std_save_message($retval);
60
		if ($retval == 0) {
61
			if (file_exists($d_staticroutesdirty_path)) {
62
				config_lock();
63
				unlink($d_staticroutesdirty_path);
64
				config_unlock();
65
			}
66
		}
67
	}
68 0f282d7a Scott Ullrich
69 5b237745 Scott Ullrich
}
70
71
if ($_GET['act'] == "del") {
72
	if ($a_routes[$_GET['id']]) {
73
		unset($a_routes[$_GET['id']]);
74
		write_config();
75
		touch($d_staticroutesdirty_path);
76
		header("Location: system_routes.php");
77
		exit;
78
	}
79
}
80
?>
81
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
82
<html>
83
<head>
84
<title><?=gentitle("System: Static routes");?></title>
85
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
86
<link href="gui.css" rel="stylesheet" type="text/css">
87
</head>
88
89
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
90
<?php include("fbegin.inc"); ?>
91
<p class="pgtitle">System: Static routes</p>
92
<form action="system_routes.php" method="post">
93 691dade5 Scott Ullrich
<input type="hidden" name="y1" value="1">
94 5b237745 Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
95
<?php if (file_exists($d_staticroutesdirty_path)): ?><p>
96
<?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>
97
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
98
<?php endif; ?>
99 0f282d7a Scott Ullrich
100 5de92d20 Scott Ullrich
	     <?php if($config['system']['disablefilter'] <> "") :?>
101
	       <table width="100%" border="0" cellpadding="0" cellspacing="0">
102
103 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>
104 5de92d20 Scott Ullrich
105 0f282d7a Scott Ullrich
		<tr><td colspan=2><hr><input type="submit" value="Save"></td></tr>
106 5de92d20 Scott Ullrich
	       </table><br>
107
	     <?php endif ?>
108 0f282d7a Scott Ullrich
109 5b237745 Scott Ullrich
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
110
                <tr>
111
                  <td width="15%" class="listhdrr">Interface</td>
112
                  <td width="25%" class="listhdrr">Network</td>
113
                  <td width="20%" class="listhdrr">Gateway</td>
114
                  <td width="30%" class="listhdr">Description</td>
115
                  <td width="10%" class="list"></td>
116
				</tr>
117
			  <?php $i = 0; foreach ($a_routes as $route): ?>
118
                <tr>
119
                  <td class="listlr">
120
                    <?php
121
				  $iflabels = array('lan' => 'LAN', 'wan' => 'WAN', 'pptp' => 'PPTP');
122
				  for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
123
				  	$iflabels['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
124
				  echo htmlspecialchars($iflabels[$route['interface']]); ?>
125
                  </td>
126
                  <td class="listr">
127
                    <?=strtolower($route['network']);?>
128
                  </td>
129
                  <td class="listr">
130
                    <?=strtolower($route['gateway']);?>
131
                  </td>
132
                  <td class="listbg">
133 8450bc24 Scott Ullrich
                    <font color="#FFFFFF"><?=htmlspecialchars($route['descr']);?>&nbsp;
134 5b237745 Scott Ullrich
                  </td>
135
                  <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>
136
                     &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>
137
				</tr>
138
			  <?php $i++; endforeach; ?>
139 8450bc24 Scott Ullrich
                <tr>
140 5b237745 Scott Ullrich
                  <td class="list" colspan="4"></td>
141
                  <td class="list"> <a href="system_routes_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
142
				</tr>
143
              </table>
144
            </form>
145
<?php include("fend.inc"); ?>
146
</body>
147
</html>