Project

General

Profile

Download (16.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    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
    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
	## Load Essential Includes
35
	require_once('guiconfig.inc');
36
	require_once('notices.inc');
37

    
38

    
39
	## Load Functions Files
40
	require_once('includes/functions.inc.php');
41

    
42

    
43
	## Load AJAX, Initiate Class ###############################################
44
	require_once('includes/sajax.class.php');
45

    
46
	## 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
	$oSajax->sajax_export("get_stats");
53
	$oSajax->sajax_handle_client_request();
54
	############################################################################
55

    
56

    
57
	## Check to see if we have a swap space,
58
	## if true, display, if false, hide it ...
59
	if(file_exists("/usr/sbin/swapinfo")) {
60
		$swapinfo = `/usr/sbin/swapinfo`;
61
		if(stristr($swapinfo,'%') == true) $showswap=true;
62
	}
63

    
64

    
65
	## User recently restored his config.
66
	## If packages are installed lets resync
67
	if(file_exists('/conf/needs_package_sync')) {
68
		if($config['installedpackages'] <> '') {
69
			conf_mount_rw();
70
			unlink('/conf/needs_package_sync');
71
			header('Location: pkg_mgr_install.php?mode=reinstallall');
72
			exit;
73
		}
74
	}
75

    
76

    
77
	## If it is the first time webGUI has been
78
	## accessed since initial install show this stuff.
79
	if(file_exists('/conf/trigger_initial_wizard')) {
80

    
81
		$pgtitle = 'pfSense first time setup';
82
		include('head.inc');
83

    
84
		echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
85
		echo "<form>\n";
86
		echo "<center>\n";
87
		echo "<img src=\"/themes/{$g['theme']}/images/logo.gif\" border=\"0\"><p>\n";
88
		echo "<div \" style=\"width:700px;background-color:#ffffff\" id=\"nifty\">\n";
89
		echo "Welcome to pfSense!<p>\n";
90
		echo "One moment while we start the initial setup wizard.<p>\n";
91
		echo "Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal gui.<p>\n";
92
		echo "To bypass the wizard, click on the pfSense wizard on the initial page.\n";
93
		echo "</div>\n";
94
		echo "<meta http-equiv=\"refresh\" content=\"1;url=wizard.php?xml=setup_wizard.xml\">\n";
95
		echo "<script type=\"text/javascript\">\n";
96
		echo "NiftyCheck();\n";
97
		echo "Rounded(\"div#nifty\",\"all\",\"#000\",\"#FFFFFF\",\"smooth\");\n";
98
		echo "</script>\n";
99
		exit;
100
	}
101

    
102

    
103
	## Find out whether there's hardware encryption or not
104
	unset($hwcrypto);
105
	$fd = @fopen("{$g['varlog_path']}/dmesg.boot", "r");
106
	if ($fd) {
107
		while (!feof($fd)) {
108
			$dmesgl = fgets($fd);
109
			if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)) {
110
				$hwcrypto = $matches[1];
111
				break;
112
			}
113
		}
114
		fclose($fd);
115
	}
116

    
117
	//set variables for traffic graph
118
	$width = "300";
119
	$height = "150";
120
	
121
	//set variables for log
122
	$system_logfile = "{$g['varlog_path']}/system.log";
123
	
