From 0808310391b8ecb5b8cdee3c922ffccc076c8daa Mon Sep 17 00:00:00 2001
From: Pim van den Berg
Date: Mon, 28 Dec 2009 10:59:29 +0100
Subject: replace duplicate code by function plugin_header
---
host.php | 6 +++---
inc/html.inc.php | 16 ++++++++++++++++
plugin.php | 4 ++--
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/host.php b/host.php
index 17cb499..42179f3 100644
--- a/host.php
+++ b/host.php
@@ -22,7 +22,7 @@ if(!$plugins) {
foreach($CONFIG['overview'] as $plugin) {
if (in_array($plugin, $plugins)) {
printf('
'."\n", $plugin);
- printf("
%s
\n", $host, $plugin, $CONFIG['weburl'], $plugin);
+ plugin_header($host, $plugin, 0);
graphs_from_plugin($host, $plugin);
print "
\n";
}
@@ -33,10 +33,10 @@ foreach($plugins as $plugin) {
if (!in_array($plugin, $CONFIG['overview'])) {
printf(''."\n", $plugin);
if ($splugin == $plugin) {
- printf("
%s
\n", $host, $plugin, $CONFIG['weburl'], $plugin);
+ plugin_header($host, $plugin, 0);
graphs_from_plugin($host, $plugin);
} else {
- printf("
%s
\n", $host, $plugin, $CONFIG['weburl'], $plugin);
+ plugin_header($host, $plugin, 1);
}
print "
\n";
}
diff --git a/inc/html.inc.php b/inc/html.inc.php
index b1cb80f..e93cc66 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -40,6 +40,22 @@ function html_end() {
EOT;
}
+function plugin_header($host, $plugin, $status) {
+ global $CONFIG;
+
+ if ($status == 1) {
+ $f = 'get';
+ $i = 'plus';
+ $a = '+';
+ } else {
+ $f = 'rm';
+ $i = 'minus';
+ $a = '-';
+ }
+
+ return printf("
%s
\n", $f, $host, $plugin, $CONFIG['weburl'], $i, $a, $plugin);
+}
+
function host_summary($hosts) {
global $CONFIG;
diff --git a/plugin.php b/plugin.php
index 036dbb5..054c559 100644
--- a/plugin.php
+++ b/plugin.php
@@ -7,9 +7,9 @@ $host = $_GET['h'];
$plugin = $_GET['p'];
if ($_GET['a'] == 'del') {
- printf("
%s
\n", $host, $plugin, $CONFIG['weburl'], $plugin);
+ plugin_header($host, $plugin, 1);
} else {
- printf("
%s
\n", $host, $plugin, $CONFIG['weburl'], $plugin);
+ plugin_header($host, $plugin, 0);
graphs_from_plugin($host, $plugin);
}
--
cgit v1.1