From 83b8b840d2dbb83216f3fb3d492e5eda9f26b541 Mon Sep 17 00:00:00 2001
From: User yamaguti 
Date: Wed, 6 Feb 2008 08:41:32 +0000
Subject: [PATCH] Disable "Log" button in "pgpool status" screen if a PIPE
 command is set as a log file.
---
 command.php          | 3 +--
 common.php           | 5 +++++
 config.php           | 2 +-
 status.php           | 8 ++++++--
 templates/status.tpl | 4 ++--
 5 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/command.php b/command.php
index 7b4fc27..537d966 100644
--- a/command.php
+++ b/command.php
@@ -91,8 +91,7 @@ function execPcp($command, $num='') {
         case 'PCP_START_PGPOOL':
 			$configOption = ' -f ' . _PGPOOL2_CONFIG_FILE . ' -F ' . _PGPOOL2_PASSWORD_FILE;
 			
-			if(strpos($num, '|') !== FALSE) {
-				// pipe
+			if(isPipe($num)) {
 				$cmdOption = $configOption . $num . ' > /dev/null &';
 			} else {
 				$cmdOption = $configOption . $num . ' 2>&1 &';
diff --git a/common.php b/common.php
index 3af4244..f96b778 100644
--- a/common.php
+++ b/common.php
@@ -392,4 +392,9 @@ function readConfigParams($paramList = FALSE) {
     
 }
 
+function isPipe($str) 
+{
+	return (strpos($str, '|') !== FALSE);
+}
+
 ?>
diff --git a/config.php b/config.php
index f31f481..59121ad 100644
--- a/config.php
+++ b/config.php
@@ -177,7 +177,7 @@ switch ( $action ) {
         } else {
             $errors[$key] = $message['errNoDefined'];            
         }
-		if($params[$key] != '' && (strpos($params[$key], '|') !== FALSE)) {
+		if($params[$key] != '' && isPipe($params[$key])) {
 			// pipe
 			$tmp_str = trim($params[$key]);
 			if(($tmp_str[0] != '|') || ($tmp_str[strlen($tmp_str) - 1] == '|')) {
diff --git a/status.php b/status.php
index e483561..254c7d0 100644
--- a/status.php
+++ b/status.php
@@ -55,6 +55,10 @@ $tpl->assign('c', _PGPOOL2_CMD_OPTION_C);
 $tpl->assign('d', _PGPOOL2_CMD_OPTION_D);
 $tpl->assign('m', _PGPOOL2_CMD_OPTION_M);
 $tpl->assign('n', _PGPOOL2_CMD_OPTION_N);
+if(isPipe(_PGPOOL2_LOG_FILE)) 
+	$tpl->assign('pipe', 1);
+else
+	$tpl->assign('pipe', 0); 
 
 switch ($action) {
     case 'start':
@@ -72,7 +76,7 @@ switch ($action) {
                 $logDir = readLogDir();
                 $pgpoolLog = "$logDir/pgpool.log";
             }
-			if(strpos($pgpoolLog, '|') !== FALSE) 
+			if(isPipe($pgpoolLog))
 				$args = "$args -n 2>&1 $pgpoolLog ";
 			else
 				$args = "$args -n > $pgpoolLog ";
@@ -169,7 +173,7 @@ switch ($action) {
                 $logDir = readLogDir();
                 $pgpoolLog = "$logDir/pgpool.log";
             }
-			if(strpos($pgpoolLog, '|') !== FALSE) 
+			if(isPipe($pgpoolLog)) 
 				$args = "$args -n 2>&1 $pgpoolLog ";
 			else
 				$args = "$args -n > $pgpoolLog ";
diff --git a/templates/status.tpl b/templates/status.tpl
index 97c5898..441dc6d 100644
--- a/templates/status.tpl
+++ b/templates/status.tpl
@@ -177,7 +177,7 @@ function changeView(chView){
     
     
     
-    {if $n == 1}
+    {if $n == 1 && $pipe == 0}
     
     {/if}
 
    
@@ -186,7 +186,7 @@ function changeView(chView){
     
     
     
-    {if $n == 1}
+    {if $n == 1 && $pipe == 0}
     
     {/if}
 
-- 
2.39.5