1
|
<?php
|
2
|
/*
|
3
|
$Id$
|
4
|
Copyright 2007 Scott Dale
|
5
|
Part of pfSense widgets (https://www.pfsense.org)
|
6
|
originally based on m0n0wall (http://m0n0.ch/wall)
|
7
|
|
8
|
Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
|
9
|
and Jonathan Watt <jwatt@jwatt.org>.
|
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
|
require_once("functions.inc");
|
35
|
require_once("guiconfig.inc");
|
36
|
require_once('notices.inc');
|
37
|
include_once("includes/functions.inc.php");
|
38
|
|
39
|
if($_REQUEST['getupdatestatus']) {
|
40
|
if(isset($config['system']['firmware']['disablecheck'])) {
|
41
|
exit;
|
42
|
}
|
43
|
if(isset($config['system']['firmware']['alturl']['enable']))
|
44
|
$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
|
45
|
else
|
46
|
$updater_url = $g['update_url'];
|
47
|
|
48
|
$nanosize = "";
|
49
|
if ($g['platform'] == "nanobsd") {
|
50
|
if (file_exists("/etc/nano_use_vga.txt"))
|
51
|
$nanosize = "-nanobsd-vga-";
|
52
|
else
|
53
|
$nanosize = "-nanobsd-";
|
54
|
$nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt")));
|
55
|
}
|
56
|
|
57
|
@unlink("/tmp/{$g['product_name']}_version");
|
58
|
if (download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true)
|
59
|
$remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version"));
|
60
|
|
61
|
if(empty($remote_version))
|
62
|
echo "<br /><br />Unable to check for updates.";
|
63
|
else {
|
64
|
$current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime"));
|
65
|
$current_installed_version = trim(file_get_contents("/etc/version"));
|
66
|
|
67
|
if(!$remote_version) {
|
68
|
echo "<br /><br />Unable to check for updates.";
|
69
|
}
|
70
|
else {
|
71
|
$needs_system_upgrade = false;
|
72
|
if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $remote_version) == -1) {
|
73
|
echo "<br /><span class=\"red\" id=\"updatealert\"><b>Update available. </b></span><a href=\"/system_firmware_check.php\">Click Here</a> to view update.";
|
74
|
echo "\n<script type=\"text/javascript\">\n";
|
75
|
echo "//<![CDATA[\n";
|
76
|
echo "jQuery('#updatealert').effect('pulsate',{times: 30},10000);\n";
|
77
|
echo "//]]>\n";
|
78
|
echo "</script>\n";
|
79
|
} else
|
80
|
echo "<br />You are on the latest version.";
|
81
|
}
|
82
|
}
|
83
|
exit;
|
84
|
}
|
85
|
|
86
|
$curcfg = $config['system']['firmware'];
|
87
|
|
88
|
$filesystems = get_mounted_filesystems();
|
89
|
|
90
|
?>
|
91
|
<script type="text/javascript">
|
92
|
//<![CDATA[
|
93
|
jQuery(function() {
|
94
|
jQuery("#statePB").progressbar( { value: <?php echo get_pfstate(true); ?> } );
|
95
|
jQuery("#mbufPB").progressbar( { value: <?php echo get_mbuf(true); ?> } );
|
96
|
jQuery("#cpuPB").progressbar( { value:false } );
|
97
|
jQuery("#memUsagePB").progressbar( { value: <?php echo mem_usage(); ?> } );
|
98
|
|
99
|
<?PHP $d = 0; ?>
|
100
|
<?PHP foreach ($filesystems as $fs): ?>
|
101
|
jQuery("#diskUsagePB<?php echo $d++; ?>").progressbar( { value: <?php echo $fs['percent_used']; ?> } );
|
102
|
<?PHP endforeach; ?>
|
103
|
|
104
|
<?php if($showswap == true): ?>
|
105
|
jQuery("#swapUsagePB").progressbar( { value: <?php echo swap_usage(); ?> } );
|
106
|
<?php endif; ?>
|
107
|
<?php if (get_temp() != ""): ?>
|
108
|
jQuery("#tempPB").progressbar( { value: <?php echo get_temp(); ?> } );
|
109
|
<?php endif; ?>
|
110
|
});
|
111
|
//]]>
|
112
|
</script>
|
113
|
|
114
|
<table width="100%" border="0" cellspacing="0" cellpadding="0" summary="system information">
|
115
|
<tbody>
|
116
|
<tr>
|
117
|
<td width="25%" class="vncellt"><?=gettext("Name");?></td>
|
118
|
<td width="75%" class="listr"><?php echo $config['system']['hostname'] . "." . $config['system']['domain']; ?></td>
|
119
|
</tr>
|
120
|
<tr>
|
121
|
<td width="25%" valign="top" class="vncellt"><?=gettext("Version");?></td>
|
122
|
<td width="75%" class="listr">
|
123
|
<strong><?php readfile("/etc/version"); ?></strong>
|
124
|
(<?php echo php_uname("m"); ?>)
|
125
|
<br />
|
126
|
built on <?php readfile("/etc/version.buildtime"); ?>
|
127
|
<?php if(!$g['hideuname']): ?>
|
128
|
<br />
|
129
|
<div id="uname"><a href="#" onclick='swapuname(); return false;'><?php echo php_uname("s") . " " . php_uname("r"); ?></a></div>
|
130
|
<?php endif; ?>
|
131
|
<?php if(!isset($config['system']['firmware']['disablecheck'])): ?>
|
132
|
<div id='updatestatus'><br /><?php echo gettext("Obtaining update status"); ?> ...</div>
|
133
|
<?php endif; ?>
|
134
|
</td>
|
135
|
</tr>
|
136
|
<?php if(!$g['hideplatform']): ?>
|
137
|
<tr>
|
138
|
<td width="25%" class="vncellt"><?=gettext("Platform");?></td>
|
139
|
<td width="75%" class="listr">
|
140
|
<?=htmlspecialchars($g['platform']);?>
|
141
|
<?php if (($g['platform'] == "nanobsd") && (file_exists("/etc/nanosize.txt"))) {
|
142
|
echo " (" . htmlspecialchars(trim(file_get_contents("/etc/nanosize.txt"))) . ")";
|
143
|
} ?>
|
144
|
</td>
|
145
|
</tr>
|
146
|
<?php endif; ?>
|
147
|
<?php if ($g['platform'] == "nanobsd"): ?>
|
148
|
<?
|
149
|
global $SLICE, $OLDSLICE, $TOFLASH, $COMPLETE_PATH, $COMPLETE_BOOT_PATH;
|
150
|
global $GLABEL_SLICE, $UFS_ID, $OLD_UFS_ID, $BOOTFLASH;
|
151
|
global $BOOT_DEVICE, $REAL_BOOT_DEVICE, $BOOT_DRIVE, $ACTIVE_SLICE;
|
152
|
nanobsd_detect_slice_info();
|
153
|
$rw = is_writable("/") ? "(rw)" : "(ro)";
|
154
|
?>
|
155
|
<tr>
|
156
|
<td width="25%" class="vncellt"><?=gettext("NanoBSD Boot Slice");?></td>
|
157
|
<td width="75%" class="listr">
|
158
|
<?=htmlspecialchars(nanobsd_friendly_slice_name($BOOT_DEVICE));?> / <?=htmlspecialchars($BOOTFLASH);?> <?php echo $rw; ?>
|
159
|
<?php if ($BOOTFLASH != $ACTIVE_SLICE): ?>
|
160
|
<br /><br />Next Boot:<br />
|
161
|
<?=htmlspecialchars(nanobsd_friendly_slice_name($GLABEL_SLICE));?> / <?=htmlspecialchars($ACTIVE_SLICE);?>
|
162
|
<?php endif; ?>
|
163
|
</td>
|
164
|
</tr>
|
165
|
<?php endif; ?>
|
166
|
<tr>
|
167
|
<td width="25%" class="vncellt"><?=gettext("CPU Type");?></td>
|
168
|
<td width="75%" class="listr">
|
169
|
<?php
|
170
|
$cpumodel = "";
|
171
|
exec("/sbin/sysctl -n hw.model", $cpumodel);
|
172
|
$cpumodel = implode(" ", $cpumodel);
|
173
|
echo (htmlspecialchars($cpumodel));
|
174
|
?>
|
175
|
<div id="cpufreq"><?= get_cpufreq(); ?></div>
|
176
|
<?php $cpucount = get_cpu_count();
|
177
|
if ($cpucount > 1): ?>
|
178
|
<div id="cpucount">
|
179
|
<?= htmlspecialchars($cpucount) ?> CPUs: <?= htmlspecialchars(get_cpu_count(true)); ?></div>
|
180
|
<?php endif; ?>
|
181
|
</td>
|
182
|
</tr>
|
183
|
<?php if ($hwcrypto): ?>
|
184
|
<tr>
|
185
|
<td width="25%" class="vncellt"><?=gettext("Hardware crypto");?></td>
|
186
|
<td width="75%" class="listr"><?=htmlspecialchars($hwcrypto);?></td>
|
187
|
</tr>
|
188
|
<?php endif; ?>
|
189
|
<tr>
|
190
|
<td width="25%" class="vncellt"><?=gettext("Uptime");?></td>
|
191
|
<td width="75%" class="listr" id="uptime"><?= htmlspecialchars(get_uptime()); ?></td>
|
192
|
</tr>
|
193
|
<tr>
|
194
|
<td width="25%" class="vncellt"><?=gettext("Current date/time");?></td>
|
195
|
<td width="75%" class="listr">
|
196
|
<div id="datetime"><?= date("D M j G:i:s T Y"); ?></div>
|
197
|
</td>
|
198
|
</tr>
|
199
|
<tr>
|
200
|
<td width="30%" class="vncellt"><?=gettext("DNS server(s)");?></td>
|
201
|
<td width="70%" class="listr">
|
202
|
<?php
|
203
|
$dns_servers = get_dns_servers();
|
204
|
foreach($dns_servers as $dns) {
|
205
|
echo "{$dns}<br />";
|
206
|
}
|
207
|
?>
|
208
|
</td>
|
209
|
</tr>
|
210
|
<?php if ($config['revision']): ?>
|
211
|
<tr>
|
212
|
<td width="25%" class="vncellt"><?=gettext("Last config change");?></td>
|
213
|
<td width="75%" class="listr"><?= htmlspecialchars(date("D M j G:i:s T Y", intval($config['revision']['time'])));?></td>
|
214
|
</tr>
|
215
|
<?php endif; ?>
|
216
|
<tr>
|
217
|
<td width="25%" class="vncellt"><?=gettext("State table size");?></td>
|
218
|
<td width="75%" class="listr">
|
219
|
<?php $pfstatetext = get_pfstate();
|
220
|
$pfstateusage = get_pfstate(true);
|
221
|
?>
|
222
|
<div id="statePB"></div>
|
223
|
<span id="pfstateusagemeter"><?= $pfstateusage.'%'; ?></span> (<span id="pfstate"><?= htmlspecialchars($pfstatetext); ?></span>)
|
224
|
<br />
|
225
|
<a href="diag_dump_states.php"><?=gettext("Show states");?></a>
|
226
|
</td>
|
227
|
</tr>
|
228
|
<tr>
|
229
|
<td width="25%" class="vncellt"><?=gettext("MBUF Usage");?></td>
|
230
|
<td width="75%" class="listr">
|
231
|
<?php
|
232
|
$mbufstext = get_mbuf();
|
233
|
$mbufusage = get_mbuf(true);
|
234
|
?>
|
235
|
<div id="mbufPB"></div>
|
236
|
<span id="mbufusagemeter"><?= $mbufusage.'%'; ?></span> (<span id="mbuf"><?= $mbufstext ?></span>)
|
237
|
</td>
|
238
|
</tr>
|
239
|
<?php if (get_temp() != ""): ?>
|
240
|
<tr>
|
241
|
<td width="25%" class="vncellt"><?=gettext("Temperature");?></td>
|
242
|
<td width="75%" class="listr">
|
243
|
<?php $TempMeter = $temp = get_temp(); ?>
|
244
|
<div id="tempPB"></div>
|
245
|
<span id="tempmeter"><?= $temp."°C"; ?></span>
|
246
|
</td>
|
247
|
</tr>
|
248
|
<?php endif; ?>
|
249
|
<tr>
|
250
|
<td width="25%" class="vncellt"><?=gettext("Load average");?></td>
|
251
|
<td width="75%" class="listr">
|
252
|
<div id="load_average" title="Last 1, 5 and 15 minutes"><?= get_load_average(); ?></div>
|
253
|
</td>
|
254
|
</tr>
|
255
|
<tr>
|
256
|
<td width="25%" class="vncellt"><?=gettext("CPU usage");?></td>
|
257
|
<td width="75%" class="listr">
|
258
|
<div id="cpuPB"></div>
|
259
|
<span id="cpumeter">(Updating in 10 seconds)</span>
|
260
|
</td>
|
261
|
</tr>
|
262
|
<tr>
|
263
|
<td width="25%" class="vncellt"><?=gettext("Memory usage");?></td>
|
264
|
<td width="75%" class="listr">
|
265
|
<?php $memUsage = mem_usage(); ?>
|
266
|
<div id="memUsagePB"></div>
|
267
|
<span id="memusagemeter"><?= $memUsage.'%'; ?></span> of <?= sprintf("%.0f", `/sbin/sysctl -n hw.physmem` / (1024*1024)) ?> MB
|
268
|
</td>
|
269
|
</tr>
|
270
|
<?php if($showswap == true): ?>
|
271
|
<tr>
|
272
|
<td width="25%" class="vncellt"><?=gettext("SWAP usage");?></td>
|
273
|
<td width="75%" class="listr">
|
274
|
<?php $swapusage = swap_usage(); ?>
|
275
|
<div id="swapUsagePB"></div>
|
276
|
<span id="swapusagemeter"><?= $swapusage.'%'; ?></span> of <?= sprintf("%.0f", `/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $2;}'`) ?> MB
|
277
|
</td>
|
278
|
</tr>
|
279
|
<?php endif; ?>
|
280
|
<tr>
|
281
|
<td width="25%" class="vncellt"><?=gettext("Disk usage");?></td>
|
282
|
<td width="75%" class="listr">
|
283
|
<?PHP $d = 0; ?>
|
284
|
<?PHP foreach ($filesystems as $fs): ?>
|
285
|
<div id="diskUsagePB<?php echo $d; ?>"></div>
|
286
|
<?PHP if (substr(basename($fs['device']), 0, 2) == "md") $fs['type'] .= " in RAM"; ?>
|
287
|
<?PHP echo "{$fs['mountpoint']} ({$fs['type']})";?>: <span id="diskusagemeter<?php echo $d++ ?>"><?= $fs['percent_used'].'%'; ?></span> of <?PHP echo $fs['total_size'];?>
|
288
|
<br />
|
289
|
<?PHP endforeach; ?>
|
290
|
</td>
|
291
|
</tr>
|
292
|
</tbody>
|
293
|
</table>
|
294
|
<script type="text/javascript">
|
295
|
//<![CDATA[
|
296
|
function swapuname() {
|
297
|
jQuery('#uname').html("<?php echo php_uname("a"); ?>");
|
298
|
}
|
299
|
<?php if(!isset($config['system']['firmware']['disablecheck'])): ?>
|
300
|
function getstatus() {
|
301
|
scroll(0,0);
|
302
|
var url = "/widgets/widgets/system_information.widget.php";
|
303
|
var pars = 'getupdatestatus=yes';
|
304
|
jQuery.ajax(
|
305
|
url,
|
306
|
{
|
307
|
type: 'get',
|
308
|
data: pars,
|
309
|
complete: activitycallback
|
310
|
});
|
311
|
}
|
312
|
function activitycallback(transport) {
|
313
|
// .html() method process all script tags contained in responseText,
|
314
|
// to avoid this we set the innerHTML property
|
315
|
jQuery('#updatestatus').prop('innerHTML',transport.responseText);
|
316
|
}
|
317
|
setTimeout('getstatus()', 4000);
|
318
|
<?php endif; ?>
|
319
|
//]]>
|
320
|
</script>
|