1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
2cd6010c
|
Scott Ullrich
|
<?php
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
index.php
|
5 |
a0c57a44
|
Scott Ullrich
|
Copyright (C) 2004 Scott Ullrich
|
6 |
|
|
All rights reserved.
|
7 |
2cd6010c
|
Scott Ullrich
|
|
8 |
a0c57a44
|
Scott Ullrich
|
Originally part of m0n0wall (http://m0n0.ch/wall)
|
9 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10 |
|
|
All rights reserved.
|
11 |
2cd6010c
|
Scott Ullrich
|
|
12 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
13 |
|
|
modification, are permitted provided that the following conditions are met:
|
14 |
2cd6010c
|
Scott Ullrich
|
|
15 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
16 |
|
|
this list of conditions and the following disclaimer.
|
17 |
2cd6010c
|
Scott Ullrich
|
|
18 |
5b237745
|
Scott Ullrich
|
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 |
2cd6010c
|
Scott Ullrich
|
|
22 |
5b237745
|
Scott Ullrich
|
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 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27 |
|
|
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 |
|
|
*/
|
33 |
|
|
|
34 |
bf787c0a
|
Scott Ullrich
|
if(file_exists("/usr/local/www/trigger_initial_wizard")) {
|
35 |
|
|
system("rm /usr/local/www/trigger_initial_wizard");
|
36 |
2b757be5
|
Scott Ullrich
|
header("Location: wizard.php?xml=setup_wizard.xml");
|
37 |
bf787c0a
|
Scott Ullrich
|
}
|
38 |
|
|
|
39 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
40 |
|
|
|
41 |
|
|
/* find out whether there's hardware encryption (hifn) */
|
42 |
|
|
unset($hwcrypto);
|
43 |
|
|
$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
|
44 |
|
|
if ($fd) {
|
45 |
|
|
while (!feof($fd)) {
|
46 |
|
|
$dmesgl = fgets($fd);
|
47 |
|
|
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)) {
|
48 |
|
|
$hwcrypto = $matches[1];
|
49 |
|
|
break;
|
50 |
|
|
}
|
51 |
|
|
}
|
52 |
|
|
fclose($fd);
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
?>
|
56 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
57 |
|
|
<html>
|
58 |
|
|
<head>
|
59 |
|
|
<title><?=gentitle("m0n0wall webGUI");?></title>
|
60 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
61 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
62 |
|
|
</head>
|
63 |
|
|
|
64 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
65 |
|
|
<?php include("fbegin.inc"); ?>
|
66 |
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
67 |
2cd6010c
|
Scott Ullrich
|
<tr align="center" valign="top">
|
68 |
5b237745
|
Scott Ullrich
|
<td height="10" colspan="2"> </td>
|
69 |
|
|
</tr>
|
70 |
2cd6010c
|
Scott Ullrich
|
<tr align="center" valign="top">
|
71 |
|
|
<td height="170" colspan="2"><img src="logobig.gif"></td>
|
72 |
5b237745
|
Scott Ullrich
|
</tr>
|
73 |
2cd6010c
|
Scott Ullrich
|
<tr>
|
74 |
5b237745
|
Scott Ullrich
|
<td colspan="2" class="listtopic">System information</td>
|
75 |
|
|
</tr>
|
76 |
2cd6010c
|
Scott Ullrich
|
<tr>
|
77 |
5b237745
|
Scott Ullrich
|
<td width="25%" class="vncellt">Name</td>
|
78 |
|
|
<td width="75%" class="listr">
|
79 |
|
|
<?php echo $config['system']['hostname'] . "." . $config['system']['domain']; ?>
|
80 |
|
|
</td>
|
81 |
|
|
</tr>
|
82 |
2cd6010c
|
Scott Ullrich
|
<tr>
|
83 |
5b237745
|
Scott Ullrich
|
<td width="25%" valign="top" class="vncellt">Version</td>
|
84 |
2cd6010c
|
Scott Ullrich
|
<td width="75%" class="listr"> <strong>
|
85 |
5b237745
|
Scott Ullrich
|
<?php readfile("/etc/version"); ?>
|
86 |
|
|
</strong><br>
|
87 |
2cd6010c
|
Scott Ullrich
|
built on
|
88 |
5b237745
|
Scott Ullrich
|
<?php readfile("/etc/version.buildtime"); ?>
|
89 |
|
|
</td>
|
90 |
|
|
</tr>
|
91 |
2cd6010c
|
Scott Ullrich
|
<tr>
|
92 |
5b237745
|
Scott Ullrich
|
<td width="25%" class="vncellt">Platform</td>
|
93 |
2cd6010c
|
Scott Ullrich
|
<td width="75%" class="listr">
|
94 |
5b237745
|
Scott Ullrich
|
<?=htmlspecialchars($g['platform']);?>
|
95 |
|
|
</td>
|
96 |
|
|
</tr><?php if ($hwcrypto): ?>
|
97 |
2cd6010c
|
Scott Ullrich
|
<tr>
|
98 |
5b237745
|
Scott Ullrich
|
<td width="25%" class="vncellt">Hardware crypto</td>
|
99 |
2cd6010c
|
Scott Ullrich
|
<td width="75%" class="listr">
|
100 |
5b237745
|
Scott Ullrich
|
<?=htmlspecialchars($hwcrypto);?>
|
101 |
|
|
</td>
|
102 |
|
|
</tr><?php endif; ?>
|
103 |
2cd6010c
|
Scott Ullrich
|
<tr>
|
104 |
5b237745
|
Scott Ullrich
|
<td width="25%" class="vncellt">Uptime</td>
|
105 |
2cd6010c
|
Scott Ullrich
|
<td width="75%" class="listr">
|
106 |
5b237745
|
Scott Ullrich
|
<?php
|
107 |
|
|
exec("/sbin/sysctl -n kern.boottime", $boottime);
|
108 |
|
|
preg_match("/sec = (\d+)/", $boottime[0], $matches);
|
109 |
|
|
$boottime = $matches[1];
|
110 |
|
|
$uptime = time() - $boottime;
|
111 |
2cd6010c
|
Scott Ullrich
|
|
112 |
5b237745
|
Scott Ullrich
|
if ($uptime > 60)
|
113 |
|
|
$uptime += 30;
|
114 |
|
|
$updays = (int)($uptime / 86400);
|
115 |
|
|
$uptime %= 86400;
|
116 |
|
|
$uphours = (int)($uptime / 3600);
|
117 |
|
|
$uptime %= 3600;
|
118 |
|
|
$upmins = (int)($uptime / 60);
|
119 |
2cd6010c
|
Scott Ullrich
|
|
120 |
5b237745
|
Scott Ullrich
|
$uptimestr = "";
|
121 |
|
|
if ($updays > 1)
|
122 |
|
|
$uptimestr .= "$updays days, ";
|
123 |
|
|
else if ($updays > 0)
|
124 |
|
|
$uptimestr .= "1 day, ";
|
125 |
|
|
$uptimestr .= sprintf("%02d:%02d", $uphours, $upmins);
|
126 |
|
|
echo htmlspecialchars($uptimestr);
|
127 |
|
|
?>
|
128 |
|
|
</td>
|
129 |
|
|
</tr><?php if ($config['lastchange']): ?>
|
130 |
2cd6010c
|
Scott Ullrich
|
<tr>
|
131 |
5b237745
|
Scott Ullrich
|
<td width="25%" class="vncellt">Last config change</td>
|
132 |
2cd6010c
|
Scott Ullrich
|
<td width="75%" class="listr">
|
133 |
5b237745
|
Scott Ullrich
|
<?=htmlspecialchars(date("D M j G:i:s T Y", $config['lastchange']));?>
|
134 |
|
|
</td>
|
135 |
|
|
</tr><?php endif; ?>
|
136 |
2cd6010c
|
Scott Ullrich
|
<tr>
|
137 |
5b237745
|
Scott Ullrich
|
<td width="25%" class="vncellt">CPU usage</td>
|
138 |
|
|
<td width="75%" class="listr">
|
139 |
|
|
<?php
|
140 |
|
|
$cpuTicks = explode(" ", `/sbin/sysctl -n kern.cp_time`);
|
141 |
|
|
sleep(1);
|
142 |
|
|
$cpuTicks2 = explode(" ", `/sbin/sysctl -n kern.cp_time`);
|
143 |
|
|
|
144 |
|
|
$diff = array();
|
145 |
|
|
$diff['user'] = $cpuTicks2[0] - $cpuTicks[0];
|
146 |
|
|
$diff['nice'] = $cpuTicks2[1] - $cpuTicks[1];
|
147 |
|
|
$diff['sys'] = $cpuTicks2[2] - $cpuTicks[2];
|
148 |
|
|
$diff['intr'] = $cpuTicks2[3] - $cpuTicks[3];
|
149 |
|
|
$diff['idle'] = $cpuTicks2[4] - $cpuTicks[4];
|
150 |
|
|
|
151 |
|
|
$totalDiff = $diff['user'] + $diff['nice'] + $diff['sys'] + $diff['intr'] + $diff['idle'];
|
152 |
|
|
|
153 |
|
|
$cpuUsage = round(100 * (1 - $diff['idle'] / $totalDiff), 0);
|
154 |
2cd6010c
|
Scott Ullrich
|
|
155 |
5b237745
|
Scott Ullrich
|
echo "<img src='bar_left.gif' height='15' width='4' border='0' align='absmiddle'>";
|
156 |
|
|
echo "<img src='bar_blue.gif' height='15' width='" . $cpuUsage . "' border='0' align='absmiddle'>";
|
157 |
|
|
echo "<img src='bar_gray.gif' height='15' width='" . (100 - $cpuUsage) . "' border='0' align='absmiddle'>";
|
158 |
|
|
echo "<img src='bar_right.gif' height='15' width='5' border='0' align='absmiddle'> ";
|
159 |
|
|
echo $cpuUsage . "%";
|
160 |
|
|
?>
|
161 |
|
|
</td>
|
162 |
|
|
</tr>
|
163 |
2cd6010c
|
Scott Ullrich
|
<tr>
|
164 |
5b237745
|
Scott Ullrich
|
<td width="25%" class="vncellt">Memory usage</td>
|
165 |
|
|
<td width="75%" class="listr">
|
166 |
|
|
<?php
|
167 |
|
|
|
168 |
|
|
exec("/sbin/sysctl -n vm.stats.vm.v_active_count vm.stats.vm.v_inactive_count " .
|
169 |
|
|
"vm.stats.vm.v_wire_count vm.stats.vm.v_cache_count vm.stats.vm.v_free_count", $memory);
|
170 |
|
|
|
171 |
|
|
$totalMem = $memory[0] + $memory[1] + $memory[2] + $memory[3] + $memory[4];
|
172 |
|
|
$freeMem = $memory[4];
|
173 |
|
|
$usedMem = $totalMem - $freeMem;
|
174 |
|
|
$memUsage = round(($usedMem * 100) / $totalMem, 0);
|
175 |
2cd6010c
|
Scott Ullrich
|
|
176 |
5b237745
|
Scott Ullrich
|
echo " <img src='bar_left.gif' height='15' width='4' border='0' align='absmiddle'>";
|
177 |
|
|
echo "<img src='bar_blue.gif' height='15' width='" . $memUsage . "' border='0' align='absmiddle'>";
|
178 |
|
|
echo "<img src='bar_gray.gif' height='15' width='" . (100 - $memUsage) . "' border='0' align='absmiddle'>";
|
179 |
|
|
echo "<img src='bar_right.gif' height='15' width='5' border='0' align='absmiddle'> ";
|
180 |
|
|
echo $memUsage . "%";
|
181 |
|
|
?>
|
182 |
|
|
</td>
|
183 |
|
|
</tr>
|
184 |
|
|
</table>
|
185 |
|
|
<?php include("fend.inc"); ?>
|
186 |
|
|
</body>
|
187 |
|
|
</html>
|