124
$jscriptstr = <<<EOD
125
<script type="text/javascript">
126

    
127
function showgraph(incInterface){
128

    
129
	d = document;	
130
	var tempArray = incInterface.split("-");
131
	selectInt = tempArray[1];
132
	realInt = tempArray[0];
133
	tr = d.getElementById(selectInt);
134

    
135
	div = d.createElement("div");
136
	selectIntID = selectInt + "graphdiv";
137
	div.setAttribute ('id', selectIntID);
138
	div.innerHTML= "<embed id='" + selectIntID + "' name='graph' src='graph.php?ifnum=" + realInt + "&ifname=" + selectInt + "' type='image/svg+xml' width='$width' height='$height' pluginspage='http://www.adobe.com/svg/viewer/install/auto' />";
139
	tr.appendChild(div);
140
	selectIntLink = selectInt + "graphlink";
141
	textlink = d.getElementById(selectIntLink);
142
	textlink.parentNode.removeChild(textlink);
143
	
144
	selectIntID = selectInt + "closegraph";
145
	closelink = d.getElementById(selectIntID);
146
	closelink.style.display="block";
147
	
148
}
149

    
150
function closegraph(incInterface, imagelocation){
151
	d = document;	
152
	var tempArray = incInterface.split("-");
153
	selectInt = tempArray[1];
154
	realInt = tempArray[0];
155
	selectIntLink = selectInt + "graphdiv";
156
	close = d.getElementById(selectIntLink);
157
	close.parentNode.removeChild(close);
158
		
159
	selectIntLink = selectInt + "closegraph";
160
	closelink = d.getElementById(selectIntLink);
161
	closelink.style.display = "none";
162
	tr = d.getElementById(selectInt);
163
	span = d.createElement("div");
164
	selectedIntID = selectInt + "graphlink";
165
	span.setAttribute ('id', selectedIntID);
166
	onclick = "return showgraph('" + realInt + "-" + selectInt + "')";
167
	span.setAttribute ("onclick", onclick);
168
	span.innerHTML = "<center><img src='" + imagelocation + "' height='32' width='28' border='0' align='middle' alt='Click here to show current " + selectInt + " traffic'' /></center>";
169
	
170
	tr.appendChild(span);			
171
	
172
}
173
	
174
</script>
175
EOD;
176

    
177
	## Set Page Title and Include Header
178
	$pgtitle = "pfSense webGUI";
179
	include("head.inc");
180
?>
181

    
182
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
183
<script language="javascript">
184
var ajaxStarted = false;
185
</script>
186
<?php
187
include("fbegin.inc");
188
echo $jscriptstr;
189
	if(!file_exists("/usr/local/www/themes/{$g['theme']}/no_big_logo"))
190
		echo "<center><img src=\"./themes/".$g['theme']."/images/logobig.jpg\"></center><br>";
191
?>
192
<p class="pgtitle">System Overview</p>
193

    
194
<div id="niftyOutter">
195
<form action="index.php" method="post">
196
<table  width="100%" border="0" cellspacing="0" cellpadding="5">
197
		<tr>
198
			<td valign="top">
199
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
200
				<tbody>
201
				<tr>
202
					<td colspan="2" class="listtopic">System information</td>
203
				</tr>
204
				<tr>
205
					<td width="25%" class="vncellt">Name</td>
206
					<td width="75%" class="listr"><?php echo $config['system']['hostname'] . "." . $config['system']['domain']; ?></td>
207
				</tr>
208
				<tr>
209
					<td width="25%" valign="top" class="vncellt">Version</td>
210
					<td width="75%" class="listr">
211
						<strong><?php readfile("/etc/version"); ?></strong>
212
						<br />
213
						built on <?php readfile("/etc/version.buildtime"); ?>
214
					</td>
215
				</tr>
216
				<tr>
217
					<td width="25%" class="vncellt">Platform</td>
218
					<td width="75%" class="listr"><?=htmlspecialchars($g['platform']);?></td>
219
				</tr>
220
				<tr>
221
					<td width="25%" class="vncellt">CPU Type</td>
222
					<td width="75%" class="listr">
223
					<?php 
224
						$cpumodel = "";
225
						exec("/sbin/sysctl -n hw.model", $cpumodel);
226
						$cpumodel = implode(" ", $cpumodel);
227
						echo (htmlspecialchars($cpumodel)); ?>
228
					</td>
229
				</tr>
230
				<?php if ($hwcrypto): ?>
231
				<tr>
232
					<td width="25%" class="vncellt">Hardware crypto</td>
233
					<td width="75%" class="listr"><?=htmlspecialchars($hwcrypto);?></td>
234
				</tr>
235
				<?php endif; ?>
236
				<tr>
237
					<td width="25%" class="vncellt">Uptime</td>
238
					<td width="75%" class="listr"><input style="border: 0px solid white;" size="30" name="uptime" id="uptime" value="<?= htmlspecialchars(get_uptime()); ?>" /></td>
