From 5aaccff5d3eb7124c2598ca8295213af5f4e6728 Mon Sep 17 00:00:00 2001 From: jim-p Date: Sun, 5 Apr 2009 15:03:39 -0400 Subject: [PATCH] New Widget: Gmirror Status --- .../www/widgets/include/gmirror_status.inc | 31 ++++++++++ .../widgets/widgets/gmirror_status.widget.php | 59 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 usr/local/www/widgets/include/gmirror_status.inc create mode 100644 usr/local/www/widgets/widgets/gmirror_status.widget.php diff --git a/usr/local/www/widgets/include/gmirror_status.inc b/usr/local/www/widgets/include/gmirror_status.inc new file mode 100644 index 0000000000..677be85b08 --- /dev/null +++ b/usr/local/www/widgets/include/gmirror_status.inc @@ -0,0 +1,31 @@ + 0) { + /* We don't need the first row, it's just a header */ + $status = array_slice($status, 1); + + /* Loop through gmirror status output. */ + foreach ($status as $line) { + /* Split the line by whitespace */ + $all = preg_split("/[\s\t]+/", trim($line), 3); + if (count($all) == 3) { + /* If there are three items on a line, it is mirror name, status, and component */ + $currentmirror = $all[0]; + $mirrors[$currentmirror]["name"] = $all[0]; + $mirrors[$currentmirror]["status"] = $all[1]; + $mirrors[$currentmirror]["components"] = array(); + $mirrors[$currentmirror]["components"][] = $all[2]; + } elseif ((trim($line) != "") && (count($all) > 0)) { + /* If there is just one item on a line, it is a component name of the previous mirror */ + $mirrors[$currentmirror]["components"][] = trim($line); + } + } + } + /* Return an hash of mirrors and components */ + return $mirrors; +} ?> \ 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 new file mode 100644 index 0000000000..2417128291 --- /dev/null +++ b/usr/local/www/widgets/widgets/gmirror_status.widget.php @@ -0,0 +1,59 @@ + + + + 0) { ?> + + + + + + $name) { ?> + + + + + + 1) { + $morecomponents = array_slice($name["components"], 1); + foreach ($morecomponents as $component) { ?> + + + + + + + + + +
NameStatusComponent
" class="listr">" class="listr">
No Mirrors Found