summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Dale <sdale@pfsense.org>2007-05-07 02:48:52 +0000
committerScott Dale <sdale@pfsense.org>2007-05-07 02:48:52 +0000
commitf69aa687d120e863676c6e3e79147b8d8478c58d (patch)
tree0aef66d339bbea0976fb9dda48ad97688db74cf3
parent1db766dfbeaee353cbafbce8926d359454994415 (diff)
downloadpfsense-f69aa687d120e863676c6e3e79147b8d8478c58d.zip
pfsense-f69aa687d120e863676c6e3e79147b8d8478c58d.tar.gz
Widget base. Note: changes to widgets are not saved yet.
-rwxr-xr-xusr/local/www/index.php11
-rw-r--r--usr/local/www/widgets/widgets/system_information.widget.php116
-rw-r--r--usr/local/www/widgets/widgets/traffic_graphs.widget.php49
3 files changed, 169 insertions, 7 deletions
diff --git a/usr/local/www/index.php b/usr/local/www/index.php
index 59809c2..1bbeb0f 100755
--- a/usr/local/www/index.php
+++ b/usr/local/www/index.php
@@ -139,11 +139,11 @@ else
while (false !== ($filename = readdir($dirhandle))) {
$periodpos = strpos($filename, ".");
$widgetname = substr($filename, 0, $periodpos);
- if ($widgetname != "system information")
+ if ($widgetname != "system_information")
$widgetfiles[] = $filename;
}
sort($widgetfiles);
- array_unshift($widgetfiles, "system information.widget.php");
+ array_unshift($widgetfiles, "system_information.widget.php");
}
@@ -274,7 +274,7 @@ echo $jscriptstr;
$periodpos = strpos($widget, ".");
$widgetname = substr($widget, 0, $periodpos);
$nicename = $widgetname;
- $widgetname = str_replace(" ", "", $widgetname);
+ $nicename = str_replace("_", " ", $nicename);
//make the title look nice
$nicename = ucwords($nicename);?>
<span style="cursor: pointer;" onclick='return showDiv("<?php echo $widgetname; ?>div",false)'><u><?php echo $nicename; ?></u></span><br><?php
@@ -288,9 +288,6 @@ echo $jscriptstr;
<p class="pgtitle">System Overview&nbsp;&nbsp;&nbsp;
<img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="Click here to add widgets" style="cursor: help;" onmouseup="domTT_activate(this, event, 'content', document.getElementById('content1'), 'type', 'velcro', 'delay', 0, 'fade', 'both', 'fadeMax', 100, 'styleClass', 'niceTitle');" />
-
-
-
<div style="clear:both;"></div>
<div id="submitpref" align="center" style="display:none;width:17%;margin:5px;padding: 5px;background:#CCCCCC">
@@ -324,7 +321,7 @@ echo $jscriptstr;
$periodpos = strpos($widget, ".");
$widgetname = substr($widget, 0, $periodpos);
$nicename = $widgetname;
- $widgetname = str_replace(" ", "", $widgetname);
+ $nicename = str_replace("_", " ", $nicename);
//make the title look nice
$nicename = ucwords($nicename);
diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php
new file mode 100644
index 0000000..8e64bad
--- /dev/null
+++ b/usr/local/www/widgets/widgets/system_information.widget.php
@@ -0,0 +1,116 @@
+<table width="100%" border="0" cellspacing="0" cellpadding="0">
+ <tbody>
+ <tr>
+ <td width="25%" class="vncellt">Name</td>
+ <td width="75%" class="listr"><?php echo $config['system']['hostname'] . "." . $config['system']['domain']; ?></td>
+ </tr>
+ <tr>
+ <td width="25%" valign="top" class="vncellt">Version</td>
+ <td width="75%" class="listr">
+ <strong><?php readfile("/etc/version"); ?></strong>
+ <br />
+ built on <?php readfile("/etc/version.buildtime"); ?>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" class="vncellt">Platform</td>
+ <td width="75%" class="listr"><?=htmlspecialchars($g['platform']);?></td>
+ </tr>
+ <tr>
+ <td width="25%" class="vncellt">CPU Type</td>
+ <td width="75%" class="listr">
+ <?php
+ $cpumodel = "";
+ exec("/sbin/sysctl -n hw.model", $cpumodel);
+ $cpumodel = implode(" ", $cpumodel);
+ echo (htmlspecialchars($cpumodel)); ?>
+ </td>
+ </tr>
+ <?php if ($hwcrypto): ?>
+ <tr>
+ <td width="25%" class="vncellt">Hardware crypto</td>
+ <td width="75%" class="listr"><?=htmlspecialchars($hwcrypto);?></td>
+ </tr>
+ <?php endif; ?>
+ <tr>
+ <td width="25%" class="vncellt">Uptime</td>
+ <td width="75%" class="listr"><input style="border: 0px solid white;" size="30" name="uptime" id="uptime" value="<?= htmlspecialchars(get_uptime()); ?>" /></td>
+ </tr>
+ <tr>
+ <td width="30%" class="vncellt">DNS server(s)</td>
+ <td width="70%" class="listr">
+ <?php
+ $dns_servers = get_dns_servers();
+ foreach($dns_servers as $dns) {
+ echo "{$dns}<br>";
+ }
+ ?>
+ </td>
+ </tr>
+ <?php if ($config['revision']): ?>
+ <tr>
+ <td width="25%" class="vncellt">Last config change</td>
+ <td width="75%" class="listr"><?= htmlspecialchars(date("D M j G:i:s T Y", $config['revision']['time']));?></td>
+ </tr>
+ <?php endif; ?>
+ <tr>
+ <td width="25%" class="vncellt">State table size</td>
+ <td width="75%" class="listr">
+ <input style="border: 0px solid white;" size="30" name="pfstate" id="pfstate" value="<?= htmlspecialchars(get_pfstate()); ?>" />
+ <br />
+ <a href="diag_dump_states.php">Show states</a>
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" class="vncellt">CPU usage</td>
+ <td width="75%" class="listr">
+ <?php $cpuUsage = "0"; ?>
+ <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" />
+ &nbsp;
+ <input style="border: 0px solid white;" size="30" name="cpumeter" id="cpumeter" value="(Updating in 5 seconds)" />
+ </td>
+ </tr>
+ <tr>
+ <td width="25%" class="vncellt">Memory usage</td>
+ <td width="75%" class="listr">
+ <?php $memUsage = mem_usage(); ?>
+ <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" />
+ &nbsp;
+ <input style="border: 0px solid white;" size="30" name="memusagemeter" id="memusagemeter" value="<?= $memUsage.'%'; ?>" />
+ </td>
+ </tr>
+ <?php if($showswap == true): ?>
+ <tr>
+ <td width="25%" class="vncellt">SWAP usage</td>
+ <td width="75%" class="listr">
+ <?php $swapusage = swap_usage(); ?>
+ <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" />
+ &nbsp;
+ <input style="border: 0px solid white;" size="30" name="swapusagemeter" id="swapusagemeter" value="<?= $swapusage.'%'; ?>" />
+ </td>
+ </tr>
+ <?php endif; ?>
+<?php
+ if(has_temp()):
+?>
+ <tr>
+ <td width='25%' class='vncellt'>Temperature</td>
+ <td width='75%' class='listr'>
+ <?php $temp = get_temp(); ?>
+ <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" />
+ &nbsp;
+ <input style="border: 0px solid white;" size="30" name="tempmeter" id="tempmeter" value="<?= $temp."C"; ?>" />
+ </td>
+ </tr>
+ <?php endif; ?>
+ <tr>
+ <td width="25%" class="vncellt">Disk usage</td>
+ <td width="75%" class="listr">
+ <?php $diskusage = disk_usage(); ?>
+ <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" />
+ &nbsp;
+ <input style="border: 0px solid white;" size="30" name="diskusagemeter" id="diskusagemeter" value="<?= $diskusage.'%'; ?>" />
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/usr/local/www/widgets/widgets/traffic_graphs.widget.php b/usr/local/www/widgets/widgets/traffic_graphs.widget.php
new file mode 100644
index 0000000..0e1f89e
--- /dev/null
+++ b/usr/local/www/widgets/widgets/traffic_graphs.widget.php
@@ -0,0 +1,49 @@
+<?php $i = 0; $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
+ for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
+ $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
+ }?>
+
+ <?php
+ //set variables for traffic graph
+ $width = "347";
+ $height = "150";
+
+ if (get_cpu_speed() >= 500)
+ $firstgraphshown = false;
+ else
+ $firstgraphshown = true;
+ foreach ($ifdescrs as $ifdescr => $ifname){
+ $ifinfo = get_interface_info($ifdescr);
+ $ifnum = convert_friendly_interface_to_real_interface_name($ifname);
+
+ if ($ifinfo['status'] != "down"){
+ ?>
+ <div id="<?=$ifname;?>trafficdiv" style="padding: 5px">
+ <div id="<?=$ifname;?>topic" class="widgetsubheader">
+ <div style="float:left;width:49%">
+ <a href="/status_graph.php?if=<?=$ifdescr;?>"><span style="color:#000000">Current <?=$ifname;?> Traffic</span></a>
+ </div>
+ <div align="right" style="float:right;width:49%">
+ <?php
+ if(!$firstgraphshown){?>
+ <div id="<?=$ifname;?>graphdiv-min" onclick='return minimizeDiv("<?php echo $ifname;?>graphdiv",true)' style="display:inline; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif" alt="Minimize <?=$ifname;?> traffic graph" /></div>
+ <?php $firstgraphshown = true;?>
+ <div id="<?=$ifname;?>graphdiv-open" onclick='return showDiv("<?php echo $ifname;?>graphdiv",true)' style="display:none; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" alt="Show <?=$ifname;?> traffic graph" /></div>
+ </div><div style="clear:both;"></div>
+ </div>
+
+ <div id="<?=$ifname;?>graphdiv">
+ <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" />
+ </div>
+ <? } else { ?>
+ <div id="<?=$ifname;?>graphdiv-open" onclick='return showDiv("<?php echo $ifname;?>graphdiv",true)' style="display:inline; cursor:pointer" ><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_open.gif" alt="Show <?=$ifname;?> traffic graph" /></div>
+ <div id="<?=$ifname;?>graphdiv-min" onclick='return minimizeDiv("<?php echo $ifname;?>graphdiv",true)' style="display:none; cursor:pointer"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_minus.gif" alt="Minimize <?=$ifname;?> traffic graph" /></div>
+ </div><div style="clear:both;"></div>
+ </div>
+ <div id="<?=$ifname;?>graphdiv" style="display: none">
+ <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" />
+ </div>
+ <? } ?>
+ </div>
+ <? }
+ } ?>
OpenPOWER on IntegriCloud