239
				</tr>			
240
				 <tr>
241
		             <td width="30%" class="vncellt">DNS server(s)</td>
242
		             <td width="70%" class="listr">
243
							<?php
244
								$dns_servers = get_dns_servers();
245
								foreach($dns_servers as $dns) {
246
									echo "{$dns}<br>";
247
								}
248
							?>
249
					</td>
250
				</tr>	
251
				<?php if ($config['lastchange']): ?>
252
				<tr>
253
					<td width="25%" class="vncellt">Last config change</td>
254
					<td width="75%" class="listr"><?= htmlspecialchars(date("D M j G:i:s T Y", $config['revision']['time']));?></td>
255
				</tr>
256
				<?php endif; ?>
257
				<tr>
258
					<td width="25%" class="vncellt">State table size</td>
259
					<td width="75%" class="listr">
260
						<input style="border: 0px solid white;" size="30" name="pfstate" id="pfstate" value="<?= htmlspecialchars(get_pfstate()); ?>" />
261
				    	<br />
262
				    	<a href="diag_dump_states.php">Show states</a>
263
					</td>
264
				</tr>
265
				<tr>
266
					<td width="25%" class="vncellt">CPU usage</td>
267
					<td width="75%" class="listr">
268
						<?php $cpuUsage = "0"; ?>
269
						<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" />
270
						&nbsp;
271
						<input style="border: 0px solid white;" size="30" name="cpumeter" id="cpumeter" value="(Updating in 5 seconds)" />
272
					</td>
273
				</tr>
274
				<tr>
275
					<td width="25%" class="vncellt">Memory usage</td>
276
					<td width="75%" class="listr">
277
						<?php $memUsage = mem_usage(); ?>
278
						<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" />
279
						&nbsp;
280
						<input style="border: 0px solid white;" size="30" name="memusagemeter" id="memusagemeter" value="<?= $memUsage.'%'; ?>" />
281
					</td>
282
				</tr>
283
				<?php if($showswap == true): ?>
284
				<tr>
285
					<td width="25%" class="vncellt">SWAP usage</td>
286
					<td width="75%" class="listr">
287
						<?php $swapusage = swap_usage(); ?>
288
						<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" />
289
						&nbsp;
290
						<input style="border: 0px solid white;" size="30" name="swapusagemeter" id="swapusagemeter" value="<?= $swapusage.'%'; ?>" />
291
					</td>
292
				</tr>
293
				<?php endif; ?>
294
		<?php
295
				if(has_temp()):
296
		?>
297
				<tr>
298
					<td width='25%' class='vncellt'>Temperature</td>
299
					<td width='75%' class='listr'>
300
						<?php $temp = get_temp(); ?>
301
						<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="tempwidtha" id="tempwidtha" width="<?= $temp; ?>" border="0" align="middle" alt="red bar" /><img src="./themes/<?= $g["theme"]; ?>/images/misc/bar_gray.gif" height="15" name="tempwidthb" id="tempwidthb" width="<?= (100 - $temp); ?>" 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" />
302
						&nbsp;
303
						<input style="border: 0px solid white;" size="30" name="tempmeter" id="tempmeter" value="<?= $temp."C"; ?>" />
304
					</td>
305
				</tr>
306
				<?php endif; ?>
307
				<tr>
308
					<td width="25%" class="vncellt">Disk usage</td>
309
					<td width="75%" class="listr">
310
						<?php $diskusage = disk_usage(); ?>
311
						<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" />
312
						&nbsp;
313
						<input style="border: 0px solid white;" size="30" name="diskusagemeter" id="diskusagemeter" value="<?= $diskusage.'%'; ?>" />
314
					</td>
315
				</tr>
316
				<tr><td>&nbsp;</td></tr>
317
				<tr>
318
					<td  colspan="2" class="listtopic">Last 5 System Logs</td>
319
				</tr>
320
				<tr>
321
						<?php
322
						//show logs here
323
						dump_clog($system_logfile, 5, true, array(), array("racoon", "ntpd", "pppoe"));
324
						?>
325
				</tr>		
