-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadvanced.php
175 lines (159 loc) · 7.57 KB
/
advanced.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
/*
* advanced.php
*
* Copyright (C) 2013-2014 by Erland Hedman <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
include 'cgi-bin/common.php';
//if (count($_POST)) {echo "<pre>"; print_r($_POST); echo "</pre>";exit;}
if (count($_POST) && $_POST["POST_ACTION"] == "OK") {
if (!function_exists('pcntl_fork')) die('PCNTL functions not available on this PHP installation');
$pid = pcntl_fork();
if ($pid == -1) {
echo("<pre>pcntl_fork: failed - check the extension for pcntl.so\n");
print_r(error_get_last());
echo "</pre>\n"; exit;
} else if (!$pid) {
// We are the child
if (isset($_POST['reboot'])) {
@system("reboot");
exit;
}
if (isset($_POST['watchdog']) && isset($_POST['w_probe'])) {
$if=$_POST['f_if'] == "lan"? g_lan():g_wan();
@system("echo 'DEST=".$_POST['w_probe']."; INTERFACES=".$if.";' > /etc/default/watchdog.dest");
@system("watchdogd start bg > /dev/null 2>&1 &");
} else {
// Cannot stop once started! do something harmless.
system("echo 'DEST=127.0.0.1; INTERFACES=".g_lan().";' > /etc/default/watchdog.dest");
}
} else {
$sec = isset($_POST['reboot'])? 64:30;
header('Location: http://'. $_SERVER["SERVER_ADDR"]. '/wait.php?seconds='.$sec.'&loc='.$_SERVER['SCRIPT_NAME']);
exit;
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="/css/bridge.css">
<title><?php p_title(); ?></title>
<script>
<?php setTimeout(); ?>
<?php include 'inc/general.js.php' ?>
function checkPage()
{
var f=getObj("form");
if (isFieldBlank(f.w_probe.value) == true) {
f.w_probe.select();
alert("Blank IP address");
return false;
}
if (isIPValid(f.w_probe) == false) {
f.w_probe.select();
alert("Invalid IP address");
return false;
}
f.f_if.value = isSubnetSame(f.w_probe.value, "<?php p_ip(g_lan()); ?>", "<?php p_mask(g_lan()) ?>") == false? "lan":"wan";
f.POST_ACTION.value = "OK";
f.submit();
return true;
}
</script>
</head>
<body><script>onbody();</script>
<form name="form" id="form" method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" onsubmit="return checkPage();">
<input name="POST_ACTION" value="" type="hidden">
<input name="f_if" id="f_if" value="0" type="hidden">
<table id="topContainer">
<tr>
<td class="laCN">Project Page : <a href="<?php p_productHome(); ?>" target=_blank><?php p_serverName(); ?></a></td>
<td class="raCN">Version : <?php p_firmware("-ro");?> </td>
</tr>
</table>
<table id="topTable">
<tr>
<td id="topBarLeft"><a id="logo" href="<?php p_productHome(); ?>"></a></td>
<td id="topBarRight"></td>
</tr>
</table>
<table id="topMenuTable">
<tr>
<td class="ledPanel">
<img class="led" alt="fwstat" title="Firewall" src="/img/<?php echo g_srvstat("shorewall")? "on":"off" ?>.png">
<img class="led" alt="dnsstat" title="DNS" src="/img/<?php echo g_srvstat("named")? "on":"off" ?>.png">
<img class="led" alt="dhcpstat" title="DHCP" src="/img/<?php echo g_srvstat("dhcpd")? "on":"off" ?>.png">
</td>
<td class="topMenuLink"><a href="/network.php">Setup</a></td>
<td class="topMenuThis"><a href="/advanced.php">Advanced</a></td>
<td class="topMenuLink"><a href="/admin.php">MAINTENANCE</a></td>
<td class="topMenuLink"><a href="/status.php">Status</a></td>
<td class="topMenuLink"><a href="/logout.php"><span id="timer"></span></a></td>
</tr>
</table>
<table id="mainContentTable">
<tr style="vertical-align: top;">
<td class="leftMenyContatiner">
<div class="leftNavLink">
<ul style="width: 100%">
<li><div id="left" class="navThis">Advanced</div></li>
<li><div class="leftnavLink"><a href="/wd_log.php">Logs</a></div></li>
</ul>
</div>
</td>
<td id="contentHeading">
<div id="contentBox">
<h1>Settings</h1>
If you are not familiar with these Advanced settings, please leave them unmodified.
<br><br>
<input value="Save Settings" type="submit">
<input value="Don't Save Settings" onclick="cancelSettings()" type="button">
</div><div class="vbr"></div>
<div class="actionBox">
<h2 class="actionHeader">SYSTEM SETTINGS</h2>
<table>
<tr>
<td class="raCB" style="width: 30%"><b>Enable the watchdog timer :</b></td>
<td> <input type="checkbox" name="watchdog" <?php echo exec("watchdogd status")=="0"? 'checked="checked"':''; ?>></td>
<td style="width: 45%">Forced reboot to prevent permanent lockups after prolonged network errors.</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr>
<td class="raCB"><b>Watchdog ping :</b></td>
<td><input name="w_probe" id="w_probe" type="text" maxlength="40" value="<?php echo exec("watchdogd probe"); ?>"> </td>
<td>This host must answer to a ping within resonable time to avoid a system reboot.</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr>
<td class="raCB"><b>Manual Reboot :</b></td>
<td colspan="2"> <input type="submit" name="reboot" value="Reboot The Device"></td>
</tr>
</table>
</div>
</td>
<td id="quickHelpContent"><strong>Help...</strong><br>
<br>
It is recommended that you leave these parameters at their default values.<br>
Adjusting them could limit the performance of your system.<br><br>
If you see that the address "Watchdog ping" is set to 127.0.0.1, then this
system has decided to use an always safe target address, usually
because of a system reconfiguration or an attempt to disable the service here.<br>
A watchdog timer can not be stopped once it has started.
</td>
</tr>
<tr>
<td colspan="3" id="footer">
Copyright © <?php p_copyRight(); ?>
</td>
</tr>
</table>
</form>
</body>
</html>