Project

General

Profile

Download (6.25 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/* $Id$ */
4
/*
5
	system_routes.php
6
	part of m0n0wall (http://m0n0.ch/wall)
7

    
8
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
9
	All rights reserved.
10

    
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13

    
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16

    
17
	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

    
21
	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
$changedesc = "Static Routes: ";
41

    
42
if ($_POST) {
43

    
44
	$pconfig = $_POST;
45

    
46
	if ($_POST['apply']) {
47

    
48
		$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
	} 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
	}
78
}
79

    
80
if ($_GET['act'] == "del") {
81
	if ($a_routes[$_GET['id']]) {
82
		$changedesc .= "removed route to {$_GET['id']}";
83
		unset($a_routes[$_GET['id']]);
84
		write_config($changedesc);
85
		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
<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
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
108
<?php endif; ?>
109

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

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

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

    
119
              <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
                  <td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
130
                    <?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
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
137
                    <?=strtolower($route['network']);?>
138
                  </td>
139
                  <td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
140
                    <?=strtolower($route['gateway']);?>
141
                  </td>
142
                  <td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
143
                    <font color="#FFFFFF"><?=htmlspecialchars($route['descr']);?>&nbsp;
144
                  </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
                <tr>
150
                  <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>
(98-98/113)