1 |
2cd6010c
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
b49448ac
|
Scott Ullrich
|
index.php
|
5 |
|
|
Copyright (C) 2004, 2005 Scott Ullrich
|
6 |
|
|
All rights reserved.
|
7 |
|
|
|
8 |
|
|
Originally part of m0n0wall (http://m0n0.ch/wall)
|
9 |
|
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10 |
|
|
All rights reserved.
|
11 |
|
|
|
12 |
|
|
Redistribution and use in source and binary forms, with or without
|
13 |
|
|
modification, are permitted provided that the following conditions are met:
|
14 |
|
|
|
15 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
16 |
|
|
this list of conditions and the following disclaimer.
|
17 |
|
|
|
18 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
19 |
|
|
notice, this list of conditions and the following disclaimer in the
|
20 |
|
|
documentation and/or other materials provided with the distribution.
|
21 |
|
|
|
22 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26 |
0682e26b
|
Colin Smith
|
oR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27 |
b49448ac
|
Scott Ullrich
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
32 |
5b237745
|
Scott Ullrich
|
*/
|
33 |
|
|
|
34 |
1df0159c
|
Erik Kristensen
|
## Load Essential Includes
|
35 |
|
|
require_once('guiconfig.inc');
|
36 |
|
|
require_once('notices.inc');
|
37 |
d772ac32
|
Erik Kristensen
|
|
38 |
|
|
|
39 |
1df0159c
|
Erik Kristensen
|
## Load Functions Files
|
40 |
|
|
require_once('includes/functions.inc.php');
|
41 |
d772ac32
|
Erik Kristensen
|
|
42 |
|
|
|
43 |
1df0159c
|
Erik Kristensen
|
## Load AJAX, Initiate Class ###############################################
|
44 |
|
|
require_once('includes/sajax.class.php');
|
45 |
d772ac32
|
Erik Kristensen
|
|
46 |
1df0159c
|
Erik Kristensen
|
## Initiate Class and Set location of ajax file containing
|
47 |
|
|
## the information that we need for this page. Also set functions
|
48 |
|
|
## that SAJAX will be using.
|
49 |
|
|
$oSajax = new sajax();
|
50 |
|
|
$oSajax->sajax_remote_uri = 'sajax/index.sajax.php';
|
51 |
|
|
$oSajax->sajax_request_type = 'POST';
|
52 |
477361c7
|
Erik Kristensen
|
$oSajax->sajax_export("get_stats");
|
53 |
1df0159c
|
Erik Kristensen
|
$oSajax->sajax_handle_client_request();
|
54 |
|
|
############################################################################
|
55 |
d772ac32
|
Erik Kristensen
|
|
56 |
|
|
|
57 |
1df0159c
|
Erik Kristensen
|
## Check to see if we have a swap space,
|
58 |
|
|
## if true, display, if false, hide it ...
|
59 |
746ca58a
|
Scott Ullrich
|
if(file_exists("/usr/sbin/swapinfo")) {
|
60 |
|
|
$swapinfo = `/usr/sbin/swapinfo`;
|
61 |
|
|
if(stristr($swapinfo,'%') == true) $showswap=true;
|
62 |
|
|
}
|
63 |
d772ac32
|
Erik Kristensen
|
|
64 |
f3e2c205
|
Scott Ullrich
|
|
65 |
1df0159c
|
Erik Kristensen
|
## User recently restored his config.
|
66 |
|
|
## If packages are installed lets resync
|
67 |
1abb04ea
|
Scott Ullrich
|
if(file_exists('/conf/needs_package_sync')) {
|
68 |
1df0159c
|
Erik Kristensen
|
if($config['installedpackages'] <> '') {
|
69 |
|
|
conf_mount_rw();
|
70 |
1abb04ea
|
Scott Ullrich
|
unlink('/conf/needs_package_sync');
|
71 |
1df0159c
|
Erik Kristensen
|
header('Location: pkg_mgr_install.php?mode=reinstallall');
|
72 |
|
|
exit;
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
8fecad11
|
Scott Ullrich
|
|
76 |
1df0159c
|
Erik Kristensen
|
|
77 |
|
|
## If it is the first time webGUI has been
|
78 |
|
|
## accessed since initial install show this stuff.
|
79 |
1abb04ea
|
Scott Ullrich
|
if(file_exists('/conf/trigger_initial_wizard')) {
|
80 |
1df0159c
|
Erik Kristensen
|
|
81 |
fdfccb63
|
Scott Ullrich
|
echo <<<EOF
|
82 |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
83 |
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
84 |
|
|
<html>
|
85 |
|
|
<head>
|
86 |
8a1d94fe
|
Scott Ullrich
|
<title>{$g['product_name']}.local - {$g['product_name']} first time setup</title>
|
87 |
fdfccb63
|
Scott Ullrich
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
88 |
|
|
<link rel="stylesheet" type="text/css" href="/niftycssprintCode.css" media="print" />
|
89 |
|
|
<script type="text/javascript">var theme = "nervecenter"</script>
|
90 |
|
|
<script type="text/javascript" src="/themes/nervecenter/loader.js"></script>
|
91 |
|
|
|
92 |
|
|
EOF;
|
93 |
1df0159c
|
Erik Kristensen
|
echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
|
94 |
ed6e63e6
|
Scott Ullrich
|
|
95 |
|
|
if(file_exists("/usr/local/www/themes/{$g['theme']}/wizard.css"))
|
96 |
|
|
echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/wizard.css\" media=\"all\" />\n";
|
97 |
|
|
else
|
98 |
|
|
echo "<link rel=\"stylesheet\" href=\"/themes/{$g['theme']}/all.css\" media=\"all\" />";
|
99 |
|
|
|
100 |
1df0159c
|
Erik Kristensen
|
echo "<form>\n";
|
101 |
|
|
echo "<center>\n";
|
102 |
|
|
echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n";
|
103 |
|
|
echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
|
104 |
c317e04e
|
Scott Ullrich
|
echo "Welcome to {$g['product_name']}!<p>\n";
|
105 |
1df0159c
|
Erik Kristensen
|
echo "One moment while we start the initial setup wizard.<p>\n";
|
106 |
711ee164
|
Chris Buechler
|
echo "Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.<p>\n";
|
107 |
c317e04e
|
Scott Ullrich
|
echo "To bypass the wizard, click on the {$g['product_name']} logo on the initial page.\n";
|
108 |
1df0159c
|
Erik Kristensen
|
echo "</div>\n";
|
109 |
|
|
echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
|
110 |
|
|
echo "<script type=\"text/javascript\">\n";
|
111 |
|
|
echo "NiftyCheck();\n";
|
112 |
fdfccb63
|
Scott Ullrich
|
echo "Rounded(\"div#nifty\",\"all\",\"#AAA\",\"#FFFFFF\",\"smooth\");\n";
|
113 |
1df0159c
|
Erik Kristensen
|
echo "</script>\n";
|
114 |
1ca54f04
|
Scott Ullrich
|
exit;
|
115 |
|
|
}
|
116 |
|
|
|
117 |
bf787c0a
|
Scott Ullrich
|
|
118 |
1df0159c
|
Erik Kristensen
|
## Find out whether there's hardware encryption or not
|
119 |
|
|
unset($hwcrypto);
|
120 |
|
|
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
|
121 |
|
|
if ($fd) {
|
122 |
|
|
while (!feof($fd)) {
|
123 |
|
|
$dmesgl = fgets($fd);
|
124 |
|
|
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)) {
|
125 |
|
|
$hwcrypto = $matches[1];
|
126 |
|
|
break;
|
127 |
|
|
}
|
128 |
5b237745
|
Scott Ullrich
|
}
|
129 |
1df0159c
|
Erik Kristensen
|
fclose($fd);
|
130 |
5b237745
|
Scott Ullrich
|
}
|
131 |
|
|
|
132 |
561d55ff
|
Erik Kristensen
|
|
133 |
1df0159c
|
Erik Kristensen
|
## Set Page Title and Include Header
|
134 |
c317e04e
|
Scott Ullrich
|
$pgtitle = "{$g['product_name']} webGUI";
|
135 |
1df0159c
|
Erik Kristensen
|
include("head.inc");
|
136 |
5b237745
|
Scott Ullrich
|
|
137 |
a8726a3d
|
Scott Ullrich
|
?>
|
138 |
8dbbc3ed
|
Scott Ullrich
|
|
139 |
5b237745
|
Scott Ullrich
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
140 |
670fe849
|
Scott Ullrich
|
<script language="javascript">
|
141 |
|
|
var ajaxStarted = false;
|
142 |
|
|
</script>
|
143 |
5ffe7500
|
Scott Ullrich
|
<?php
|
144 |
|
|
include("fbegin.inc");
|
145 |
5e237c18
|
Erik Kristensen
|
if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
|
146 |
|
|
echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>";
|
147 |
0682e26b
|
Colin Smith
|
?>
|
148 |
561d55ff
|
Erik Kristensen
|
<p class="pgtitle">System Overview</p>
|
149 |
|
|
|
150 |
1df0159c
|
Erik Kristensen
|
<div id="niftyOutter">
|
151 |
|
|
<form action="index.php" method="post">
|
152 |
d772ac32
|
Erik Kristensen
|
<table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0">
|
153 |
|
|
<tbody>
|
154 |
|
|
<tr>
|
155 |
|
|
<td colspan="2" class="listtopic">System information</td>
|
156 |
|
|
</tr>
|
157 |
|
|
<tr>
|
158 |
|
|
<td width="25%" class="vncellt">Name</td>
|
159 |
|
|
<td width="75%" class="listr"><?php echo $config['system']['hostname'] . "." . $config['system']['domain']; ?></td>
|
160 |
|
|
</tr>
|
161 |
|
|
<tr>
|
162 |
|
|
<td width="25%" valign="top" class="vncellt">Version</td>
|
163 |
|
|
<td width="75%" class="listr">
|
164 |
|
|
<strong><?php readfile("/etc/version"); ?></strong>
|
165 |
|
|
<br />
|
166 |
|
|
built on <?php readfile("/etc/version.buildtime"); ?>
|
167 |
|
|
</td>
|
168 |
|
|
</tr>
|
169 |
c6a15b30
|
Scott Ullrich
|
<?php if(!$g['hideplatform']): ?>
|
170 |
d772ac32
|
Erik Kristensen
|
<tr>
|
171 |
|
|
<td width="25%" class="vncellt">Platform</td>
|
172 |
|
|
<td width="75%" class="listr"><?=htmlspecialchars($g['platform']);?></td>
|
173 |
|
|
</tr>
|
174 |
c6a15b30
|
Scott Ullrich
|
<?php endif; ?>
|
175 |
d772ac32
|
Erik Kristensen
|
<?php if ($hwcrypto): ?>
|
176 |
|
|
<tr>
|
177 |
|
|
<td width="25%" class="vncellt">Hardware crypto</td>
|
178 |
|
|
<td width="75%" class="listr"><?=htmlspecialchars($hwcrypto);?></td>
|
179 |
|
|
</tr>
|
180 |
|
|
<?php endif; ?>
|
181 |
|
|
<tr>
|
182 |
|
|
<td width="25%" class="vncellt">Uptime</td>
|
183 |
|
|
<td width="75%" class="listr"><input style="border: 0px solid white;" size="30" name="uptime" id="uptime" value="<?= htmlspecialchars(get_uptime()); ?>" /></td>
|
184 |
|
|
</tr>
|
185 |
|
|
<?php if ($config['lastchange']): ?>
|
186 |
|
|
<tr>
|
187 |
|
|
<td width="25%" class="vncellt">Last config change</td>
|
188 |
|
|
<td width="75%" class="listr"><?= htmlspecialchars(date("D M j G:i:s T Y", $config['revision']['time']));?></td>
|
189 |
|
|
</tr>
|
190 |
|
|
<?php endif; ?>
|
191 |
|
|
<tr>
|
192 |
|
|
<td width="25%" class="vncellt">State table size</td>
|
193 |
|
|
<td width="75%" class="listr">
|
194 |
|
|
<input style="border: 0px solid white;" size="30" name="pfstate" id="pfstate" value="<?= htmlspecialchars(get_pfstate()); ?>" />
|
195 |
|
|
<br />
|
196 |
|
|
<a href="diag_dump_states.php">Show states</a>
|
197 |
|
|
</td>
|
198 |
|
|
</tr>
|
199 |
7dbee0fd
|
Scott Ullrich
|
<tr>
|
200 |
|
|
<td width="25%" class="vncellt">MBUF Usage</td>
|
201 |
|
|
<td width="75%" class="listr">
|
202 |
|
|
<?php
|
203 |
f957780e
|
Scott Ullrich
|
$mbufs_inuse=`netstat -mb | grep "mbufs in use" | awk '{ print $1 }' | cut -d"/" -f1`;
|
204 |
|
|
$mbufs_total=`netstat -mb | grep "mbufs in use" | awk '{ print $1 }' | cut -d"/" -f3`;
|
205 |
7dbee0fd
|
Scott Ullrich
|
?>
|
206 |
|
|
<?=$mbufs_inuse?>/<?=$mbufs_total?>
|
207 |
|
|
</td>
|
208 |
|
|
</tr>
|
209 |
d772ac32
|
Erik Kristensen
|
<tr>
|
210 |
|
|
<td width="25%" class="vncellt">CPU usage</td>
|
211 |
561d55ff
|
Erik Kristensen
|
<td width="75%" class="listr">
|
212 |
a3d1ff72
|
Scott Ullrich
|
<?php $cpuUsage = "0"; ?>
|
213 |
6ad26249
|
Scott Ullrich
|
<img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="cpuwidtha" id="cpuwidtha" width="<?= $cpuUsage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="cpuwidthb" id="cpuwidthb" width="<?= (100 - $cpuUsage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
|
214 |
a3d1ff72
|
Scott Ullrich
|
|
215 |
b82d131e
|
Scott Ullrich
|
<input style="border: 0px solid white;" size="30" name="cpumeter" id="cpumeter" value="(Updating in 5 seconds)" />
|
216 |
d772ac32
|
Erik Kristensen
|
</td>
|
217 |
|
|
</tr>
|
218 |
|
|
<tr>
|
219 |
|
|
<td width="25%" class="vncellt">Memory usage</td>
|
220 |
|
|
<td width="75%" class="listr">
|
221 |
|
|
<?php $memUsage = mem_usage(); ?>
|
222 |
6ad26249
|
Scott Ullrich
|
<img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" name="memwidtha" id="memwidtha" width="<?= $memUsage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" name="memwidthb" id="memwidthb" width="<?= (100 - $memUsage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
|
223 |
a3d1ff72
|
Scott Ullrich
|
|
224 |
|
|
<input style="border: 0px solid white;" size="30" name="memusagemeter" id="memusagemeter" value="<?= $memUsage.'%'; ?>" />
|
225 |
d772ac32
|
Erik Kristensen
|
</td>
|
226 |
|
|
</tr>
|
227 |
|
|
<?php if($showswap == true): ?>
|
228 |
|
|
<tr>
|
229 |
|
|
<td width="25%" class="vncellt">SWAP usage</td>
|
230 |
|
|
<td width="75%" class="listr">
|
231 |
49c2af5c
|
Scott Ullrich
|
<?php $swapUsage = swap_usage(); ?>
|
232 |
6ad26249
|
Scott Ullrich
|
<img src="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif" height="15" width="<?= $swapUsage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" height="15" width="<?= (100 - $swapUsage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
|
233 |
a3d1ff72
|
Scott Ullrich
|
|
234 |
49c2af5c
|
Scott Ullrich
|
<input style="border: 0px solid white;" size="30" name="swapusagemeter" id="swapusagemeter" value="<?= $swapUsage.'%'; ?>" />
|
235 |
d772ac32
|
Erik Kristensen
|
</td>
|
236 |
|
|
</tr>
|
237 |
|
|
<?php endif; ?>
|
238 |
|
|
<tr>
|
239 |
|
|
<td width="25%" class="vncellt">Disk usage</td>
|
240 |
|
|
<td width="75%" class="listr">
|
241 |
|
|
<?php $diskusage = disk_usage(); ?>
|
242 |
6ad26249
|
Scott Ullrich
|
<img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_left.gif" height="15" width="4" border="0" align="middle" alt="left bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_blue.gif" height="15" width="<?= $diskusage; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_gray.gif" height="15" width="<?= (100 - $diskusage); ?>" border="0" align="middle" alt="gray bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_right.gif" height="15" width="5" border="0" align="middle" alt="right bar" />
|
243 |
a3d1ff72
|
Scott Ullrich
|
|
244 |
d50e7978
|
Bill Marquette
|
<input style="border: 0px solid white;" size="30" name="diskusagemeter" id="diskusagemeter" value="<?= $diskusage.'%'; ?>" />
|
245 |
d772ac32
|
Erik Kristensen
|
</td>
|
246 |
|
|
</tr>
|
247 |
|
|
</tbody>
|
248 |
|
|
</table>
|
249 |
1df0159c
|
Erik Kristensen
|
</form>
|
250 |
d772ac32
|
Erik Kristensen
|
</div>
|
251 |
561d55ff
|
Erik Kristensen
|
|
252 |
d772ac32
|
Erik Kristensen
|
<?php include("fend.inc"); ?>
|
253 |
7f1f5492
|
Scott Ullrich
|
|
254 |
|
|
<script type="text/javascript">
|
255 |
d772ac32
|
Erik Kristensen
|
NiftyCheck();
|
256 |
|
|
Rounded("div#nifty","top","#FFF","#EEEEEE","smooth");
|
257 |
7f1f5492
|
Scott Ullrich
|
</script>
|
258 |
1df0159c
|
Erik Kristensen
|
|
259 |
5b237745
|
Scott Ullrich
|
</body>
|
260 |
561d55ff
|
Erik Kristensen
|
</html>
|