summaryrefslogtreecommitdiffstats
path: root/usr/local
diff options
context:
space:
mode:
authorjim-p <jim@pingle.org>2010-02-27 20:45:03 -0500
committerjim-p <jim@pingle.org>2010-02-27 20:45:03 -0500
commit312d166b02d1b2acb656b7daca256b30b2e05033 (patch)
tree18b3aa9e3c6c3ae9720c0f0b446bc1b031597a78 /usr/local
parent9f9b88e2172994610dd6794057ed5c567ade0a9e (diff)
downloadpfsense-312d166b02d1b2acb656b7daca256b30b2e05033.zip
pfsense-312d166b02d1b2acb656b7daca256b30b2e05033.tar.gz
AJAX-ify the gmirror status widget. Add license header while I'm here.
Diffstat (limited to 'usr/local')
-rw-r--r--usr/local/www/widgets/include/gmirror_status.inc63
-rw-r--r--usr/local/www/widgets/widgets/gmirror_status.widget.php44
2 files changed, 76 insertions, 31 deletions
diff --git a/usr/local/www/widgets/include/gmirror_status.inc b/usr/local/www/widgets/include/gmirror_status.inc
index 677be85..414c394 100644
--- a/usr/local/www/widgets/include/gmirror_status.inc
+++ b/usr/local/www/widgets/include/gmirror_status.inc
@@ -1,5 +1,31 @@
<?php
-function get_gmirror_status() {
+/*
+ gmirror_status.widget.php
+ Copyright (C) 2009-2010 Jim Pingle
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+function gmirror_get_status() {
$status = "";
exec("/sbin/gmirror status", $status);
$mirrors = array();
@@ -28,4 +54,37 @@ function get_gmirror_status() {
}
/* Return an hash of mirrors and components */
return $mirrors;
-} ?> \ No newline at end of file
+}
+
+function gmirror_html_status() {
+ $mirrors = gmirror_get_status();
+ $output = "";
+ if (count($mirrors) > 0) {
+ $output .= "<tr>\n";
+ $output .= "<td width=\"40%\" class=\"vncellt\">Name</td>\n";
+ $output .= "<td width=\"40%\" class=\"vncellt\">Status</td>\n";
+ $output .= "<td width=\"20%\" class=\"vncellt\">Component</td>\n";
+ $output .= "</tr>\n";
+ foreach ($mirrors as $mirror => $name) {
+ $components = count($name["components"]);
+ $output .= "<tr>\n";
+ $output .= "<td width=\"40%\" rowspan=\"{$components}\" class=\"listr\">{$name['name']}</td>\n";
+ $output .= "<td width=\"40%\" rowspan=\"{$components}\" class=\"listr\">{$name['status']}</td>\n";
+ $output .= "<td width=\"20%\" class=\"listr\">{$name['components'][0]}</td>\n";
+ $output .= "</tr>\n";
+ if (count($name["components"]) > 1) {
+ $morecomponents = array_slice($name["components"], 1);
+ foreach ($morecomponents as $component) {
+ $output .= "<tr>\n";
+ $output .= "<td width=\"20%\" class=\"listr\">{$component}</td>\n";
+ $output .= "</tr>\n";
+ }
+ }
+ }
+ } else {
+ $output .= "<tr><td colspan=\"3\" class=\"listr\">No Mirrors Found</td></tr>\n";
+ }
+ // $output .= "<tr><td colspan=\"3\" class=\"listr\">Updated at " . date("F j, Y, g:i:s a") . "</td></tr>\n";
+ return $output;
+}
+?> \ No newline at end of file
diff --git a/usr/local/www/widgets/widgets/gmirror_status.widget.php b/usr/local/www/widgets/widgets/gmirror_status.widget.php
index dcbcbc4..cd73a0f 100644
--- a/usr/local/www/widgets/widgets/gmirror_status.widget.php
+++ b/usr/local/www/widgets/widgets/gmirror_status.widget.php
@@ -1,7 +1,7 @@
<?php
/*
gmirror_status.widget.php
- Copyright (C) 2009 Jim Pingle
+ Copyright (C) 2009-2010 Jim Pingle
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -27,35 +27,21 @@
require_once("/usr/local/www/widgets/include/gmirror_status.inc");
-$mirrors = get_gmirror_status();
-
+if ($_GET['textonly'] == "true") {
+ header("Cache-Control: no-cache");
+ echo gmirror_html_status();
+ exit;
+}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
- <tbody>
-<?php if (count($mirrors) > 0) { ?>
- <tr>
- <td width="40%" class="vncellt">Name</td>
- <td width="40%" class="vncellt">Status</td>
- <td width="20%" class="vncellt">Component</td>
- </tr>
- <?php foreach ($mirrors as $mirror => $name) { ?>
- <tr>
- <td width="40%" rowspan="<?= count($name["components"]) ?>" class="listr"><?= $name["name"] ?></td>
- <td width="40%" rowspan="<?= count($name["components"]) ?>" class="listr"><?= $name["status"] ?></td>
- <td width="20%" class="listr"><?= $name["components"][0] ?></td>
- </tr>
- <?php
- if (count($name["components"]) > 1) {
- $morecomponents = array_slice($name["components"], 1);
- foreach ($morecomponents as $component) { ?>
- <tr>
- <td width="20%" class="listr"><?= $component ?></td>
- </tr>
- <?php }
- } ?>
- <?php } ?>
-<?php } else { ?>
- <tr><td colspan="3" class="listr">No Mirrors Found</td></tr>
-<?php } ?>
+ <tbody id="gmirror_status_table">
+ <?php echo gmirror_html_status(); ?>
</tbody>
</table>
+
+<script type="text/javascript" language="javascript">
+ // <![CDATA[
+ var gmirrorupdater = new Ajax.PeriodicalUpdater('gmirror_status_table', '/widgets/widgets/gmirror_status.widget.php?textonly=true',
+ { method: 'get', frequency: 5 } );
+ // ]]>
+</script>
OpenPOWER on IntegriCloud