326
			</tbody>
327
		</table>
328
		</td>
329
		<td valign="top">
330
			<table width="100%" border="0" cellspacing="0" cellpadding="0" id="wangraphtable">
331
			<tbody>
332
					<?php $i = 0; $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
333
					for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
334
						$ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
335
					}
336
					$firstgraphshown = false;
337
					foreach ($ifdescrs as $ifdescr => $ifname){
338
						$ifinfo = get_interface_info($ifdescr);					
339
						$ifnum = convert_friendly_interface_to_real_interface_name($ifname);
340
						
341
					 if ($ifinfo['status'] != "down"){ 					
342
					?>
343
					<tr>
344
					<td class="listtopic" colspan="2">Current <?=$ifname;?> Traffic
345
						<div id="<?=$ifname;?>closegraph" align="right" onclick='return closegraph("<?php echo $ifnum; echo "-"; echo $ifname; ?>","./themes/<?= $g['theme']; ?>/images/icons/icon_check.gif")' style="display:<?php if(!$firstgraphshown)echo "block";else echo "none";?>">[close graph]</div>
346
					</td>
347
					</tr>
348
					<tr>
349
						<td id="<?=$ifname;?>" valign="middle"><?php 
350
						
351
						 if (get_cpu_speed() >= 500) { 
352
						 	if(!$firstgraphshown){
353
						 	?>
354
							<div id="<?=$ifname;?>graphdiv">
355
								<embed id="graph" src="graph.php?ifnum=<?=$ifnum;?>&ifname=<?=rawurlencode($ifname);?>" type="image/svg+xml" width="<? echo $width; ?>" height="<? echo $height; ?>" pluginspage="http://www.adobe.com/svg/viewer/install/auto" />
356
							</div>
357
						<?
358
							$firstgraphshown = true;
359
							}
360
							else
361
							{ ?>
362
								<div  id="<?=$ifname;?>graphlink" onclick='return showgraph("<?php echo $ifnum; echo "-"; echo $ifname; ?>");'><center><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_check.gif" height="32" width="28" border="0" align="middle" alt="Click here to show current <?=$ifname;?> traffic" /></center></div>
363
							<? }
364
						 } else { ?>
365
								<div id="<?=$ifname;?>graphlink" onclick='return showgraph("<?php echo $ifnum; echo "-"; echo $ifname; ?>");'><center><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_check.gif" height="32" width="28" border="0" align="middle" alt="Click here to show current <?=$ifname;?> traffic" /></center></div>
366
						<? } ?>
367
						</td>
368
					</tr><tr><td>&nbsp;</td></tr>
369
					 <? } 
370
					}?>	
371
					
372
				</tbody>
373
			</table><br>
374
			<table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0">
375
				<tr>
376
					<td colspan="2" class="listtopic">Interfaces</td>
377
				</tr> 
378
				<?php foreach ($ifdescrs as $ifdescr => $ifname){
379
						$ifinfo = get_interface_info($ifdescr);
380
					?>
381
					<tr> 
382
					<?php if ($ifinfo['status'] != "down"){ ?>
383
					<td class="vncellt" width="30%"><strong><?=htmlspecialchars($ifname);?></strong></td>
384
					<td width="70%"  class="listr">
385
					
386
					  <?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"){ ?>
387
					  <?php if ($ifinfo['ipaddr']){ ?>
388
		                  <?=htmlspecialchars($ifinfo['ipaddr']);?>
389
		                  &nbsp; </td>
390
		            </tr><?php }
391
					  			}
392
					  		}
393
					  } 					?> 
394
				</table>
395
			</td>	
396
	</tr>
397
</tbody>
398
</table>
399
</form>
400
</div>
401

    
402
<?php include("fend.inc"); ?>
403
	    
404
<script type="text/javascript">
405
	NiftyCheck();
406
	Rounded("div#nifty","top","#FFF","#EEEEEE","smooth");
407
</script>
408

    
409
<meta http-equiv="refresh" content="120;url=<?php print $_SERVER['PHP_SELF']; ?>">
410

    
411
</body>
412
</html>
(68-68/175)