Project

General

Profile

Download (6.97 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	index.php
5
        Copyright (C) 2004 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
	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
if(file_exists("/usr/local/www/trigger_initial_wizard")) {
35
	system("rm /usr/local/www/trigger_initial_wizard");
36
	header("Location:  wizard.php?xml=setup_wizard.xml");
37
}
38

    
39
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
              <tr align="center" valign="top">
68
                <td height="10" colspan="2">&nbsp;</td>
69
              </tr>
70
              <tr align="center" valign="top">
71
                <td height="170" colspan="2"><img src="logobig.gif"></td>
72
              </tr>
73
              <tr>
74
                <td colspan="2" class="listtopic">System information</td>
75
              </tr>
76
              <tr>
77
                <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
              <tr>
83
                <td width="25%" valign="top" class="vncellt">Version</td>
84
                <td width="75%" class="listr"> <strong>
85
                  <?php readfile("/etc/version"); ?>
86
                  </strong><br>
87
                  built on
88
                  <?php readfile("/etc/version.buildtime"); ?>
89
                </td>
90
              </tr>
91
              <tr>
92
                <td width="25%" class="vncellt">Platform</td>
93
                <td width="75%" class="listr">
94
                  <?=htmlspecialchars($g['platform']);?>
95
                </td>
96
              </tr><?php if ($hwcrypto): ?>
97
              <tr>
98
                <td width="25%" class="vncellt">Hardware crypto</td>
99
                <td width="75%" class="listr">
100
                  <?=htmlspecialchars($hwcrypto);?>
101
                </td>
102
              </tr><?php endif; ?>
103
              <tr>
104
                <td width="25%" class="vncellt">Uptime</td>
105
                <td width="75%" class="listr">
106
                  <?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

    
112
					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

    
120
					$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
              <tr>
131
                <td width="25%" class="vncellt">Last config change</td>
132
                <td width="75%" class="listr">
133
                  <?=htmlspecialchars(date("D M j G:i:s T Y", $config['lastchange']));?>
134
                </td>
135
              </tr><?php endif; ?>
136
			  <tr>
137
                <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

    
155
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
			  <tr>
164
                <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

    
176
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>
(40-40/98)