diff options
author | Nozomi Anzai | 2011-10-06 04:45:58 +0000 |
---|---|---|
committer | Nozomi Anzai | 2011-10-06 04:45:58 +0000 |
commit | 3157fc4d0029387be6de495a6546efbb3ee49282 (patch) | |
tree | 977d9e476d969a7f48515c1a97985513cab97a5b | |
parent | 2a5ad6d8882e161e3282f3a57e147b353e8b9ea4 (diff) |
rearrange to read easier
- add empty rows
- add comments
- based on one coding rule
- sort parameters by their order in pgpool.conf (definePgpoolConfParam.php)
-rw-r--r-- | changePassword.php | 20 | ||||
-rw-r--r-- | command.php | 86 | ||||
-rw-r--r-- | common.php | 264 | ||||
-rw-r--r-- | config.php | 428 | ||||
-rw-r--r-- | definePgpoolConfParam.php | 371 | ||||
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | innerLog.php | 8 | ||||
-rw-r--r-- | innerNodeServerStatus.php | 13 | ||||
-rw-r--r-- | innerSummary.php | 14 | ||||
-rw-r--r-- | innerSystemCatalog.php | 26 | ||||
-rw-r--r-- | login.php | 62 | ||||
-rw-r--r-- | nodeServerStatus.php | 2 | ||||
-rw-r--r-- | nodeStatus.php | 86 | ||||
-rw-r--r-- | pgconfig.php | 382 | ||||
-rw-r--r-- | procInfo.php | 24 | ||||
-rw-r--r-- | queryCache.php | 93 | ||||
-rw-r--r-- | status.php | 130 | ||||
-rw-r--r-- | systemDb.php | 413 | ||||
-rw-r--r-- | templates/config.tpl | 10 | ||||
-rw-r--r-- | templates/error.tpl | 2 | ||||
-rw-r--r-- | templates/login.tpl | 4 | ||||
-rw-r--r-- | templates/menu.tpl | 1 | ||||
-rw-r--r-- | templates/nodeServerStatus.tpl | 11 | ||||
-rw-r--r-- | templates/nodeStatus.tpl | 25 | ||||
-rw-r--r-- | templates/pgconfig.tpl | 242 | ||||
-rw-r--r-- | version.php | 2 |
26 files changed, 1503 insertions, 1218 deletions
diff --git a/changePassword.php b/changePassword.php index c9915ab..5f835b8 100644 --- a/changePassword.php +++ b/changePassword.php @@ -40,23 +40,23 @@ if(isset($_POST['action'])) { switch ( $action ) { case 'update': - + if(!isset($_POST['password']) || !isset($_POST['password2'])) { $tpl->display('changePassword.tpl'); break; } - + $password = $_POST['password']; $password2 = $_POST['password2']; - + if($password == '' || $password2 == '') { $tpl->assign('error', $message['errPasswordMismatch']); $tpl->display('changePassword.tpl'); break; } - + if($password === $password2) { - + $passFile = @file(_PGPOOL2_PASSWORD_FILE); if($passFile == false) { $errorCode = 'e6001'; @@ -64,7 +64,7 @@ switch ( $action ) { $tpl->display('error.tpl'); exit(); } - + if( ! is_writable(_PGPOOL2_PASSWORD_FILE) ) { $errorCode = 'e6003'; $tpl->assign('errorCode', $errorCode); @@ -72,19 +72,19 @@ switch ( $action ) { exit(); } $fw = fopen(_PGPOOL2_PASSWORD_FILE, 'w'); - + for($i=0; $i<count($passFile); $i++) { - + $line = $passFile[$i]; $spt = split(":", $line); - + if($spt[0] == $_SESSION[SESSION_LOGIN_USER]) { $line = $_SESSION[SESSION_LOGIN_USER] . ":" . md5($password) . "\n"; } fputs($fw, $line); } fclose($fw); - + session_unset(); $tpl->display('login.tpl'); break; diff --git a/command.php b/command.php index 01dab2d..0c67c57 100644 --- a/command.php +++ b/command.php @@ -32,29 +32,35 @@ require_once('common.php'); * @param srgs $num * @return array */ -function execPcp($command, $num='') { +function execPcp($command, $num='') +{ $pcpStatus = array ( - '0' => 'SUCCESS', - '1' => 'UNKNOWNERR', - '2' => 'EOFERR', - '3' => 'NOMEMERR', - '4' => 'READERR', - '5' => 'WRITEERR', - '6' => 'TIMEOUTERR', - '7' => 'INVALERR', - '8' => 'CONNERR', - '9' => 'NOCONNERR', - '10' => 'SOCKERR', - '11' => 'HOSTERR', - '12' => 'BACKENDERR', - '13' => 'AUTHERR', + '0' => 'SUCCESS', + '1' => 'UNKNOWNERR', + '2' => 'EOFERR', + '3' => 'NOMEMERR', + '4' => 'READERR', + '5' => 'WRITEERR', + '6' => 'TIMEOUTERR', + '7' => 'INVALERR', + '8' => 'CONNERR', + '9' => 'NOCONNERR', + '10' => 'SOCKERR', + '11' => 'HOSTERR', + '12' => 'BACKENDERR', + '13' => 'AUTHERR', '127' => 'COMMANDERROR' ); $param = readPcpInfo(); $param['hostname'] = _PGPOOL2_PCP_HOSTNAME; - $args = " " . $param['pcp_timeout'] . " " . $param['hostname'] . " " . $param['pcp_port'] . " ". $_SESSION[SESSION_LOGIN_USER] . " '" . $_SESSION[SESSION_LOGIN_USER_PASSWORD] . "' " . $num; + $args = " " . $param['pcp_timeout'] . + " " . $param['hostname'] . + " " . $param['pcp_port'] . + " ". $_SESSION[SESSION_LOGIN_USER] . + " '" . $_SESSION[SESSION_LOGIN_USER_PASSWORD] . "' " . + $num; switch ($command) { case 'PCP_NODE_COUNT': @@ -66,47 +72,47 @@ function execPcp($command, $num='') { $cmd = _PGPOOL2_PCP_DIR . '/pcp_node_info' . $args; $ret = exec($cmd, $output, $return_var); break; - + case 'PCP_ATTACH_NODE': $cmd = _PGPOOL2_PCP_DIR . '/pcp_attach_node' . $args; $ret = exec($cmd, $output, $return_var); break; - + case 'PCP_DETACH_NODE': $cmd = _PGPOOL2_PCP_DIR . '/pcp_detach_node' . $args; $ret = exec($cmd, $output, $return_var); break; - + case 'PCP_PROC_COUNT': $cmd = _PGPOOL2_PCP_DIR . '/pcp_proc_count' . $args; $ret = exec($cmd, $output, $return_var); break; - + case 'PCP_PROC_INFO': $cmd = _PGPOOL2_PCP_DIR . '/pcp_proc_info' . $args; $ret = exec($cmd, $output, $return_var); $ret = $output; break; - + case 'PCP_START_PGPOOL': - $configOption = ' -f ' . _PGPOOL2_CONFIG_FILE . ' -F ' . _PGPOOL2_PASSWORD_FILE; - - if(isPipe($num)) { - $cmdOption = $configOption . $num . ' > /dev/null &'; - } else { - $cmdOption = $configOption . $num . ' 2>&1 &'; - } - - /* we should not check pid file here. - * let pgpool handle bogus pid file + $configOption = ' -f ' . _PGPOOL2_CONFIG_FILE . + ' -F ' . _PGPOOL2_PASSWORD_FILE; + + if(isPipe($num)) { + $cmdOption = $configOption . $num . ' > /dev/null &'; + } else { + $cmdOption = $configOption . $num . ' 2>&1 &'; + } + + /* we should not check pid file here. + * let pgpool handle bogus pid file * if(DoesPgpoolPidExist()) { * return array('FAIL'=> ''); * } - */ + */ $cmd = _PGPOOL2_COMMAND . $cmdOption; - //var_dump($cmd);exit; $ret = exec($cmd, $output, $return_var); - if($return_var == 0) { + if ($return_var == 0) { return array($pcpStatus[$return_var] => $output); } else { return array('FAIL' => $output); @@ -115,18 +121,18 @@ function execPcp($command, $num='') { case 'PCP_RELOAD_PGPOOL': $cmdOption = $num; - $cmdOption = $cmdOption . ' -f ' . _PGPOOL2_CONFIG_FILE - . ' -F ' . _PGPOOL2_PASSWORD_FILE . ' reload'; + $cmdOption = $cmdOption . + ' -f ' . _PGPOOL2_CONFIG_FILE . + ' -F ' . _PGPOOL2_PASSWORD_FILE . ' reload'; $cmd = _PGPOOL2_COMMAND . $cmdOption . ' 2>&1 &'; $ret = exec($cmd, $output, $return_var); - if($return_var == 0) { + if ($return_var == 0) { return array($pcpStatus[$return_var] => $output); } else { return array('FAIL' => $output); } break; - case 'PCP_STOP_PGPOOL': $cmd = _PGPOOL2_PCP_DIR . '/pcp_stop_pgpool' . $args; $ret = exec($cmd, $output, $return_var); @@ -148,8 +154,8 @@ function execPcp($command, $num='') { * * @return array */ -function readPcpInfo() { - +function readPcpInfo() +{ $params = readConfigParams(array('pcp_port', 'pcp_timeout')); return $params; } @@ -46,7 +46,7 @@ define('SMARTY_COMPILE_DIR', dirname(__FILE__) . '/templates_c' ); $tpl = new Smarty(); $tpl->assign('version', $version); -if(!file_exists('conf/pgmgt.conf.php')) { +if (!file_exists('conf/pgmgt.conf.php')) { include('lang/en.lang.php'); $tpl->assign('message', $message); $tpl->display('pgmgtNotFound.tpl'); @@ -59,7 +59,7 @@ require_once('conf/pgmgt.conf.php'); * Check login */ $isLogin = FALSE; -if(isset($_SESSION[SESSION_LOGIN_USER])) { +if (isset($_SESSION[SESSION_LOGIN_USER])) { $isLogin = TRUE; $tpl->assign('isLogin', $isLogin); } @@ -68,21 +68,21 @@ if(isset($_SESSION[SESSION_LOGIN_USER])) { * Check pgmgt.conf.php Parameter */ $errors = array(); -if( !defined('_PGPOOL2_LANG') - || !defined('_PGPOOL2_CONFIG_FILE') - || !defined('_PGPOOL2_PASSWORD_FILE') - || !defined('_PGPOOL2_COMMAND') - || !defined('_PGPOOL2_PCP_DIR') - || !defined('_PGPOOL2_PCP_HOSTNAME') - || !defined('_PGPOOL2_STATUS_REFRESH_TIME')) { - - include('lang/en.lang.php'); - $tpl->assign('message', $message); - $errorCode = 'e7'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('error.tpl'); - exit(); - } +if (!defined('_PGPOOL2_LANG') || + !defined('_PGPOOL2_CONFIG_FILE') || + !defined('_PGPOOL2_PASSWORD_FILE') || + !defined('_PGPOOL2_COMMAND') || + !defined('_PGPOOL2_PCP_DIR') || + !defined('_PGPOOL2_PCP_HOSTNAME') || + !defined('_PGPOOL2_STATUS_REFRESH_TIME')) +{ + include('lang/en.lang.php'); + $tpl->assign('message', $message); + $errorCode = 'e7'; + $tpl->assign('errorCode', $errorCode); + $tpl->display('error.tpl'); + exit(); +} /** * Create message catalog list @@ -90,17 +90,17 @@ if( !defined('_PGPOOL2_LANG') $messageList = array(); $res_dir = opendir('lang/'); -while($file_name = readdir( $res_dir )) { - if(preg_match('/.*\.lang\.php$/', $file_name)) { - if(@is_file('lang/' . $file_name)) { +while ($file_name = readdir( $res_dir )) { + if (preg_match('/.*\.lang\.php$/', $file_name)) { + if (@is_file('lang/' . $file_name)) { include('lang/' . $file_name); - $messageList[$message['lang']] = $message['strLang']; + $messageList[$message['lang']] = $message['strLang']; + } else { $errorCode = 'e2'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); - } } } @@ -123,18 +123,18 @@ $_SESSION[SESSION_MESSAGE] = $message; */ function openDBConnection($param) { - $host= $param['hostname']; - $port = $param['port']; - $dbname = $param['dbname']; - $user = $param['user']; + $host = $param['hostname']; + $port = $param['port']; + $dbname = $param['dbname']; + $user = $param['user']; $password = $param['password']; - if($host != '') { + if ($host != '') { $conStr = "host=$host port=$port dbname=$dbname user=$user password=$password" ; } else { $conStr = "port=$port dbname=$dbname user=$user password=$password" ; } - + $con = @pg_connect($conStr); return $con; } @@ -156,10 +156,11 @@ function closeDBConnection($connection) * @param string $sql * @return resource */ -function execQuery($conn, $sql) { +function execQuery($conn, $sql) +{ $rs = @pg_query($conn, $sql); - if(!pg_result_status($rs) == PGSQL_TUPLES_OK) { - return false; + if (!pg_result_status($rs) == PGSQL_TUPLES_OK) { + return FALSE; } return $rs; @@ -170,33 +171,36 @@ function execQuery($conn, $sql) { * * @return string */ -function selectLanguage($selectLang, $messageList) { - if( $selectLang == null || $selectLang == 'auto') { +function selectLanguage($selectLang, $messageList) +{ + if ($selectLang == NULL || $selectLang == 'auto') { if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $acceptLanguages = $_SERVER['HTTP_ACCEPT_LANGUAGE']; } else { $acceptLanguages = FALSE; } - - $lang = null; - - if($acceptLanguages == FALSE) { + + $lang = NULL; + + if ($acceptLanguages == FALSE) { $lang = 'en'; + } else { $langList = split(',|;', $acceptLanguages); - foreach($langList as $acceptLanguage) { - foreach(array_keys($messageList) as $messageLanguage) { - if( $acceptLanguage == $messageLanguage ) { + foreach ($langList as $acceptLanguage) { + foreach (array_keys($messageList) as $messageLanguage) { + if ($acceptLanguage == $messageLanguage ) { $lang = $messageLanguage; break; } } - if( $lang != null) break; + if ($lang != NULL) { break; } } } } else { $lang = $selectLang; } + $_SESSION[SESSION_LANG] = $lang; return $lang; } @@ -206,14 +210,14 @@ function selectLanguage($selectLang, $messageList) { * * @return bool */ -function isParallelMode() { - +function isParallelMode() +{ $params = readConfigParams(array('parallel_mode')); - if($params['parallel_mode'] == 'true') { - return true; + if ($params['parallel_mode'] == 'true') { + return TRUE; } else { - return false; + return FALSE; } } @@ -222,15 +226,17 @@ function isParallelMode() { * * @return bool */ -function NodeActive($num) { +function NodeActive($num) +{ $healthCheckDb = 'template1'; - + $params = readHealthCheckParam(); - + $healthCheckUser = $params['health_check_user']; $backendHostName = $params['backend_hostname'][$num]; - $backendPort = $params['backend_port'][$num]; - if($backendHostName != '') { + $backendPort = $params['backend_port'][$num]; + + if ($backendHostName != '') { $conStr = "dbname=$healthCheckDb user=$healthCheckUser host=$backendHostName port=$backendPort" ; } else { $conStr = "dbname=$healthCheckDb port=$backendPort user=$healthCheckUser" ; @@ -238,7 +244,7 @@ function NodeActive($num) { $conn = @pg_connect($conStr); - if($conn == FALSE) { + if ($conn == FALSE) { @pg_close($conn); return FALSE; } else { @@ -252,21 +258,24 @@ function NodeActive($num) { * * @return integer */ -function NodeStandby($num) { +function NodeStandby($num) +{ - $params = readConfigParams(array('master_slave_mode','master_slave_sub_mode')); + $params = readConfigParams(array('master_slave_mode','master_slave_sub_mode')); - if ($params['master_slave_mode'] != 'true' || $params['master_slave_sub_mode'] != 'stream') - return -1; + if ($params['master_slave_mode'] != 'true' || $params['master_slave_sub_mode'] != 'stream') { + return -1; + } $healthCheckDb = 'template1'; - + $params = readHealthCheckParam(); - + $healthCheckUser = $params['health_check_user']; $backendHostName = $params['backend_hostname'][$num]; - $backendPort = $params['backend_port'][$num]; - if($backendHostName != '') { + $backendPort = $params['backend_port'][$num]; + + if ($backendHostName != '') { $conStr = "dbname=$healthCheckDb user=$healthCheckUser host=$backendHostName port=$backendPort" ; } else { $conStr = "dbname=$healthCheckDb port=$backendPort user=$healthCheckUser" ; @@ -274,40 +283,42 @@ function NodeStandby($num) { $conn = @pg_connect($conStr); - if($conn == FALSE) { + if ($conn == FALSE) { @pg_close($conn); return -1; - } + } - $res = pg_query($conn, 'SELECT pg_is_in_recovery()'); - if(!pg_result_status($res) == PGSQL_TUPLES_OK) { + $res = pg_query($conn, 'SELECT pg_is_in_recovery()'); + if (!pg_result_status($res) == PGSQL_TUPLES_OK) { return -1; } - $rr = pg_fetch_array($res); + $rr = pg_fetch_array($res); - if ($rr[0][0] == 't') - $r = 1; - else - $r = 0; + if ($rr[0][0] == 't') { + $r = 1; + } else { + $r = 0; + } - @pg_free_result($res); - @pg_close($conn); - return $r; + @pg_free_result($res); + @pg_close($conn); + return $r; } /** - * Read parameter from pgpool.conf using health check + * Read parameter from pgpool.conf using health check * * @return array */ -function readHealthCheckParam() { - +function readHealthCheckParam() +{ + $params = readConfigParams(array('health_check_user', - 'backend_hostname', - 'backend_port', - 'backend_weight')); - + 'backend_hostname', + 'backend_port', + 'backend_weight')); + return $params; } @@ -316,13 +327,14 @@ function readHealthCheckParam() { * * @return bool */ -function DoesPgpoolPidExist() { +function DoesPgpoolPidExist() +{ $params = readConfigParams(array('pid_file_name')); $pidFile = $params['pid_file_name']; - if( file_exists($pidFile) ) { - return true; + if (file_exists($pidFile) ) { + return TRUE; } - return false; + return FALSE; } /** @@ -330,8 +342,9 @@ function DoesPgpoolPidExist() { * * @return bool */ -function readLogDir() { - +function readLogDir() +{ + $params = readConfigParams(array('logdir')); return $params['logdir']; } @@ -341,14 +354,14 @@ function readLogDir() { * * @return bool */ -function isReplicationMode() { - +function isReplicationMode() +{ $params = readConfigParams(array('replication_mode')); - if($params['replication_mode'] == 'true') { - return true; + if ($params['replication_mode'] == 'true') { + return TRUE; } else { - return false; + return FALSE; } } @@ -357,14 +370,14 @@ function isReplicationMode() { * * @return bool */ -function isMasterSlaveMode() { - +function isMasterSlaveMode() +{ $params = readConfigParams(array('master_slave_mode')); - if($params['master_slave_mode'] == 'true') { - return true; + if ($params['master_slave_mode'] == 'true') { + return TRUE; } else { - return false; + return FALSE; } } @@ -375,13 +388,13 @@ function isMasterSlaveMode() { * @param array $paramList * @return array */ -function readConfigParams($paramList = FALSE) { - +function readConfigParams($paramList = FALSE) +{ $results = array(); $configParam = array(); - + $configFile = @file(_PGPOOL2_CONFIG_FILE); - if($configFile == false) { + if ($configFile == FALSE) { $errTpl = new Smarty(); $errTpl->assign('message', $_SESSION[SESSION_MESSAGE]); $errorCode = 'e4'; @@ -389,62 +402,65 @@ function readConfigParams($paramList = FALSE) { $errTpl->display('error.tpl'); exit(); } - + foreach ($configFile as $line_num => $line) { $line = trim($line); - if(preg_match("/^\w/", $line)) { + if (preg_match("/^\w/", $line)) { list($key, $value) = explode("=", $line); - + $key = trim($key); $value = trim($value); - - if(preg_match("/^backend_hostname/", $key)) { + + if (preg_match("/^backend_hostname/", $key)) { $num = str_replace('backend_hostname', '', $key); $configParam['backend_hostname'][$num] = str_replace("'", "", $value); - } - else if(preg_match("/^backend_port/", $key)) { + + } elseif (preg_match("/^backend_port/", $key)) { $num = str_replace('backend_port', '', $key); $configParam['backend_port'][$num] = $value; - } - else if(preg_match("/^backend_weight/", $key)) { + + } elseif (preg_match("/^backend_weight/", $key)) { $num = str_replace('backend_weight', '', $key); $configParam['backend_weight'][$num] = $value; - } - else if(preg_match("/^backend_data_directory/", $key)) { + + } elseif (preg_match("/^backend_data_directory/", $key)) { $num = str_replace('backend_data_directory', '', $key); $configParam['backend_data_directory'][$num] =str_replace("'", "", $value); - } - else { + + } else { $configParam[$key] = str_replace("'", "", $value); } } } - - if(is_array($paramList)) { - foreach($paramList as $key) { - if(isset($configParam[$key])) { + + if (is_array($paramList)) { + foreach ($paramList as $key) { + if (isset($configParam[$key])) { $results[$key] = $configParam[$key]; } else { include('definePgpoolConfParam.php'); - if(!preg_match("/^backend_hostname/", $key) - && !preg_match("/^backend_port/", $key) - && !preg_match("/^backend_weight/", $key) - && !preg_match("/^backend_data_directory/", $key)) { + if(!preg_match("/^backend_hostname/", $key) && + !preg_match("/^backend_port/", $key) && + !preg_match("/^backend_weight/", $key) && + !preg_match("/^backend_data_directory/", $key)) + { $results[$key] = $pgpoolConfigParam[$key]['default']; } } } + } else { $results = $configParam; } - + return $results; - + } -function isPipe($str) +function isPipe($str) + { - return (strpos($str, '|') !== FALSE); + return (strpos($str, '|') !== FALSE); } ?> @@ -26,290 +26,143 @@ require_once('common.php'); $tpl->assign('help', basename( __FILE__, '.php')); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { header('Location: login.php'); exit(); } -if(isset($_POST['action'])) { +if (isset($_POST['action'])) { $action = $_POST['action']; } else { $action = FALSE; } -$errors = array(); +global $g_msg_nodef; +$g_msg_nodef = $message['errNoDefined']; + +global $g_msg_notfound; +$g_msg_notfound = $message['errFileNotFound']; + +global $g_post; +$g_post = $_POST; + +global $params; $params = array(); -/** +global $errors; +$errors = array(); + +/* * Read current parameter */ -if( defined('_PGPOOL2_LANG')) - $params['lang'] = _PGPOOL2_LANG; -else - $errors['lang'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_CONFIG_FILE')) - $params['pgpool_config_file'] = _PGPOOL2_CONFIG_FILE; -else - $errors['pgpool_config_file'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_PASSWORD_FILE')) - $params['password_file'] = _PGPOOL2_PASSWORD_FILE; -else - $errors['password_file'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_COMMAND')) - $params['pgpool_command'] = _PGPOOL2_COMMAND; -else - $errors['pgpool_command'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_CMD_OPTION_C')) - $params['c'] = _PGPOOL2_CMD_OPTION_C; -else - $errors['c'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_CMD_OPTION_LARGE_D')) - $params['D'] = _PGPOOL2_CMD_OPTION_LARGE_D; -else - $errors['D'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_CMD_OPTION_D')) - $params['d'] = _PGPOOL2_CMD_OPTION_D; -else - $errors['d'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_CMD_OPTION_M')) - $params['m'] = _PGPOOL2_CMD_OPTION_M; -else - $errors['m'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_CMD_OPTION_N')) - $params['n'] = _PGPOOL2_CMD_OPTION_N; -else - $errors['n'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_LOG_FILE')) - $params['pgpool_logfile'] = _PGPOOL2_LOG_FILE; -else - $errors['pgpool_logfile'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_PCP_DIR')) - $params['pcp_client_dir'] = _PGPOOL2_PCP_DIR; -else - $errors['pcp_client_dir'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_PCP_HOSTNAME')) - $params['pcp_hostname'] = _PGPOOL2_PCP_HOSTNAME; -else - $errors['pcp_hostname'] = $message['errNoDefined']; - -if( defined('_PGPOOL2_STATUS_REFRESH_TIME')) - $params['pcp_refresh_time'] = _PGPOOL2_STATUS_REFRESH_TIME; -else - $errors['pcp_refresh_time'] = $message['errNoDefined']; - +$params['lang'] = (defined('_PGPOOL2_LANG')) ? + _PGPOOL2_LANG : $message['errNoDefined']; +$params['pgpool_config_file'] = (defined('_PGPOOL2_CONFIG_FILE')) ? + _PGPOOL2_CONFIG_FILE : $message['errNoDefined']; +$params['password_file'] = (defined('_PGPOOL2_PASSWORD_FILE')) ? + _PGPOOL2_PASSWORD_FILE : $message['errNoDefined']; +$params['pgpool_command'] = (defined('_PGPOOL2_COMMAND')) ? + _PGPOOL2_COMMAND : $message['errNoDefined']; +$params['c'] = (defined('_PGPOOL2_CMD_OPTION_C')) ? + _PGPOOL2_CMD_OPTION_C : $message['errNoDefined']; +$params['d'] = (defined('_PGPOOL2_CMD_OPTION_D')) ? + _PGPOOL2_CMD_OPTION_D : $message['errNoDefined']; +$params['D'] = (defined('_PGPOOL2_CMD_OPTION_LARGE_D')) ? + _PGPOOL2_CMD_OPTION_LARGE_D : $message['errNoDefined']; +$params['m'] = (defined('_PGPOOL2_CMD_OPTION_M')) ? + _PGPOOL2_CMD_OPTION_M : $message['errNoDefined']; +$params['n'] = (defined('_PGPOOL2_CMD_OPTION_N')) ? + _PGPOOL2_CMD_OPTION_N : $message['errNoDefined']; +$params['pgpool_logfile'] = (defined('_PGPOOL2_LOG_FILE')) ? + _PGPOOL2_LOG_FILE : $message['errNoDefined']; +$params['pcp_client_dir'] = (defined('_PGPOOL2_PCP_DIR')) ? + _PGPOOL2_PCP_DIR : $message['errNoDefined']; +$params['pcp_hostname'] = (defined('_PGPOOL2_PCP_HOSTNAME')) ? + _PGPOOL2_PCP_HOSTNAME : $message['errNoDefined']; +$params['pcp_refresh_time'] = (defined('_PGPOOL2_STATUS_REFRESH_TIME')) ? + _PGPOOL2_STATUS_REFRESH_TIME : $message['errNoDefined']; + switch ( $action ) { case 'update': - - $key = 'lang'; - if(isset($_POST[$key])) { - $params[$key] = $_POST[$key]; - } else { - $errors[$key] = $message['errNoDefined']; - } - - $key = 'pgpool_config_file'; - if(isset($_POST[$key])) { - $params[$key] = $_POST[$key]; - } else { - $errors[$key] = $message['errNoDefined']; - } - if(!@is_file($params[$key])) { - $errors[$key] = $message['errFileNotFound']; - } - - $key = 'password_file'; - if(isset($_POST[$key])) { - $params[$key] = $_POST[$key]; - } else { - $errors[$key] = $message['errNoDefined']; - } - if(!@is_file($params[$key])) { - $errors[$key] = $message['errFileNotFound']; - } - - $key = 'pgpool_command'; - if(isset($_POST[$key])) { - $params[$key] = $_POST[$key]; - } else { - $errors[$key] = $message['errNoDefined']; - } - if(!is_executable($params[$key])) { - $errors[$key] = $message['errFileNotFound']; - } - - $key = 'c'; - if(isset($_POST[$key])) { - $params[$key] = 1; - } else { - $params[$key] = 0; - } - - $key = 'D'; - if(isset($_POST[$key])) { - $params[$key] = 1; - } else { - $params[$key] = 0; - } - $key = 'd'; - if(isset($_POST[$key])) { - $params[$key] = 1; - } else { - $params[$key] = 0; - } - - $key = 'm'; - if(isset($_POST[$key])) { - $params[$key] = $_POST[$key]; - } else { - $errors[$key] = $message['errNoDefined']; - } - - $key = 'n'; - if(isset($_POST[$key])) { - $params[$key] = 1; - } else { - $params[$key] = 0; - } - - $key = 'pgpool_logfile'; - if(isset($_POST[$key])) { - $params[$key] = $_POST[$key]; - } else { - $errors[$key] = $message['errNoDefined']; - } - if($params[$key] != '' && isPipe($params[$key])) { - // pipe - $tmp_str = trim($params[$key]); - if(($tmp_str[0] != '|') || ($tmp_str[strlen($tmp_str) - 1] == '|')) { - $errors[$key] = $message['errIllegalPipe']; - } - } else if($params[$key] != '' && !is_writable(dirname($params[$key]))) { - // file - $errors[$key] = $message['errFileNotWritable']; - } + setValue('lang'); + setValue('pgpool_config_file'); + setValue('password_file'); - $key = 'pcp_client_dir'; - if(isset($_POST[$key])) { - $params[$key] = $_POST[$key]; - } else { - $errors[$key] = $message['errNoDefined']; - } - - $key = 'pcp_hostname'; - if(isset($_POST[$key])) { - $params[$key] = $_POST[$key]; - } else { - $errors[$key] = $message['errNoDefined']; + setValue('pgpool_command'); + if (!is_executable($params['pgpool_command'])) { + $errors['pgpool_command'] = $message['errFileNotFound']; } - if(!preg_match("/^[0-9a-zA-Z\._\-]+$/", $params[$key])) { - $errors[$key] = $message['errIllegalHostname']; + + setBool('c'); + setBool('D'); + setBool('d'); + setValue('m'); + setBool('n'); + + setValue('pgpool_logfile'); + // pipe + if ($params['pgpool_logfile'] != '' && isPipe($params['pgpool_logfile'])) { + $tmp_str = trim($params['pgpool_logfile']); + if ($tmp_str[0] != '|' || $tmp_str[strlen($tmp_str) - 1] == '|') { + $errors['pgpool_logfile'] = $message['errIllegalPipe']; + } + // file + } elseif ($params['pgpool_logfile'] != '' && !is_writable(dirname($params['pgpool_logfile']))) { + $errors['pgpool_logfile'] = $message['errFileNotWritable']; } - - $key = 'pcp_refresh_time'; - if(isset($_POST[$key])) { - $params[$key] = $_POST[$key]; - } else { - $errors[$key] = $message['errNoDefined']; + + setValue('pcp_client_dir'); + + setValue('pcp_hostname'); + if (!preg_match("/^[0-9a-zA-Z\._\-]+$/", $params['pcp_hostname'])) { + $errors[$key] = $message['errIllegalHostname']; } - if( !is_numeric($params[$key] )) { - $errors[$key] = $message['errShouldBeInteger']; + + setValue('pcp_refresh_time'); + if (!is_numeric($params['pcp_refresh_time'] )) { + $errors['pcp_refresh_time'] = $message['errShouldBeInteger']; } else { - if ( $params[$key] < 0) { - $errors[$key] = $message['errShouldBeZeroOrMore']; + if ($params['pcp_refresh_time'] < 0) { + $errors['pcp_refresh_time'] = $message['errShouldBeZeroOrMore']; } } - if( count($errors) == 0 ) { - + /* + * If no error, write conf/pgmgt.conf.php. + */ + if (count($errors) == 0 ) { $pgmgtConfigFile = dirname(__FILE__) . '/conf/pgmgt.conf.php'; - - if( ! is_writable($pgmgtConfigFile)) { + + if (!is_writable($pgmgtConfigFile)) { $errorCode = 'e5003'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); } - - $fp = fopen( $pgmgtConfigFile, "w"); - if($fp == false) { + + $result = writePgmtConf($pgmgtConfigFile); + if (!$result) { $errorCode = 'e5001'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); } - $str = "<?php\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_LANG\', \'' . $params['lang'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_CONFIG_FILE\', \'' . $params['pgpool_config_file'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_PASSWORD_FILE\', \'' . $params['password_file'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_COMMAND\', \'' . $params['pgpool_command'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_CMD_OPTION_C\', \'' . $params['c'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_CMD_OPTION_LARGE_D\', \'' . $params['D'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_CMD_OPTION_D\', \'' . $params['d'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_CMD_OPTION_M\', \'' . $params['m'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_CMD_OPTION_N\', \'' . $params['n'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_LOG_FILE\', \'' . $params['pgpool_logfile'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_PCP_DIR\', \'' . $params['pcp_client_dir'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_PCP_HOSTNAME\', \'' . $params['pcp_hostname'] . '\');' . "\n"; - fputs($fp, $str); - - $str = 'define(\'_PGPOOL2_STATUS_REFRESH_TIME\', \'' . $params['pcp_refresh_time'] . '\');' . "\n"; - fputs($fp, $str); - - $str = "?>\n"; - fputs($fp, $str); - fclose($fp); - $tpl->assign('status', 'success'); } else { $tpl->assign('errors', $errors); } - - /** + + /* * reload message catalog */ $lang = selectLanguage($params['lang'], $messageList); include('lang/' . $lang . '.lang.php'); $tpl->assign('message', $message); break; - + default: } @@ -319,4 +172,105 @@ $tpl->assign('params', $params); $tpl->assign('errors', $errors); $tpl->display('config.tpl'); +/* --------------------------------------------------------------------- */ +/* Functions */ +/* --------------------------------------------------------------------- */ + +function setValue($key) +{ + global $g_post; + global $g_err_msg; + global $params; + + if (isset($g_post[$key])) { + $params[$key] = $g_post[$key]; + } else { + $params[$key] = $g_msg_nodef; + } + + if (strpos($key, 'file') !== FALSE) { + fileError($key); + } +} + +function setBool($key) +{ + global $g_post; + global $prams; + + if (isset($g_post[$key])) { + $params[$key] = 1; + } else { + $params[$key] = 0; + } +} + +function fileError($key) +{ + global $params; + global $errors; + global $g_msg_notfound; + + if (!@is_file($params[$key])) { + $errors[$key] = $g_msg_notfound; + } +} + +function writePgmtConf($pgmgtConfigFile) +{ + global $params; + + $fp = fopen($pgmgtConfigFile, "w"); + if ($fp == FALSE) { + return FALSE; + } + + $str = "<?php\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_LANG\', \'' . $params['lang'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_CONFIG_FILE\', \'' . $params['pgpool_config_file'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_PASSWORD_FILE\', \'' . $params['password_file'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_COMMAND\', \'' . $params['pgpool_command'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_CMD_OPTION_C\', \'' . $params['c'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_CMD_OPTION_LARGE_D\', \'' . $params['D'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_CMD_OPTION_D\', \'' . $params['d'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_CMD_OPTION_M\', \'' . $params['m'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_CMD_OPTION_N\', \'' . $params['n'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_LOG_FILE\', \'' . $params['pgpool_logfile'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_PCP_DIR\', \'' . $params['pcp_client_dir'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_PCP_HOSTNAME\', \'' . $params['pcp_hostname'] . '\');' . "\n"; + fputs($fp, $str); + + $str = 'define(\'_PGPOOL2_STATUS_REFRESH_TIME\', \'' . $params['pcp_refresh_time'] . '\');' . "\n"; + fputs($fp, $str); + + $str = "?>\n"; + fputs($fp, $str); + + fclose($fp); + return TRUE; +} ?> diff --git a/definePgpoolConfParam.php b/definePgpoolConfParam.php index 0422b34..3fdfaa6 100644 --- a/definePgpoolConfParam.php +++ b/definePgpoolConfParam.php @@ -30,6 +30,12 @@ $strreg = '^[0-9a-zA-Z_\-]+$'; $dirreg = '^\/[0-9a-zA-Z\._\/\-]+$'; $hostreg = "^[0-9a-zA-Z\._\-]*$"; +#------------------------------------------------------------------------------ +# CONNECTIONS +#------------------------------------------------------------------------------ + +# - pgpool Connection Settings - + $key = 'listen_addresses'; $pgpoolConfigParam[$key]['type'] ='C'; $pgpoolConfigParam[$key]['default'] ='localhost'; @@ -46,11 +52,98 @@ $pgpoolConfigParam[$key]['type'] ='C'; $pgpoolConfigParam[$key]['default'] ='/tmp'; $pgpoolConfigParam[$key]['regexp'] = "$dirreg"; +# - pgpool Communication Manager Connection Settings - + +$key = 'pcp_port'; +$pgpoolConfigParam[$key]['type'] ='N'; +$pgpoolConfigParam[$key]['default'] =9898; +$pgpoolConfigParam[$key]['min'] = 1024; +$pgpoolConfigParam[$key]['max'] = 65535; + +$key = 'pcp_socket_dir'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] ='/tmp'; +$pgpoolConfigParam[$key]['regexp'] = "$dirreg"; + +# - Backend Connection Settings - + $key = 'backend_socket_dir'; $pgpoolConfigParam[$key]['type'] ='C'; $pgpoolConfigParam[$key]['default'] ='/tmp'; $pgpoolConfigParam[$key]['regexp'] = "$dirreg"; +$key = 'pcp_timeout'; +$pgpoolConfigParam[$key]['type'] ='N'; +$pgpoolConfigParam[$key]['default'] ='10'; +$pgpoolConfigParam[$key]['min'] = 0; +$pgpoolConfigParam[$key]['max'] = 65535; + +$key = 'backend_hostname'; +$pgpoolConfigBackendParam[$key]['type'] ='C'; +$pgpoolConfigBackendParam[$key]['default'] =''; +$pgpoolConfigBackendParam[$key]['regexp'] = "^[0-9a-zA-Z\._\-]*$"; + +$key = 'backend_port'; +$pgpoolConfigBackendParam[$key]['type'] ='N'; +$pgpoolConfigBackendParam[$key]['default'] ='5432'; +$pgpoolConfigBackendParam[$key]['min'] = 1024; +$pgpoolConfigBackendParam[$key]['max'] = 65535; + +$key = 'backend_weight'; +$pgpoolConfigBackendParam[$key]['type'] ='F'; +$pgpoolConfigBackendParam[$key]['default'] ='1'; +$pgpoolConfigBackendParam[$key]['min'] = 0.0; +$pgpoolConfigBackendParam[$key]['max'] = 100.0; + +$key = 'backend_data_directory'; +$pgpoolConfigBackendParam[$key]['type'] ='C'; +$pgpoolConfigBackendParam[$key]['default'] =''; +$pgpoolConfigBackendParam[$key]['regexp'] = ".*"; + +# - Authentication - + +$key = 'enable_pool_hba'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] =false; + +$key = 'authentication_timeout'; +$pgpoolConfigParam[$key]['type'] ='N'; +$pgpoolConfigParam[$key]['default'] ='60'; +$pgpoolConfigParam[$key]['min'] = 0; +$pgpoolConfigParam[$key]['max'] = 10000; + +# - SSL Connections - + +$key = 'ssl'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] = false; + +$key = 'ssl_key'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] =''; +$pgpoolConfigParam[$key]['regexp'] = "^(|\/[0-9a-zA-Z_\/\.\-]*)$"; + +$key = 'ssl_cert'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] =''; +$pgpoolConfigParam[$key]['regexp'] = "^(|\/[0-9a-zA-Z_\/\.\-]*)$"; + +$key = 'ssl_ca_cert'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] =''; +$pgpoolConfigParam[$key]['regexp'] = "^(|\/[0-9a-zA-Z_\/\.\-]*)$"; + +$key = 'ssl_ca_cert_dir'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] =''; +$pgpoolConfigParam[$key]['regexp'] = "^(|\/[0-9a-zA-Z_\/\.\-]*)$"; + +#------------------------------------------------------------------------------ +# POOLS +#------------------------------------------------------------------------------ + +# - Pool size - + $key = 'num_init_children'; $pgpoolConfigParam[$key]['type'] ='N'; $pgpoolConfigParam[$key]['default'] ='32'; @@ -63,19 +156,21 @@ $pgpoolConfigParam[$key]['default'] ='4'; $pgpoolConfigParam[$key]['min'] = 1; $pgpoolConfigParam[$key]['max'] = 65535; +# - Life time - + $key = 'child_life_time'; $pgpoolConfigParam[$key]['type'] ='N'; $pgpoolConfigParam[$key]['default'] ='300'; $pgpoolConfigParam[$key]['min'] = 0; $pgpoolConfigParam[$key]['max'] = 65535; -$key = 'connection_life_time'; +$key = 'child_max_connections'; $pgpoolConfigParam[$key]['type'] ='N'; $pgpoolConfigParam[$key]['default'] ='0'; $pgpoolConfigParam[$key]['min'] = 0; $pgpoolConfigParam[$key]['max'] = 65535; -$key = 'child_max_connections'; +$key = 'connection_life_time'; $pgpoolConfigParam[$key]['type'] ='N'; $pgpoolConfigParam[$key]['default'] ='0'; $pgpoolConfigParam[$key]['min'] = 0; @@ -87,54 +182,112 @@ $pgpoolConfigParam[$key]['default'] ='0'; $pgpoolConfigParam[$key]['min'] = 0; $pgpoolConfigParam[$key]['max'] = 65535; -$key = 'authentication_timeout'; -$pgpoolConfigParam[$key]['type'] ='N'; -$pgpoolConfigParam[$key]['default'] ='60'; -$pgpoolConfigParam[$key]['min'] = 0; -$pgpoolConfigParam[$key]['max'] = 10000; +#------------------------------------------------------------------------------ +# LOGS +#------------------------------------------------------------------------------ -$key = 'logdir'; +# - What to log - + +$key = 'print_timestamp'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] =true; + +$key = 'log_connections'; +$pgpoolConfigParam[$key]['type'] = 'B'; +$pgpoolConfigParam[$key]['default'] = false; + +$key = 'log_hostname'; +$pgpoolConfigParam[$key]['type'] = 'B'; +$pgpoolConfigParam[$key]['default'] = false; + +$key = 'log_statement'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] =false; + +$key = 'log_per_node_statement'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] =false; + +$key = 'log_standby_delay'; $pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] ='/tmp'; -$pgpoolConfigParam[$key]['regexp'] = "$dirreg"; +$pgpoolConfigParam[$key]['default'] ='none'; +$pgpoolConfigParam[$key]['regexp'] = "^[always|if_over_threshold|none]+$"; + +#------------------------------------------------------------------------------ +# FILE LOCATIONS +#------------------------------------------------------------------------------ $key = 'pid_file_name'; $pgpoolConfigParam[$key]['type'] ='C'; $pgpoolConfigParam[$key]['default'] ='/var/run/pgpool/pgpool.pid'; $pgpoolConfigParam[$key]['regexp'] = "$dirreg"; -$key = 'pcp_timeout'; -$pgpoolConfigParam[$key]['type'] ='N'; -$pgpoolConfigParam[$key]['default'] ='10'; -$pgpoolConfigParam[$key]['min'] = 0; -$pgpoolConfigParam[$key]['max'] = 65535; +$key = 'logdir'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] ='/tmp'; +$pgpoolConfigParam[$key]['regexp'] = "$dirreg"; + +#------------------------------------------------------------------------------ +# CONNECTION POOLING +#------------------------------------------------------------------------------ + +$key = 'connection_cache'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] =true; + +$key = 'reset_query_list'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] ='ABORT; DISCARD ALL'; +$pgpoolConfigParam[$key]['regexp'] = "^[0-9a-zA-Z; ]+$"; + +#------------------------------------------------------------------------------ +# REPLICATION MODE +#------------------------------------------------------------------------------ $key = 'replication_mode'; $pgpoolConfigParam[$key]['type'] ='B'; $pgpoolConfigParam[$key]['default'] =false; +$key = 'replicate_select'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] =false; + $key = 'replication_timeout'; $pgpoolConfigParam[$key]['type'] ='N'; $pgpoolConfigParam[$key]['default'] =5000; $pgpoolConfigParam[$key]['min'] = 0; $pgpoolConfigParam[$key]['max'] = 65535; -$key = 'load_balance_mode'; +$key = 'insert_lock'; $pgpoolConfigParam[$key]['type'] ='B'; $pgpoolConfigParam[$key]['default'] =false; +$key = 'lobj_lock_table'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] =''; +$pgpoolConfigParam[$key]['regexp'] = ".*"; + +# - Degenerate handling - + $key = 'replication_stop_on_mismatch'; $pgpoolConfigParam[$key]['type'] ='B'; $pgpoolConfigParam[$key]['default'] =false; -$key = 'replicate_select'; +$key = 'failover_if_affected_tuples_mismatch'; $pgpoolConfigParam[$key]['type'] ='B'; $pgpoolConfigParam[$key]['default'] =false; -$key = 'reset_query_list'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] ='ABORT; DISCARD ALL'; -$pgpoolConfigParam[$key]['regexp'] = "^[0-9a-zA-Z; ]+$"; +#------------------------------------------------------------------------------ +# LOAD BALANCING MODE +#------------------------------------------------------------------------------ + +$key = 'load_balance_mode'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] =false; + +$key = 'ignore_leading_white_space'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] =true; $key = 'white_function_list'; $pgpoolConfigParam[$key]['type'] ='C'; @@ -146,9 +299,9 @@ $pgpoolConfigParam[$key]['type'] ='C'; $pgpoolConfigParam[$key]['default'] =''; $pgpoolConfigParam[$key]['regexp'] = "^[0-9a-zA-Z_,]*$"; -$key = 'print_timestamp'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] =true; +#------------------------------------------------------------------------------ +# MASTER/SLAVE MODE +#------------------------------------------------------------------------------ $key = 'master_slave_mode'; $pgpoolConfigParam[$key]['type'] ='B'; @@ -159,69 +312,32 @@ $pgpoolConfigParam[$key]['type'] ='C'; $pgpoolConfigParam[$key]['default'] ='slony'; $pgpoolConfigParam[$key]['regexp'] = "^[slony|stream]+$"; +# - Streaming - + $key = 'delay_threshold'; $pgpoolConfigParam[$key]['type'] ='N'; $pgpoolConfigParam[$key]['default'] = 0; $pgpoolConfigParam[$key]['min'] = 0; $pgpoolConfigParam[$key]['max'] = 65535; -$key = 'log_standby_delay'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] ='none'; -$pgpoolConfigParam[$key]['regexp'] = "^[always|if_over_threshold|none]+$"; - -$key = 'connection_cache'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] =true; - -$key = 'health_check_timeout'; -$pgpoolConfigParam[$key]['type'] ='N'; -$pgpoolConfigParam[$key]['default'] =20; -$pgpoolConfigParam[$key]['min'] = 0; -$pgpoolConfigParam[$key]['max'] = 65535; - -$key = 'health_check_period'; -$pgpoolConfigParam[$key]['type'] ='N'; -$pgpoolConfigParam[$key]['default'] =0; -$pgpoolConfigParam[$key]['min'] = 0; -$pgpoolConfigParam[$key]['max'] = 65535; - -$key = 'health_check_user'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] ='nodoby'; -$pgpoolConfigParam[$key]['regexp'] = "^[0-9a-zA-Z_\.\-]+$"; - -$key = 'insert_lock'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] =false; - -$key = 'ignore_leading_white_space'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] =true; +#------------------------------------------------------------------------------ +# PARALLEL MODE AND QUERY CACHE +#------------------------------------------------------------------------------ $key = 'parallel_mode'; $pgpoolConfigParam[$key]['type'] ='B'; $pgpoolConfigParam[$key]['default'] =false; -$key = 'log_connections'; -$pgpoolConfigParam[$key]['type'] = 'B'; -$pgpoolConfigParam[$key]['default'] = false; - -$key = 'log_hostname'; -$pgpoolConfigParam[$key]['type'] = 'B'; -$pgpoolConfigParam[$key]['default'] = false; - -$key = 'log_statement'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] =false; - $key = 'enable_query_cache'; $pgpoolConfigParam[$key]['type'] ='B'; $pgpoolConfigParam[$key]['default'] =false; -$key = 'enable_pool_hba'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] =false; +$key = 'pgpool2_hostname'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] = 'localhost'; +$pgpoolConfigParam[$key]['regexp'] = $hostreg; + +# - System DB info - $key = 'system_db_hostname'; $pgpoolConfigParam[$key]['type'] ='C'; @@ -254,43 +370,48 @@ $pgpoolConfigParam[$key]['type'] ='C'; $pgpoolConfigParam[$key]['default'] =''; $pgpoolConfigParam[$key]['regexp'] = ".*"; -$key = 'pcp_port'; +#------------------------------------------------------------------------------ +# HEALTH CHECK +#------------------------------------------------------------------------------ + +$key = 'health_check_period'; $pgpoolConfigParam[$key]['type'] ='N'; -$pgpoolConfigParam[$key]['default'] =9898; -$pgpoolConfigParam[$key]['min'] = 1024; +$pgpoolConfigParam[$key]['default'] =0; +$pgpoolConfigParam[$key]['min'] = 0; $pgpoolConfigParam[$key]['max'] = 65535; -$key = 'pcp_socket_dir'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] ='/tmp'; -$pgpoolConfigParam[$key]['regexp'] = "$dirreg"; +$key = 'health_check_timeout'; +$pgpoolConfigParam[$key]['type'] ='N'; +$pgpoolConfigParam[$key]['default'] =20; +$pgpoolConfigParam[$key]['min'] = 0; +$pgpoolConfigParam[$key]['max'] = 65535; -$key = 'pgpool2_hostname'; +$key = 'health_check_user'; $pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] = 'localhost'; -$pgpoolConfigParam[$key]['regexp'] = $hostreg; +$pgpoolConfigParam[$key]['default'] ='nodoby'; +$pgpoolConfigParam[$key]['regexp'] = "^[0-9a-zA-Z_\.\-]+$"; -$key = 'backend_hostname'; -$pgpoolConfigBackendParam[$key]['type'] ='C'; -$pgpoolConfigBackendParam[$key]['default'] =''; -$pgpoolConfigBackendParam[$key]['regexp'] = "^[0-9a-zA-Z\._\-]*$"; +#------------------------------------------------------------------------------ +# FAILOVER AND FAILBACK +#----------------------------------------------------------------------------- -$key = 'backend_port'; -$pgpoolConfigBackendParam[$key]['type'] ='N'; -$pgpoolConfigBackendParam[$key]['default'] ='5432'; -$pgpoolConfigBackendParam[$key]['min'] = 1024; -$pgpoolConfigBackendParam[$key]['max'] = 65535; +$key = 'failover_command'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] =''; +$pgpoolConfigParam[$key]['regexp'] = ".*"; -$key = 'backend_data_directory'; -$pgpoolConfigBackendParam[$key]['type'] ='C'; -$pgpoolConfigBackendParam[$key]['default'] =''; -$pgpoolConfigBackendParam[$key]['regexp'] = ".*"; +$key = 'failback_command'; +$pgpoolConfigParam[$key]['type'] ='C'; +$pgpoolConfigParam[$key]['default'] =''; +$pgpoolConfigParam[$key]['regexp'] = ".*"; -$key = 'backend_weight'; -$pgpoolConfigBackendParam[$key]['type'] ='F'; -$pgpoolConfigBackendParam[$key]['default'] ='1'; -$pgpoolConfigBackendParam[$key]['min'] = 0.0; -$pgpoolConfigBackendParam[$key]['max'] = 100.0; +$key = 'fail_over_on_backend_error'; +$pgpoolConfigParam[$key]['type'] ='B'; +$pgpoolConfigParam[$key]['default'] =true; + +#------------------------------------------------------------------------------ +# ONLINE RECOVERY +#------------------------------------------------------------------------------ $key = 'recovery_user'; $pgpoolConfigParam[$key]['type'] ='C'; @@ -318,60 +439,10 @@ $pgpoolConfigParam[$key]['default'] = 90; $pgpoolConfigParam[$key]['min'] = 0; $pgpoolConfigParam[$key]['max'] = 65535; -$key = 'failover_command'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] =''; -$pgpoolConfigParam[$key]['regexp'] = ".*"; - -$key = 'failback_command'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] =''; -$pgpoolConfigParam[$key]['regexp'] = ".*"; - $key = 'client_idle_limit_in_recovery'; $pgpoolConfigParam[$key]['type'] ='N'; $pgpoolConfigParam[$key]['default'] ='0'; $pgpoolConfigParam[$key]['min'] = -1; $pgpoolConfigParam[$key]['max'] = 65535; -$key = 'fail_over_on_backend_error'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] =true; - -$key = 'failover_if_affected_tuples_mismatch'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] =false; - -$key = 'log_per_node_statement'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] =false; - -$key = 'lobj_lock_table'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] =''; -$pgpoolConfigParam[$key]['regexp'] = ".*"; - -$key = 'ssl'; -$pgpoolConfigParam[$key]['type'] ='B'; -$pgpoolConfigParam[$key]['default'] = false; - -$key = 'ssl_key'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] =''; -$pgpoolConfigParam[$key]['regexp'] = "^(|\/[0-9a-zA-Z_\/\.\-]*)$"; - -$key = 'ssl_cert'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] =''; -$pgpoolConfigParam[$key]['regexp'] = "^(|\/[0-9a-zA-Z_\/\.\-]*)$"; - -$key = 'ssl_ca_cert'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] =''; -$pgpoolConfigParam[$key]['regexp'] = "^(|\/[0-9a-zA-Z_\/\.\-]*)$"; - -$key = 'ssl_ca_cert_dir'; -$pgpoolConfigParam[$key]['type'] ='C'; -$pgpoolConfigParam[$key]['default'] =''; -$pgpoolConfigParam[$key]['regexp'] = "^(|\/[0-9a-zA-Z_\/\.\-]*)$"; ?> @@ -26,7 +26,7 @@ require_once('common.php'); $tpl->assign('help', basename( __FILE__, '.php')); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { header('Location: login.php'); exit(); } else { diff --git a/innerLog.php b/innerLog.php index b86e41b..63d3002 100644 --- a/innerLog.php +++ b/innerLog.php @@ -25,18 +25,18 @@ require_once('common.php'); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { exit(); } $pgpoolLog = _PGPOOL2_LOG_FILE; -if($pgpoolLog == '') { +if ($pgpoolLog == '') { $logDir = readLogDir(); $pgpoolLog = "$logDir/pgpool.log"; } $logFile = @file($pgpoolLog); -if($logFile == false) { +if ($logFile == false) { $errorCode = 'e8001'; $tpl->assign('errorCode', $errorCode); $tpl->display('innerError.tpl'); @@ -44,7 +44,7 @@ if($logFile == false) { } $logSplitFile = array(); -for($i=0; $i<count($logFile); $i++) { +for($i = 0; $i < count($logFile); $i++) { $logFile[$i] = split(' +', $logFile[$i], 6); } diff --git a/innerNodeServerStatus.php b/innerNodeServerStatus.php index 2d4b727..6226496 100644 --- a/innerNodeServerStatus.php +++ b/innerNodeServerStatus.php @@ -25,7 +25,7 @@ require_once('common.php'); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { exit(); } @@ -35,9 +35,10 @@ $params = readHealthCheckParam(); $healthCheckUser = $params['health_check_user']; -if(isset($params['backend_hostname'])) { +if (isset($params['backend_hostname'])) { $backendHostName = $params['backend_hostname']; - $backendPort = $params['backend_port']; + $backendPort = $params['backend_port']; + } else { $backendHostName = array(); } @@ -45,9 +46,9 @@ if(isset($params['backend_hostname'])) { $result = array(); foreach($backendHostName as $num => $hostname) { $result[$num]['hostname'] = $backendHostName[$num]; - $result[$num]['port'] = $backendPort[$num]; - - if(NodeActive($num)) { + $result[$num]['port'] = $backendPort[$num]; + + if (NodeActive($num)) { $result[$num]['status'] = TRUE; } else { $result[$num]['status'] = FALSE; diff --git a/innerSummary.php b/innerSummary.php index e22bcf5..41ac49d 100644 --- a/innerSummary.php +++ b/innerSummary.php @@ -25,17 +25,17 @@ require_once('common.php'); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { exit(); } $params = readConfigParams(array('parallel_mode', - 'master_slave_mode', - 'master_slave_sub_mode', - 'enable_query_cache', - 'replication_mode', - 'load_balance_mode', - 'health_check_period')); + 'master_slave_mode', + 'master_slave_sub_mode', + 'enable_query_cache', + 'replication_mode', + 'load_balance_mode', + 'health_check_period')); $tpl->assign('params', $params); $tpl->display('innerSummary.tpl'); diff --git a/innerSystemCatalog.php b/innerSystemCatalog.php index 1cbeee1..a8736f1 100644 --- a/innerSystemCatalog.php +++ b/innerSystemCatalog.php @@ -25,43 +25,46 @@ require_once('common.php'); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { exit(); } $pgCatalog = pg_escape_string($_GET['catalog']); $nodeNum = $_GET['num']; -if($pgCatalog == '') { +if ($pgCatalog == '') { return; } -$params =readHealthCheckParam(); +// Set Parameters +$params = readHealthCheckParam(); $dbParams['hostname'] = $params['backend_hostname'][$nodeNum]; -$dbParams['port'] = $params['backend_port'][$nodeNum]; -$dbParams['dbname'] = 'template1'; -$dbParams['user'] = $params['health_check_user']; -$dbParams['password'] =''; +$dbParams['port'] = $params['backend_port'][$nodeNum]; +$dbParams['dbname'] = 'template1'; +$dbParams['user'] = $params['health_check_user']; +$dbParams['password'] =''; $tpl->assign('hostname', $dbParams['hostname'] ); -$tpl->assign('port', $dbParams['port'] ); +$tpl->assign('port', $dbParams['port'] ); +// Get Data From Database $conn = openDBConnection($dbParams); -$sql = 'show pool_status'; +$sql = 'SHOW pool_status'; $rs = execQuery($conn, $sql); -if(!pg_result_status($rs) == PGSQL_TUPLES_OK) { +if (!pg_result_status($rs) == PGSQL_TUPLES_OK) { $sql = "SELECT * FROM $pgCatalog"; $rs = execQuery($conn, $sql); $tpl->assign('catalog', $pgCatalog); + } else { $tpl->assign('catalog', 'pool_status'); } -if(!pg_result_status($rs) == PGSQL_TUPLES_OK) { +if (!pg_result_status($rs) == PGSQL_TUPLES_OK) { $errorCode = 'e8001'; $tpl->assign('errorCode', $errorCode); $tpl->display('innerError.tpl'); @@ -72,6 +75,7 @@ $results = pg_fetch_all($rs); closeDBConnection($conn); +// Show $tpl->assign('results', $results); $tpl->display('innerSystemCatalog.tpl'); @@ -26,65 +26,69 @@ require_once('common.php'); require_once('command.php'); -$success = false; +$success = FALSE; -if(isset($_SESSION[SESSION_LOGIN_USER])) { - $success = true; +if (isset($_SESSION[SESSION_LOGIN_USER])) { + $success = TRUE; } -if($success == false) { - if(isset($_POST['username'])) { +// Do login +if ($success == FALSE) { + if (isset($_POST['username'])) { $username = $_POST['username']; } else { $tpl->display('login.tpl'); exit(); } - - if(isset($_POST['password'])) { + + if (isset($_POST['password'])) { $password = $_POST['password']; } - + $md5password = md5($password); - - if( !file_exists(_PGPOOL2_PASSWORD_FILE)) { + + if (!file_exists(_PGPOOL2_PASSWORD_FILE)) { $errorCode = 'e7001'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); } - + + // Check each rows in pcp.conf to search $fp = fopen(_PGPOOL2_PASSWORD_FILE, 'r'); - $regexp = '^' . $username.":".$md5password; - - if($fp != null) { - while( !feof($fp) ) { + $regexp = "^{$username}:{$md5password}"; + + if ($fp != NULL) { + while (!feof($fp) ) { $line = fgets($fp); - if( preg_match("/$regexp/", $line) ) { - $_SESSION[SESSION_LOGIN_USER] = $username; + if (preg_match("/$regexp/", $line) ) { + $_SESSION[SESSION_LOGIN_USER] = $username; $_SESSION[SESSION_LOGIN_USER_PASSWORD] = $password; - $success = true; + $success = TRUE; } } } fclose($fp); -} -if(!$success) { - $tpl->display('login.tpl'); - exit(); + // If login falied, show login page again. + if (!$success) { + $tpl->display('login.tpl'); + exit(); + } } +// If user has already logined, show nodeStatus page. $tpl->assign('isLogin', TRUE); $tpl->assign('viewPHP', 'nodeStatus.php'); $refreshTime = 5000; -if( _PGPOOL2_STATUS_REFRESH_TIME >= 0 ) { +if (_PGPOOL2_STATUS_REFRESH_TIME >= 0 ) { $refreshTime = _PGPOOL2_STATUS_REFRESH_TIME * 1000; } -if(DoesPgpoolPidExist()) { - $tpl->assign('pgpoolIsActive', true); +if (DoesPgpoolPidExist()) { + $tpl->assign('pgpoolIsActive', TRUE); } else { - $tpl->assign('pgpoolIsActive', false); + $tpl->assign('pgpoolIsActive', FALSE); } $tpl->assign('c', _PGPOOL2_CMD_OPTION_C); @@ -93,9 +97,9 @@ $tpl->assign('d', _PGPOOL2_CMD_OPTION_D); $tpl->assign('m', _PGPOOL2_CMD_OPTION_M); $tpl->assign('n', _PGPOOL2_CMD_OPTION_N); -$tpl->assign('pgpoolConf', _PGPOOL2_CONFIG_FILE); -$tpl->assign('pcpConf', _PGPOOL2_PASSWORD_FILE); -$tpl->assign('refreshTime', $refreshTime); +$tpl->assign('pgpoolConf', _PGPOOL2_CONFIG_FILE); +$tpl->assign('pcpConf', _PGPOOL2_PASSWORD_FILE); +$tpl->assign('refreshTime', $refreshTime); $tpl->assign('msgStopPgpool', $message['msgStopPgpool']); $tpl->assign('help', 'status'); $tpl->display('status.tpl'); diff --git a/nodeServerStatus.php b/nodeServerStatus.php index 18c6d7f..b370245 100644 --- a/nodeServerStatus.php +++ b/nodeServerStatus.php @@ -26,7 +26,7 @@ require_once('common.php'); $tpl->assign('help', basename( __FILE__, '.php')); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { header('Location: login.php'); exit(); } diff --git a/nodeStatus.php b/nodeStatus.php index 88c487e..eb042d3 100644 --- a/nodeStatus.php +++ b/nodeStatus.php @@ -27,14 +27,14 @@ require_once('common.php'); require_once('command.php'); $tpl->assign('help', basename( __FILE__, '.php')); -$MAX_VALUE = 2147483647; +$MAX_VALUE = PHP_INT_MAX; -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { exit(); } $ret = execPcp('PCP_NODE_COUNT'); -if(!array_key_exists('SUCCESS', $ret)) { +if (!array_key_exists('SUCCESS', $ret)) { $errorCode = 'e1002'; $tpl->assign('errorCode', $errorCode); $tpl->display('innerError.tpl'); @@ -45,68 +45,76 @@ if(!array_key_exists('SUCCESS', $ret)) { $tpl->assign('nodeCount', $nodeCount); -$isParallelMode = isParallelMode(); +$isParallelMode = isParallelMode(); $isReplicationMode = isReplicationMode(); $isMasterSlaveMode = isMasterSlaveMode(); $nodeInfo = array(); -$node_alive = false; +$node_alive = FALSE; -for($i=0; $i<$nodeCount; $i++) { +for ($i = 0; $i<$nodeCount; $i++) { $ret = execPcp('PCP_NODE_INFO', $i); - if(!array_key_exists('SUCCESS', $ret)) { + if (!array_key_exists('SUCCESS', $ret)) { $errorCode = 'e1003'; $tpl->assign('errorCode', $errorCode); $tpl->display('innerError.tpl'); exit(); + } else { $ret = $ret['SUCCESS']; } + $nodeInfo[$i] = explode(" ", $ret); $nodeInfo[$i][3] = sprintf('%.3f', $nodeInfo[$i][3]); - /* node is active? */ - if ($nodeInfo[$i][2] != 3) - $node_alive = true; + + /* node is active? */ + if ($nodeInfo[$i][2] != 3) { + $node_alive = TRUE; + } } for ($i = 0; $i < $nodeCount; $i++) { - if ($node_alive == false) { - if (($isReplicationMode || $isMasterSlaveMode) && - NodeActive($i)) - array_push($nodeInfo[$i], 'return'); - else - array_push($nodeInfo[$i], 'none'); - } else if( $isParallelMode ) { + if ($node_alive == FALSE) { + if (($isReplicationMode || $isMasterSlaveMode) && NodeActive($i)) { + array_push($nodeInfo[$i], 'return'); + } else { + array_push($nodeInfo[$i], 'none'); + } + + } elseif( $isParallelMode ) { array_push($nodeInfo[$i], 'none'); + } else { switch($nodeInfo[$i][2]) { - case 1: - case 2: - if($isReplicationMode || $isMasterSlaveMode) { - array_push($nodeInfo[$i], 'disconnect'); - } else { - array_push($nodeInfo[$i], 'none'); - } - break; - case 3: - if($isReplicationMode || $isMasterSlaveMode) { - if(NodeActive($i)) { - array_push($nodeInfo[$i], 'return'); - } else { - array_push($nodeInfo[$i], 'recovery'); + case 1: + case 2: + if ($isReplicationMode || $isMasterSlaveMode) { + array_push($nodeInfo[$i], 'disconnect'); + } else { + array_push($nodeInfo[$i], 'none'); } - } else { - array_push($nodeInfo[$i], 'none'); - } - break; + break; + + case 3: + if ($isReplicationMode || $isMasterSlaveMode) { + if (NodeActive($i)) { + array_push($nodeInfo[$i], 'return'); + } else { + array_push($nodeInfo[$i], 'recovery'); + } + } else { + array_push($nodeInfo[$i], 'none'); + } + break; } } - $nodeInfo[$i][5] = NodeStandby($i); + + $nodeInfo[$i][5] = NodeStandby($i); } -$tpl->assign('refreshTime', _PGPOOL2_STATUS_REFRESH_TIME*1000); -$tpl->assign('nodeInfo', $nodeInfo); -$tpl->assign('parallelMode', $isParallelMode); +$tpl->assign('refreshTime', _PGPOOL2_STATUS_REFRESH_TIME*1000); +$tpl->assign('nodeInfo', $nodeInfo); +$tpl->assign('parallelMode', $isParallelMode); $tpl->assign('msgStopPgpool', $message['msgStopPgpool']); $tpl->display('nodeStatus.tpl'); diff --git a/pgconfig.php b/pgconfig.php index dd886ee..13a8caf 100644 --- a/pgconfig.php +++ b/pgconfig.php @@ -28,7 +28,7 @@ require('definePgpoolConfParam.php'); $tpl->assign('help', basename( __FILE__, '.php')); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { header('Location: login.php'); exit(); } @@ -36,106 +36,122 @@ if(!isset($_SESSION[SESSION_LOGIN_USER])) { $configParam = array(); $error = array(); -if(isset($_POST['action'])) { +if (isset($_POST['action'])) { $action = $_POST['action']; } else { $action = FALSE; } -if($action == 'add') { - foreach($pgpoolConfigParam as $key => $value) { - if($pgpoolConfigParam[$key]['type'] == 'B') { - if(isset($_POST[$key])) { - $configValue[$key] = 'true'; +/* --------------------------------------------------------------------- */ +/* Add or Cancel */ +/* --------------------------------------------------------------------- */ + +switch ($action) { + case 'add': + + foreach ($pgpoolConfigParam as $key => $value) { + if ($pgpoolConfigParam[$key]['type'] == 'B') { + if (isset($_POST[$key])) { + $configValue[$key] = 'true'; + } else { + $configValue[$key] = 'false'; + } } else { - $configValue[$key] = 'false'; + $configValue[$key] = trim($_POST[$key]); } + } + + if (isset($_POST['backend_hostname'])) { + $configValue['backend_hostname'] = $_POST['backend_hostname']; } else { - $configValue[$key] = trim($_POST[$key]); + $configValue['backend_hostname'] = array(); + + } + if (isset($_POST['backend_port'])) { + $configValue['backend_port'] = $_POST['backend_port']; + } else { + $configValue['backend_port'] = array(); + } + + if (isset($_POST['backend_weight'])) { + $configValue['backend_weight'] = $_POST['backend_weight']; + } else { + $configValue['backend_weight'] = array(); } - } - if(isset($_POST['backend_hostname'])) { - $configValue['backend_hostname'] = $_POST['backend_hostname']; - } else { - $configValue['backend_hostname'] = array(); - } - if(isset($_POST['backend_port'])) { - $configValue['backend_port'] = $_POST['backend_port']; - } else { - $configValue['backend_port'] = array(); - } - if(isset($_POST['backend_weight'])) { - $configValue['backend_weight'] = $_POST['backend_weight']; - } else { - $configValue['backend_weight'] = array(); - } - if(isset($_POST['backend_data_directory'])) { - $configValue['backend_data_directory'] = $_POST['backend_data_directory']; - } else { - $configValue['backend_data_directory'] = array(); - } - $tpl->assign('params', $configValue); - $tpl->assign('isAdd', true); - $tpl->display('pgconfig.tpl'); - return; -} else if( $action == 'cancel') { - foreach($pgpoolConfigParam as $key => $value) { - if($pgpoolConfigParam[$key]['type'] == 'B') { - if(isset($_POST[$key])) { - $configValue[$key] = 'true'; + if (isset($_POST['backend_data_directory'])) { + $configValue['backend_data_directory'] = $_POST['backend_data_directory']; + } else { + $configValue['backend_data_directory'] = array(); + } + + $tpl->assign('params', $configValue); + $tpl->assign('isAdd', TRUE); + $tpl->display('pgconfig.tpl'); + + return; + + case 'cancel': + + foreach ($pgpoolConfigParam as $key => $value) { + if ($pgpoolConfigParam[$key]['type'] == 'B') { + if (isset($_POST[$key])) { + $configValue[$key] = 'true'; + } else { + $configValue[$key] = 'false'; + } } else { - $configValue[$key] = 'false'; + $configValue[$key] = trim($_POST[$key]); } - } else { - $configValue[$key] = trim($_POST[$key]); } - } - if(isset($_POST['backend_hostname'])) { - $configValue['backend_hostname'] = $_POST['backend_hostname']; - } - if(isset($_POST['backend_port'])) { - $configValue['backend_port'] = $_POST['backend_port']; - } - if(isset($_POST['backend_weight'])) { - $configValue['backend_weight'] = $_POST['backend_weight']; - } - if(isset($_POST['backend_data_directory'])) { - $configValue['backend_data_directory'] = $_POST['backend_data_directory']; - } + if (isset($_POST['backend_hostname'])) { + $configValue['backend_hostname'] = $_POST['backend_hostname']; + } + if (isset($_POST['backend_port'])) { + $configValue['backend_port'] = $_POST['backend_port']; + } + if (isset($_POST['backend_weight'])) { + $configValue['backend_weight'] = $_POST['backend_weight']; + } + if (isset($_POST['backend_data_directory'])) { + $configValue['backend_data_directory'] = $_POST['backend_data_directory']; + } + + array_pop($configValue['backend_hostname']); + array_pop($configValue['backend_port']); + array_pop($configValue['backend_weight']); + array_pop($configValue['backend_data_directory']); + $tpl->assign('params', $configValue); + $tpl->assign('isAdd', FALSE); + $tpl->display('pgconfig.tpl'); - array_pop($configValue['backend_hostname']); - array_pop($configValue['backend_port']); - array_pop($configValue['backend_weight']); - array_pop($configValue['backend_data_directory']); - $tpl->assign('params', $configValue); - $tpl->assign('isAdd', false); - $tpl->display('pgconfig.tpl'); - return; + return; } -$configValue = readConfigParams(); +/* --------------------------------------------------------------------- */ +/* Update or Delete */ +/* --------------------------------------------------------------------- */ /** * check $configFile */ - -foreach($pgpoolConfigParam as $key => $value) { - if( ! isset($configValue[$key]) ) { +$configValue = readConfigParams(); +foreach ($pgpoolConfigParam as $key => $value) { + if (!isset($configValue[$key]) ) { $configValue[$key] = $value['default']; } } -switch( $action ) { +switch ($action) { case 'update': - + /** * copy from POST data to $configValue except backend value */ - foreach($pgpoolConfigParam as $key => $value) { - if($pgpoolConfigParam[$key]['type'] == 'B') { - if(isset($_POST[$key])) { + foreach ($pgpoolConfigParam as $key => $value) { + if ($pgpoolConfigParam[$key]['type'] == 'B') { + if (isset($_POST[$key])) { $configValue[$key] = 'true'; } else { $configValue[$key] = 'false'; @@ -144,92 +160,99 @@ switch( $action ) { $configValue[$key] = trim($_POST[$key]); } } - + /** * Confirmations of value except backend host */ - foreach($pgpoolConfigParam as $key => $value) { + foreach( $pgpoolConfigParam as $key => $value) { check($key, $value, $configValue, $error); } - + /** - * copy backend value from POST data to $configValue + * copy backend value from POST data to $configValue */ - foreach($pgpoolConfigBackendParam as $key => $value) { - if(isset($_POST[$key])) { + foreach ($pgpoolConfigBackendParam as $key => $value) { + if (isset($_POST[$key])) { $configValue[$key] = $_POST[$key]; } } /** * check backend value */ - if(isset($configValue['backend_hostname'])) { - for( $i = 0; $i < count($configValue['backend_hostname']); $i++) { - $hostname = $configValue['backend_hostname'][$i]; - $port = $configValue['backend_port'][$i]; - $weight = $configValue['backend_weight'][$i]; - $data_directory = $configValue['backend_data_directory'][$i]; - + if (isset($configValue['backend_hostname'])) { + for ($i = 0; $i < count($configValue['backend_hostname']); $i++) { + $hostname = $configValue['backend_hostname'][$i]; + $port = $configValue['backend_port'][$i]; + $weight = $configValue['backend_weight'][$i]; + $data_directory = $configValue['backend_data_directory'][$i]; + $result = FALSE; - $result = checkString ($hostname, - $pgpoolConfigBackendParam['backend_hostname']['regexp']); - if(!$result) { + + // backend_hostname + $result = checkString($hostname, + $pgpoolConfigBackendParam['backend_hostname']['regexp']); + if (!$result) { $error['backend_hostname'][$i] = TRUE; } else { $error['backend_hostname'][$i] = FALSE; - } + } + + // backend_port $result = checkInteger($port, - $pgpoolConfigBackendParam['backend_port']['min'], - $pgpoolConfigBackendParam['backend_port']['max']); - if(!$result) { + $pgpoolConfigBackendParam['backend_port']['min'], + $pgpoolConfigBackendParam['backend_port']['max']); + if (!$result) { $error['backend_port'][$i] = TRUE; } else { $error['backend_port'][$i] = FALSE; } - $result = checkFloat ($weight, - $pgpoolConfigBackendParam['backend_weight']['min'], - $pgpoolConfigBackendParam['backend_weight']['max']); - if(!$result) { + + // backend_weight + $result = checkFloat($weight, + $pgpoolConfigBackendParam['backend_weight']['min'], + $pgpoolConfigBackendParam['backend_weight']['max']); + if (!$result) { $error['backend_weight'][$i] = TRUE; } else { $error['backend_weight'][$i] = FALSE; } - // check backend_data_directory - $result = checkString ($data_directory, - $pgpoolConfigBackendParam['backend_data_directory']['regexp']); - if(!$result) { + // backend_data_directory + $result = checkString($data_directory, + $pgpoolConfigBackendParam['backend_data_directory']['regexp']); + if (!$result) { $error['backend_data_directory'][$i] = TRUE; } else { $error['backend_data_directory'][$i] = FALSE; - } - + } + } } - + $isError = FALSE; - foreach($error as $key => $value) { - if(preg_match("/^backend_hostname/", $key) - || preg_match("/^backend_port/", $key) - || preg_match("/^backend_weight/", $key) - || preg_match("/^backend_data_directory/", $key)) { - for($i=0; $i < count($value); $i++) { - if($value[$i] == TRUE) { + foreach ($error as $key => $value) { + if (preg_match("/^backend_hostname/", $key) || + preg_match("/^backend_port/", $key) || + preg_match("/^backend_weight/", $key) || + preg_match("/^backend_data_directory/", $key)) + { + for ($i = 0; $i < count($value); $i++) { + if ($value[$i] == TRUE) { $isError = TRUE; } } + } else { if ($value == TRUE) { $isError = TRUE; } } - if($isError) { - break; - } + + if ($isError) { break; } } - - if( !$isError) { - if(is_writable(_PGPOOL2_CONFIG_FILE)) { + + if (!$isError) { + if (is_writable(_PGPOOL2_CONFIG_FILE)) { writeConfigFile($configValue, $pgpoolConfigParam); $configValue = readConfigParams(); $tpl->assign('status', 'success'); @@ -239,27 +262,30 @@ switch( $action ) { $tpl->display('error.tpl'); exit(); } - } else { + + } else { $tpl->assign('status', 'fail'); } break; - + case 'delete': $num = $_POST['num']; - deleteBackendHost($num, $configValue); - if(is_writable(_PGPOOL2_CONFIG_FILE)) { - writeConfigFile($configValue, $pgpoolConfigParam); - $configValue = readConfigParams(); - } else { - $errorCode = 'e4003'; - $tpl->assign('errorCode', $errorCode); - $tpl->display('error.tpl'); - exit(); - } + deleteBackendHost($num, $configValue); + + if (is_writable(_PGPOOL2_CONFIG_FILE)) { + writeConfigFile($configValue, $pgpoolConfigParam); + $configValue = readConfigParams(); + + } else { + $errorCode = 'e4003'; + $tpl->assign('errorCode', $errorCode); + $tpl->display('error.tpl'); + exit(); + } break; - + case 'reset': default: } @@ -269,6 +295,10 @@ $tpl->assign('error', $error); $tpl->display('pgconfig.tpl'); +/* --------------------------------------------------------------------- */ +/* Functions */ +/* --------------------------------------------------------------------- */ + /** * check POST value * @@ -277,10 +307,11 @@ $tpl->display('pgconfig.tpl'); * @param array $configParam * @param string $error */ -function check($key, $value, &$configParam ,&$error) { +function check($key, $value, &$configParam ,&$error) +{ $type = $value['type']; - $result = false; - switch($type) { + $result = FALSE; + switch ($type) { case 'B': $result = checkBoolean($configParam[$key]); break; @@ -294,8 +325,8 @@ function check($key, $value, &$configParam ,&$error) { $result = checkInteger($configParam[$key], $value['min'], $value['max']); break; } - if(!$result) { - $error[$key] = true; + if (!$result) { + $error[$key] = TRUE; } } @@ -308,10 +339,10 @@ function check($key, $value, &$configParam ,&$error) { */ function checkString($str, $pattern) { - if(preg_match("/$pattern/", $str)) { - return true; + if (preg_match("/$pattern/", $str)) { + return TRUE; } else { - return false; + return FALSE; } } @@ -325,16 +356,17 @@ function checkString($str, $pattern) */ function checkInteger($str, $min, $max) { - if(is_numeric($str)) { + if (is_numeric($str)) { $minLen = strlen($min); $maxLen = strlen($max); - if($str < $min || $str > $max) { - return false; + + if ($str < $min || $str > $max) { + return FALSE; } else { - return true; + return TRUE; } } - return false; + return FALSE; } /** @@ -347,13 +379,13 @@ function checkInteger($str, $min, $max) */ function checkFloat($str, $min, $max) { - if(is_numeric($str)) { - if($str < $min || $str > $max) { - return false; + if (is_numeric($str)) { + if ($str < $min || $str > $max) { + return FALSE; } - return true; + return TRUE; } - return false; + return FALSE; } /** @@ -364,10 +396,10 @@ function checkFloat($str, $min, $max) */ function checkBoolean($str) { - if($str == 'true' || $str == 'false') { - return true; + if ($str == 'true' || $str == 'false') { + return TRUE; } else { - return false; + return FALSE; } } @@ -379,22 +411,25 @@ function checkBoolean($str) */ function writeConfigFile($configValue, $pgpoolConfigParam) { - $configFile = @file(_PGPOOL2_CONFIG_FILE); $removeBackendConfigFile = array(); - - for($i=0; $i < count($configFile); $i++) { + + for ($i = 0; $i < count($configFile); $i++) { $line = $configFile[$i]; - if(preg_match("/^\w/", $line)) { + + if (preg_match("/^\w/", $line)) { list($key, $value) = explode("=", $line); $key = trim($key); - if(!preg_match("/^backend_hostname/", $key) - && !preg_match("/^backend_port/", $key) - && !preg_match("/^backend_weight/", $key) - && !preg_match("/^backend_data_directory/", $key)) { + + if (!preg_match("/^backend_hostname/", $key) && + !preg_match("/^backend_port/", $key) && + !preg_match("/^backend_weight/", $key) && + !preg_match("/^backend_data_directory/", $key)) + { $removeBackendConfigFile[] = $line; } + } else { $removeBackendConfigFile[] = $line; } @@ -402,14 +437,14 @@ function writeConfigFile($configValue, $pgpoolConfigParam) $configFile = $removeBackendConfigFile; - foreach($pgpoolConfigParam as $key => $value) { + foreach ($pgpoolConfigParam as $key => $value) { $isWrite = FALSE; - for($j=0; $j<count($configFile); $j++) { + for ($j = 0; $j<count($configFile); $j++) { $line = $configFile[$j]; $line = trim($line); - if(preg_match("/^$key/", $line)) { - if( strcmp($pgpoolConfigParam[$key]['type'], "C") == 0) { + if (preg_match("/^$key/", $line)) { + if (strcmp($pgpoolConfigParam[$key]['type'], "C") == 0) { $configFile[$j] = $key . " = '" . $configValue[$key] . "'\n"; } else { $configFile[$j] = $key . " = " . $configValue[$key]."\n"; @@ -418,22 +453,25 @@ function writeConfigFile($configValue, $pgpoolConfigParam) break; } } - if(!$isWrite) { - if( strcmp($pgpoolConfigParam[$key]['type'], "C") == 0) { + + if (!$isWrite) { + if (strcmp($pgpoolConfigParam[$key]['type'], "C") == 0) { $configFile[] = $key . " = '" . $configValue[$key] . "'\n"; } else { $configFile[] = $key . " = " . $configValue[$key]."\n"; } } } - if(isset($configValue['backend_hostname'])) { - for($i=0; $i<count($configValue['backend_hostname']); $i++) { + + if (isset($configValue['backend_hostname'])) { + for ($i = 0; $i<count($configValue['backend_hostname']); $i++) { + $line = "backend_hostname$i = '" . $configValue['backend_hostname'][$i] . "'\n"; $configFile[] = $line; - + $line = "backend_port$i = " . $configValue['backend_port'][$i] . "\n"; $configFile[] = $line; - + $line = "backend_weight$i = " . $configValue['backend_weight'][$i] . "\n"; $configFile[] = $line; @@ -443,7 +481,7 @@ function writeConfigFile($configValue, $pgpoolConfigParam) } $outfp = fopen(_PGPOOL2_CONFIG_FILE, 'w'); - foreach($configFile as $line) { + foreach ($configFile as $line) { fputs($outfp, $line); } fclose($outfp); @@ -459,7 +497,7 @@ function deleteBackendHost($num, &$configValue) { unset($configValue['backend_hostname'][$num]); $configValue['backend_hostname'] = array_values($configValue['backend_hostname']); - + unset($configValue['backend_port'][$num]); $configValue['backend_port'] = array_values($configValue['backend_port']); @@ -468,7 +506,7 @@ function deleteBackendHost($num, &$configValue) unset($configValue['backend_data_directory'][$num]); $configValue['backend_data_directory'] = array_values($configValue['backend_data_directory']); - -} + +} ?> diff --git a/procInfo.php b/procInfo.php index b2e8e09..546860d 100644 --- a/procInfo.php +++ b/procInfo.php @@ -25,38 +25,40 @@ require_once('command.php'); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { exit(); } $ret = execPcp('PCP_PROC_COUNT'); -if(!array_key_exists('SUCCESS', $ret)) { +if (!array_key_exists('SUCCESS', $ret)) { $errorCode = 'e1004'; $tpl->assign('errorCode', $errorCode); $tpl->display('innerError.tpl'); exit(); + } else { - $procPids = explode(" ", $ret['SUCCESS']); + $procPids = explode(" ", $ret['SUCCESS']); } -for($i=0; $i<count($procPids); $i++) { +for ($i = 0; $i < count($procPids); $i++) { $procPid = $procPids[$i]; $ret = execPcp('PCP_PROC_INFO', $procPid); - if(!array_key_exists('SUCCESS', $ret)) { + + if (!array_key_exists('SUCCESS', $ret)) { $errorCode = 'e1005'; $tpl->assign('errorCode', $errorCode); $tpl->display('innerError.tpl'); exit(); - } else { + } else { $ret = $ret['SUCCESS']; - - if(count($ret) > 0) { - foreach($ret as $line) { + + if (count($ret) > 0) { + foreach ($ret as $line) { $data = split(" ", $line); -/* +/* $dateFormat = $message['strDateFormat']; - $data[2] = date($dateFormat, $data[2]); + $data[2] = date($dateFormat, $data[2]); $data[3] = date($dateFormat, $data[3]); */ $procInfo[$procPid][] = $data; diff --git a/queryCache.php b/queryCache.php index 5c82f18..6bc14d7 100644 --- a/queryCache.php +++ b/queryCache.php @@ -26,26 +26,26 @@ require_once('common.php'); $tpl->assign('help', basename( __FILE__, '.php')); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { header('Location: login.php'); exit(); } readConfigParams(); -if(isset($_GET['action'])) { +if (isset($_GET['action'])) { $action=$_GET['action']; } else { $action = ''; } -if(isset($_GET['col'])) { +if (isset($_GET['col'])) { $col = $_GET{'col'}; } else { $col = ''; } -if(isset($_GET['sort'])) { +if (isset($_GET['sort'])) { $sort = $_GET{'sort'}; } else { $sort = ''; @@ -55,37 +55,38 @@ $tpl->assign('col', $col); $tpl->assign('sort', $sort); $sysDbParam = readConfigParams(array('system_db_hostname', - 'system_db_port', - 'system_db_dbname', - 'system_db_schema', - 'system_db_user', - 'system_db_password')); + 'system_db_port', + 'system_db_dbname', + 'system_db_schema', + 'system_db_user', + 'system_db_password')); $sysDbParam['hostname'] = $sysDbParam['system_db_hostname']; -$sysDbParam['port'] = $sysDbParam['system_db_port']; -$sysDbParam['dbname'] = $sysDbParam['system_db_dbname']; -$sysDbParam['user'] = $sysDbParam['system_db_user']; +$sysDbParam['port'] = $sysDbParam['system_db_port']; +$sysDbParam['dbname'] = $sysDbParam['system_db_dbname']; +$sysDbParam['user'] = $sysDbParam['system_db_user']; $sysDbParam['password'] = $sysDbParam['system_db_password']; $sysDbSchema = $sysDbParam['system_db_schema']; $conn = openDBConnection($sysDbParam); -if($conn == false) { +if ($conn == FALSE) { $errorCode = 'e2001'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); } -if($action == 'delete') { - if(isset($_POST['hash'])) { +if ($action == 'delete') { + if (isset($_POST['hash'])) { $hashArray = $_POST['hash']; } else { $hashArray = FALSE; } - if($hashArray != FALSE) { + + if ($hashArray != FALSE) { $sql = "DELETE FROM $sysDbSchema.query_cache WHERE "; - for($i=0; $i<count($hashArray)-1; $i++) { + for ($i = 0; $i<count($hashArray)-1; $i++) { $escaped = pg_escape_string($hashArray[$i]); $sql .= "hash = '$escaped' OR "; } @@ -96,70 +97,72 @@ if($action == 'delete') { } } -if($action == 'search') { - $query = $_POST['qQueryStr']; +if ($action == 'search') { + $query = $_POST['qQueryStr']; $dbname = $_POST['qDb']; + $_SESSION['qQueryStr'] = $query; $_SESSION['qDb'] = $dbname; } if(isset($_SESSION['qQueryStr'])) { $query = $_SESSION['qQueryStr']; -} else { +} else { $query = ''; } -if(isset($_SESSION['qDb'])) { +if (isset($_SESSION['qDb'])) { $dbname = $_SESSION['qDb']; } else { $dbname = ''; } -if($action == 'clear') { +if ($action == 'clear') { session_unregister('qQueryStr'); session_unregister('qDb'); - + $query = ''; $dbname = ''; } $sql = "SELECT hash, query, dbname, create_time FROM $sysDbSchema.query_cache "; -$first = true; -if($query != null) { - if($first) { +$first = TRUE; +if ($query != NULL) { + if ($first) { $sql = $sql . " WHERE "; - $first = false; - } - else { + $first = FALSE; + + } else { $sql = $sql . " AND "; } - + $sql = $sql . "query like '%" . pg_escape_string($query) . "%' "; } -if($dbname != null) { - if($first) { +if ($dbname != NULL) { + if ($first) { $sql = $sql . " WHERE "; - $first = false; - } - else { + $first = FALSE; + + } else { $sql = $sql . " AND "; } - + $sql = $sql . "dbname like '%" . pg_escape_string($dbname). "%' "; } -if($col == null) { +if ($col == NULL) { $col = 'query'; } $sql = $sql . " ORDER BY " . pg_escape_string($col); -if($sort == "descending") +if ($sort == "descending") { $sql = $sql . " DESC"; - +} + $rs = execQuery($conn, $sql); -if($rs == false) { +if ($rs == FALSE) { $errorCode = 'e2002'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); @@ -171,11 +174,11 @@ $result = pg_fetch_all($rs); closeDBConnection($conn); -if($result) { - $dateFormat = $message['strDateFormat']; - for($i=0; $i<count($result); $i++) { - $result[$i]['create_time'] = date($dateFormat, strtotime($result[$i]['create_time'])); - } +if ($result) { + $dateFormat = $message['strDateFormat']; + for ($i = 0; $i < count($result); $i++) { + $result[$i]['create_time'] = date($dateFormat, strtotime($result[$i]['create_time'])); + } $tpl->assign('queryCache', $result); } @@ -29,19 +29,19 @@ $tpl->assign('help', basename( __FILE__, '.php')); $viewPHP = 'nodeStatus.php'; $refreshTime = 5000; -if(isset($_POST['nodeNumber'])) { +if (isset($_POST['nodeNumber'])) { $nodeNumber = $_POST['nodeNumber']; } else { $nodeNumber = -1; } -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { header('Location: login.php'); exit(); } -if(isset($_POST['action'])) { +if (isset($_POST['action'])) { $action = $_POST['action']; } else { $action = FALSE; @@ -56,75 +56,82 @@ $tpl->assign('D', _PGPOOL2_CMD_OPTION_LARGE_D); $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); + +if (isPipe(_PGPOOL2_LOG_FILE)) { + $tpl->assign('pipe', 1); +} else { + $tpl->assign('pipe', 0); +} switch ($action) { case 'start': $args = ' '; - if(isset($_POST['c'])) { + if (isset($_POST['c'])) { $args = $args . "-c "; } - if(isset($_POST['D'])) { + if (isset($_POST['D'])) { $args = $args . "-D "; } - if(isset($_POST['d'])) { + if (isset($_POST['d'])) { $args = $args . "-d "; } - if(isset($_POST['n'])) { + if (isset($_POST['n'])) { $pgpoolLog = _PGPOOL2_LOG_FILE; - if($pgpoolLog == '') { + if ($pgpoolLog == '') { $logDir = readLogDir(); $pgpoolLog = "$logDir/pgpool.log"; } - if(isPipe($pgpoolLog)) - $args = "$args -n 2>&1 $pgpoolLog "; - else - $args = "$args -n > $pgpoolLog "; + if (isPipe($pgpoolLog)) { + $args = "$args -n 2>&1 $pgpoolLog "; + } else { + $args = "$args -n > $pgpoolLog "; + } } + $ret = execPcp('PCP_START_PGPOOL', $args); - if(!array_key_exists('SUCCESS', $ret)) { + if (!array_key_exists('SUCCESS', $ret)) { $tpl->assign('pgpoolStatus', 'pgpool start failed.'); $tpl->assign('pgpoolMessage', $ret); } else { - for($i=0; $i<10; $i++) { + for ($i = 0; $i < 10; $i++) { if(DoesPgpoolPidExist()) { break; } else { sleep(1); } } - if(DoesPgpoolPidExist()) { + + if (DoesPgpoolPidExist()) { $tpl->assign('pgpoolStatus', 'pgpool start succeed'); } else { $tpl->assign('pgpoolStatus', 'pgpool start failed. pgpool.pid not found'); } $tpl->assign('pgpoolMessage', $ret['SUCCESS']); } - + break; case 'stop': $m = $_POST['stop_mode']; $ret = execPcp('PCP_STOP_PGPOOL', $m); - if(!array_key_exists('SUCCESS', $ret)) { + if (!array_key_exists('SUCCESS', $ret)) { $errorCode = 'e1006'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); + } else { - for($i=0; $i<10; $i++) { - if(DoesPgpoolPidExist()) { + for ($i = 0; $i < 10; $i++) { + if (DoesPgpoolPidExist()) { sleep(1); } else { break; } } - if(DoesPgpoolPidExist()) { + + if (DoesPgpoolPidExist()) { $tpl->assign('pgpoolStatus', 'pgpool stop failed. pgpool.pid exists.'); } else { $tpl->assign('pgpoolStatus', 'pgpool stop succeed'); @@ -140,65 +147,69 @@ switch ($action) { $m = $_POST['restart_mode']; $ret = execPcp('PCP_STOP_PGPOOL', $m); - if(!array_key_exists('SUCCESS', $ret)) { + if (!array_key_exists('SUCCESS', $ret)) { $errorCode = 'e1006'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); + } else { - for($i=0; $i<10; $i++) { - if(DoesPgpoolPidExist()) { + for($i = 0; $i < 10; $i++) { + if (DoesPgpoolPidExist()) { sleep(1); } else { break; } } } - - if(DoesPgpoolPidExist() ) { - $tpl->assign('pgpoolStatus', 'pgpool restart failed. pgpool.pid exists.'); - break; + + if (DoesPgpoolPidExist()) { + $tpl->assign('pgpoolStatus', 'pgpool restart failed. pgpool.pid exists.'); + break; } - + /** * Start pgpool */ $args = ' '; - if(isset($_POST['c'])) { + if (isset($_POST['c'])) { $args = $args . "-c "; } - if(isset($_POST['D'])) { + if (isset($_POST['D'])) { $args = $args . "-D "; } - if(isset($_POST['d'])) { + if (isset($_POST['d'])) { $args = $args . "-d "; } - if(isset($_POST['n'])) { + if (isset($_POST['n'])) { $pgpoolLog = _PGPOOL2_LOG_FILE; - if($pgpoolLog == '') { + if ($pgpoolLog == '') { $logDir = readLogDir(); $pgpoolLog = "$logDir/pgpool.log"; } - if(isPipe($pgpoolLog)) - $args = "$args -n 2>&1 $pgpoolLog "; - else - $args = "$args -n > $pgpoolLog "; - } + if (isPipe($pgpoolLog)) { + $args = "$args -n 2>&1 $pgpoolLog "; + } else { + $args = "$args -n > $pgpoolLog "; + } + } + $ret = execPcp('PCP_START_PGPOOL', $args); - if(!array_key_exists('SUCCESS', $ret)) { + if (!array_key_exists('SUCCESS', $ret)) { $tpl->assign('pgpoolStatus', 'pgpool restart failed.'); $tpl->assign('pgpoolMessage', $ret); + } else { - for($i=0; $i<10; $i++) { - if(DoesPgpoolPidExist()) { + for ($i = 0; $i < 10; $i++) { + if (DoesPgpoolPidExist()) { $tpl->assign('pgpoolStatus', 'pgpool restart succeed'); break; } else { sleep(1); } } - if(!DoesPgpoolPidExist()) { + if (!DoesPgpoolPidExist()) { $tpl->assign('pgpoolStatus', 'pgpool restart failed. pgpool.pid not found'); } $tpl->assign('pgpoolMessage', $ret['SUCCESS']); @@ -216,7 +227,7 @@ switch ($action) { case 'return': $ret = execPcp('PCP_ATTACH_NODE', $nodeNumber); - if(!array_key_exists('SUCCESS', $ret)) { + if (!array_key_exists('SUCCESS', $ret)) { $errorCode = 'e1010'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); @@ -225,8 +236,8 @@ switch ($action) { break; case 'recovery': - $ret = execPcp('PCP_RECOVERY_NODE', $nodeNumber); - if(!array_key_exists('SUCCESS', $ret)) { + $ret = execPcp('PCP_RECOVERY_NODE', $nodeNumber); + if (!array_key_exists('SUCCESS', $ret)) { $errorCode = 'e1012'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); @@ -237,43 +248,46 @@ switch ($action) { case 'detach': $ret = execPcp('PCP_DETACH_NODE', $nodeNumber); - if(!array_key_exists('SUCCESS', $ret)) { + if (!array_key_exists('SUCCESS', $ret)) { $errorCode = 'e1007'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); } break; - + case 'summary': $viewPHP = 'innerSummary.php'; break; + case 'proc': $viewPHP = 'procInfo.php'; break; + case 'node': $viewPHP = 'nodeStatus.php'; break; + case 'log': $viewPHP = 'innerLog.php'; break; } -if(DoesPgpoolPidExist()) { - $tpl->assign('pgpoolIsActive', true); +if (DoesPgpoolPidExist()) { + $tpl->assign('pgpoolIsActive', TRUE); } else { - $tpl->assign('pgpoolIsActive', false); + $tpl->assign('pgpoolIsActive', FALSE); } $tpl->assign('viewPHP', $viewPHP); -if( _PGPOOL2_STATUS_REFRESH_TIME >= 0 ) { +if (_PGPOOL2_STATUS_REFRESH_TIME >= 0 ) { $refreshTime = _PGPOOL2_STATUS_REFRESH_TIME * 1000; } -$tpl->assign('pgpoolConf', _PGPOOL2_CONFIG_FILE); -$tpl->assign('pcpConf', _PGPOOL2_PASSWORD_FILE); -$tpl->assign('refreshTime', $refreshTime); +$tpl->assign('pgpoolConf', _PGPOOL2_CONFIG_FILE); +$tpl->assign('pcpConf', _PGPOOL2_PASSWORD_FILE); +$tpl->assign('refreshTime', $refreshTime); $tpl->assign('msgStopPgpool', $message['msgStopPgpool']); $tpl->display('status.tpl'); diff --git a/systemDb.php b/systemDb.php index a3dfdf4..90d015b 100644 --- a/systemDb.php +++ b/systemDb.php @@ -26,32 +26,33 @@ require_once('common.php'); $tpl->assign('help', basename( __FILE__, '.php')); -if(!isset($_SESSION[SESSION_LOGIN_USER])) { +if (!isset($_SESSION[SESSION_LOGIN_USER])) { header('Location: login.php'); exit(); } -if( ! file_exists(_PGPOOL2_CONFIG_FILE)) { +if (!file_exists(_PGPOOL2_CONFIG_FILE)) { $errorCode = 'e3006'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); } + $sysDbParam = readConfigParams(array('system_db_hostname', - 'system_db_port', - 'system_db_dbname', - 'system_db_schema', - 'system_db_user', - 'system_db_password')); + 'system_db_port', + 'system_db_dbname', + 'system_db_schema', + 'system_db_user', + 'system_db_password')); $sysDbParam['hostname'] = $sysDbParam['system_db_hostname']; -$sysDbParam['port'] = $sysDbParam['system_db_port']; -$sysDbParam['dbname'] = $sysDbParam['system_db_dbname']; -$sysDbParam['user'] = $sysDbParam['system_db_user']; +$sysDbParam['port'] = $sysDbParam['system_db_port']; +$sysDbParam['dbname'] = $sysDbParam['system_db_dbname']; +$sysDbParam['user'] = $sysDbParam['system_db_user']; $sysDbParam['password'] = $sysDbParam['system_db_password']; $conn = openDBConnection($sysDbParam); -if($conn == false) { +if ($conn == FALSE) { $errorCode = 'e3001'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); @@ -60,58 +61,60 @@ if($conn == false) { $sysDbSchema = $sysDbParam['system_db_schema']; -if(isset($_GET['dbname'])) { +if (isset($_GET['dbname'])) { $dbname = pg_escape_string($_GET['dbname']); } else { $dbname = ''; } -if(isset($_GET['schema_name'])) { +if (isset($_GET['schema_name'])) { $schema_name = pg_escape_string($_GET['schema_name']); } else { $schema_name = ''; } -if(isset($_GET['table_name'])) { +if (isset($_GET['table_name'])) { $table_name = pg_escape_string($_GET['table_name']); } else { $table_name = ''; } -$result = null; +$result = NULL; + +if ($dbname && $schema_name && $table_name) { + $sql = "SELECT * FROM $sysDbSchema.dist_def ". + "WHERE dbname='$dbname' AND schema_name='$schema_name' AND table_name = '$table_name'"; -if($dbname && $schema_name && $table_name) { - $sql = "SELECT * FROM $sysDbSchema.dist_def WHERE dbname='$dbname' AND schema_name='$schema_name' AND table_name = '$table_name'"; $rs = execQuery($conn, $sql); - if($rs == false) { + if ($rs == FALSE) { $errorCode = 'e3002'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); - } + } - if(pg_num_rows($rs) > 0) { + if (pg_num_rows($rs) > 0) { $result = pg_fetch_array($rs, 0); - - $col_lists = var_sql2php($result['col_list']); + + $col_lists = var_sql2php($result['col_list']); $type_lists = var_sql2php($result['type_list']); - - $col_list = "'" . $col_lists[0] . "'"; - $type_list = "'" . $type_lists[0] . "'"; - - for($i=1; $i<count($col_lists); $i++) { - $col_list = $col_list . ", '" . $col_lists[$i] . "'"; - $type_list = $type_list . ", '" . $type_lists[$i] . "'"; + + $col_list = "'{$col_lists[0]}'"; + $type_list = "'{$type_lists[0]}'"; + + for ($i = 1; $i < count($col_lists); $i++) { + $col_list = "{$col_list}, '{$col_lists[$i]}'"; + $type_list = "{$type_list}, '{$type_lists[$i]}'"; } - - $result['col_list'] = $col_list; + + $result['col_list'] = $col_list; $result['type_list'] = $type_list; - - $tpl->assign('isUpdate', true); + + $tpl->assign('isUpdate', TRUE); } } $tpl->assign('result', $result); -if(isset($_POST['action'])) { +if (isset($_POST['action'])) { $action = $_POST['action']; } else { $action = FALSE; @@ -119,256 +122,273 @@ if(isset($_POST['action'])) { $error = FALSE; -switch( $action ) { - +switch ($action) { + case 'add': - $dbname = $_POST['dbname']; - $schema_name = $_POST['schema_name']; - $table_name = $_POST['table_name']; - $col_name = $_POST['col_name']; - $col_list = $_POST['col_list']; - $type_list = $_POST['type_list']; + $dbname = $_POST['dbname']; + $schema_name = $_POST['schema_name']; + $table_name = $_POST['table_name']; + $col_name = $_POST['col_name']; + $col_list = $_POST['col_list']; + $type_list = $_POST['type_list']; $dist_def_func = $_POST['dist_def_func']; - - $col_list = str_replace('\\', '', $col_list); + + $col_list = str_replace('\\', '', $col_list); $type_list = str_replace('\\', '', $type_list); - - $col_lists = explode_csv($col_list, FALSE, ',', '\'', array()); + + $col_lists = explode_csv($col_list, FALSE, ',', '\'', array()); $type_lists = explode_csv($type_list, FALSE, ',', '\'', array()); - - if($dbname == '' - || $schema_name == '' - || $table_name == '' - || $col_name == '' - || $col_list == '' - || $type_list == '' - || $dist_def_func == '') { - $tpl->assign('error', $message['errInputEverything']); - $error = TRUE; - break; + + if ($dbname == '' || + $schema_name == '' || + $table_name == '' || + $col_name == '' || + $col_list == '' || + $type_list == '' || + $dist_def_func == '') + { + $tpl->assign('error', $message['errInputEverything']); + $error = TRUE; + break; } - - if(count($col_lists) != count($type_lists)) { + + if (count($col_lists) != count($type_lists)) { $tpl->assign('error', $message['errNotSameLength']); $error = TRUE; break; } - - for($i=0; $i<count($col_lists); $i++) { - if(trim($col_lists[$i]) == '' || trim($type_lists[$i]) == '') { + + for ($i = 0; $i < count($col_lists); $i++) { + if (trim($col_lists[$i]) == '' || trim($type_lists[$i]) == '') { $tpl->assign('error', $message['errNotSameLength']); $error = TRUE; break 2; } } - - for($i=0; $i<count($col_lists); $i++) { - $col_lists[$i] = pg_escape_string(trim($col_lists[$i])); + + for ($i = 0; $i < count($col_lists); $i++) { + $col_lists[$i] = pg_escape_string(trim($col_lists[$i])); $type_lists[$i] = pg_escape_string(trim($type_lists[$i])); } - - $col_list = array2sql($col_lists); + + $col_list = array2sql($col_lists); $type_list = array2sql($type_lists); - - $dbname = pg_escape_string($dbname); - $schema_name = pg_escape_string($schema_name); - $table_name = pg_escape_string($table_name); - $col_name = pg_escape_string($col_name); + + $dbname = pg_escape_string($dbname); + $schema_name = pg_escape_string($schema_name); + $table_name = pg_escape_string($table_name); + $col_name = pg_escape_string($col_name); $dist_def_func = pg_escape_string($dist_def_func); - $sql = "SELECT count(*) FROM $sysDbSchema.dist_def WHERE dbname='$dbname' AND schema_name='$schema_name' AND table_name = '$table_name'"; - + $sql = "SELECT count(*) FROM $sysDbSchema.dist_def ". + "WHERE dbname='$dbname' AND schema_name='$schema_name' AND table_name = '$table_name'"; + $rs = execQuery($conn, $sql); - if($rs == false) { + if ($rs == FALSE) { $errorCode = 'e3003'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); - } + } $count = pg_fetch_row($rs, 0); - - if($count[0] > 0) { + + if ($count[0] > 0) { $tpl->assign('error', $message['errAlreadyExist']); $error = TRUE; break; } - - $sql = "INSERT INTO $sysDbSchema.dist_def VALUES('$dbname', '$schema_name', '$table_name', '$col_name', ARRAY[$col_list], ARRAY[$type_list], '$dist_def_func')"; - + + $sql = "INSERT INTO $sysDbSchema.dist_def VALUES ". + "('$dbname', '$schema_name', '$table_name', '$col_name', ". + "ARRAY[$col_list], ARRAY[$type_list], '$dist_def_func')"; + $rs = execQuery($conn, $sql); - if($rs == false) { + if ($rs == FALSE) { $errorCode = 'e3003'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); - } + } + break; - + case 'update': - $tpl->assign('isUpdate', true); - - $dbname = $_POST['dbname']; - $schema_name = $_POST['schema_name']; - $table_name = $_POST['table_name']; - $col_name = $_POST['col_name']; - $col_list = $_POST['col_list']; - $type_list = $_POST['type_list']; + $tpl->assign('isUpdate', TRUE); + + $dbname = $_POST['dbname']; + $schema_name = $_POST['schema_name']; + $table_name = $_POST['table_name']; + $col_name = $_POST['col_name']; + $col_list = $_POST['col_list']; + $type_list = $_POST['type_list']; $dist_def_func = $_POST['dist_def_func']; - - $col_list = str_replace('\\', '', $col_list); + + $col_list = str_replace('\\', '', $col_list); $type_list = str_replace('\\', '', $type_list); - - $col_lists = explode_csv($col_list, FALSE, ',', '\'', array()); + + $col_lists = explode_csv($col_list, FALSE, ',', '\'', array()); $type_lists = explode_csv($type_list, FALSE, ',', '\'', array()); - - if($dbname == '' - || $schema_name == '' - || $table_name == '' - || $col_name == '' - || $col_list == '' - || $type_list == '' - || $dist_def_func == '') { - $tpl->assign('error', $message['errInputEverything']); - $error = TRUE; - break; + + if ($dbname == '' || + $schema_name == '' || + $table_name == '' || + $col_name == '' || + $col_list == '' || + $type_list == '' || + $dist_def_func == '') + { + $tpl->assign('error', $message['errInputEverything']); + $error = TRUE; + break; } - - if(count($col_lists) != count($type_lists)) { + + if (count($col_lists) != count($type_lists)) { $tpl->assign('error', $message['errNotSameLength']); $error = TRUE; break; } - - $err = false; - - for($i=0; $i<count($col_lists); $i++) { - if(trim($col_lists[$i]) == '' || trim($type_lists[$i]) == '') { + + $err = FALSE; + + for ($i = 0; $i < count($col_lists); $i++) { + if (trim($col_lists[$i]) == '' || trim($type_lists[$i]) == '') { $tpl->assign('error', $message['errNotSameLength']); $error = TRUE; break 2; } } - - for($i=0; $i<count($col_lists); $i++) { - $col_lists[$i] = pg_escape_string(trim($col_lists[$i])); + + for ($i = 0; $i<count($col_lists); $i++) { + $col_lists[$i] = pg_escape_string(trim($col_lists[$i])); $type_lists[$i] = pg_escape_string(trim($type_lists[$i])); } - - $col_list = array2sql($col_lists); + + $col_list = array2sql($col_lists); $type_list = array2sql($type_lists); - - $dbname = pg_escape_string($dbname); - $schema_name = pg_escape_string($schema_name); - $table_name = pg_escape_string($table_name); - $col_name = pg_escape_string($col_name); + + $dbname = pg_escape_string($dbname); + $schema_name = pg_escape_string($schema_name); + $table_name = pg_escape_string($table_name); + $col_name = pg_escape_string($col_name); $dist_def_func = pg_escape_string($dist_def_func); - if($dbname && $schema_name && $table_name) { - $sql = "UPDATE $sysDbSchema.dist_def set " - . "dbname = '$dbname', " - . "schema_name = '$schema_name', " - . "table_name = '$table_name', " - . "col_name = '$col_name', " - . "col_list = ARRAY[$col_list], " - . "type_list = ARRAY[$type_list], " - . "dist_def_func = '$dist_def_func' " - . "WHERE dbname='$dbname' AND schema_name='$schema_name' AND table_name = '$table_name'"; - + if ($dbname && $schema_name && $table_name) { + $sql = "UPDATE $sysDbSchema.dist_def SET ". + "dbname = '$dbname', ". + "schema_name = '$schema_name', ". + "table_name = '$table_name', ". + "col_name = '$col_name', ". + "col_list = ARRAY[$col_list], ". + "type_list = ARRAY[$type_list], ". + "dist_def_func = '$dist_def_func' ". + "WHERE dbname='$dbname' AND schema_name='$schema_name' AND table_name = '$table_name'"; + $rs = execQuery($conn, $sql); - if($rs == false) { + if ($rs == FALSE) { $errorCode = 'e3004'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); - } - $tpl->assign('isUpdate', false); + } + $tpl->assign('isUpdate', FALSE); break; } + case 'delete': - $dbname = pg_escape_string($_POST['dbname']); + $dbname = pg_escape_string($_POST['dbname']); $schema_name = pg_escape_string($_POST['schema_name']); - $table_name = pg_escape_string($_POST['table_name']); - - if($dbname && $schema_name && $table_name) { - $sql = "DELETE FROM $sysDbSchema.dist_def WHERE " - . "dbname = '$dbname' AND " - . "schema_name = '$schema_name' AND " - . "table_name = '$table_name'"; - + $table_name = pg_escape_string($_POST['table_name']); + + if ($dbname && $schema_name && $table_name) { + $sql = "DELETE FROM $sysDbSchema.dist_def WHERE ". + "dbname = '$dbname' AND ". + "schema_name = '$schema_name' AND ". + "table_name = '$table_name'"; + $rs = execQuery($conn, $sql); - if($rs == false) { + if ($rs == FALSE) { $errorCode = 'e3005'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); - } + } break; } - case 'cancel': - default: + + case 'cancel': + default: } -if($error == TRUE) { - $result['dbname'] = $dbname; - $result['schema_name'] = $schema_name; - $result['table_name'] = $table_name; - $result['col_name'] = $col_name; - $result['col_list'] = $col_list; - $result['type_list'] = $type_list; +if ($error == TRUE) { + $result['dbname'] = $dbname; + $result['schema_name'] = $schema_name; + $result['table_name'] = $table_name; + $result['col_name'] = $col_name; + $result['col_list'] = $col_list; + $result['type_list'] = $type_list; $result['dist_def_func'] = $dist_def_func; - $tpl->assign('result', $result); + + $tpl->assign('result', $result); } $sql = "SELECT * FROM $sysDbSchema.dist_def ORDER BY dbname"; $rs = execQuery($conn, $sql); -if($rs == false) { +if ($rs == FALSE) { $errorCode = 'e3002'; $tpl->assign('errorCode', $errorCode); $tpl->display('error.tpl'); exit(); -} +} $result = pg_fetch_all($rs); closeDBConnection($conn); -if($result) { +if ($result) { $arrayResult = array(); foreach($result as $rc) { - $rc['col_list'] = var_sql2php($rc['col_list']); - $rc['type_list'] = var_sql2php($rc['type_list']); + $rc['col_list'] = var_sql2php($rc['col_list']); + $rc['type_list'] = var_sql2php($rc['type_list']); $rc['listLength'] = count($rc['col_list']); array_push($arrayResult, $rc); } - + $tpl->assign('systemDb', $arrayResult); } $tpl->display('systemDb.tpl'); -function explode_csv($STR,$SQL = FALSE,$DELIMITER = ',',$ENCLOSURE = '"',$BRACKETS = array('{','}')) { - $column = 0; +/* --------------------------------------------------------------------- */ +/* Functions */ +/* --------------------------------------------------------------------- */ + +function explode_csv($STR, $SQL = FALSE, $DELIMITER = ',', $ENCLOSURE = '"', $BRACKETS = array('{','}')) +{ + $column = 0; $enclose = FALSE; - $escape = FALSE; - $braket = 0; + $escape = FALSE; + $braket = 0; settype($ROW[$column],'string'); - for($i = 0; $i < mb_strlen($STR); $i++) { + + for ($i = 0; $i < mb_strlen($STR); $i++) { $C = mb_substr($STR,$i,1); - if(isset($BRACKETS[0])) { + + if (isset($BRACKETS[0])) { $brakets0 = $BRACKETS[0]; } else { - $brakets0 = null; + $brakets0 = NULL; } - if(isset($BRACKETS[1])) { + + if (isset($BRACKETS[1])) { $brakets1 = $BRACKETS[1]; } else { - $brakets1 = null; + $brakets1 = NULL; } - - switch($C) { + + switch ($C) { case $DELIMITER: if($enclose || $braket > 0) { $ROW[$column] .= $C; @@ -378,12 +398,12 @@ function explode_csv($STR,$SQL = FALSE,$DELIMITER = ',',$ENCLOSURE = '"',$BRACKE } $escape = FALSE; break; - + case $ENCLOSURE: - if($escape || $braket) { + if ($escape || $braket) { $ROW[$column] .= $C; } else { - if($enclose) { + if ($enclose) { $enclose = FALSE; } else { $enclose = TRUE; @@ -391,53 +411,56 @@ function explode_csv($STR,$SQL = FALSE,$DELIMITER = ',',$ENCLOSURE = '"',$BRACKE } $escape = FALSE; break; - + case '\\': $ROW[$column] .= $C; $escape = TRUE; break; - + case $brakets0: $ROW[$column] .= $C; - if($SQL && !$escape) { + if ($SQL && !$escape) { $braket++; } $escape = FALSE; break; - + case $brakets1: $ROW[$column] .= $C; - if($SQL && !$escape) { + if ($SQL && !$escape) { $braket--; } $escape = FALSE; break; - + default: $ROW[$column] .= $C; $escape = FALSE; } } + return($ROW); } -function var_sql2php($VAL) { - if(mb_ereg('^\{(.*)\}$',$VAL,$match) !== FALSE) { - $VAL = array_map('var_sql2php',explode_csv($match[1],TRUE)); +function var_sql2php($VAL) +{ + if (mb_ereg('^\{(.*)\}$',$VAL,$match) !== FALSE) { + $VAL = array_map('var_sql2php', explode_csv($match[1],TRUE)); } return($VAL); } -function array2sql($var) { - if(!is_array($var)) { +function array2sql($var) +{ + if (!is_array($var)) { return ''; } - + $str = ''; - $str = "'" . $var[0] . "'"; - - for($i=1; $i<count($var); $i++) { - $str = $str . ", '" . $var[$i] . "'"; + $str = "'{$var[0] }'"; + + for ($i = 1; $i < count($var); $i++) { + $str = "{$str} , '{$var[$i]}'"; } return $str; } diff --git a/templates/config.tpl b/templates/config.tpl index 9fee43d..dd731b9 100644 --- a/templates/config.tpl +++ b/templates/config.tpl @@ -26,7 +26,7 @@ <td>{$message.msgUpdateFailed|escape}</td> </tr> </table> - {/if} + {/if} <h2>{$message.strSetting|escape}</h2> <form action="config.php" method="post" id="Config"> <input type="hidden" name="action" value="update" /> @@ -131,19 +131,19 @@ <option value="s" selected="selected">smart</option> <option value="f">fast</option> <option value="i">immediate</option> - {elseif $params.m == 'f'} + {elseif $params.m == 'f'} <option value="s">smart</option> <option value="f" selected="selected">fast</option> <option value="i">immediate</option> - {elseif $params.m == 'i'} + {elseif $params.m == 'i'} <option value="s">smart</option> <option value="f">fast</option> <option value="i" selected="selected">immediate</option> - {else} + {else} <option value="s">smart</option> <option value="f">fast</option> <option value="i">immediate</option> - {/if} + {/if} </td></tr> <tr> {if $errors.pgpool_logfile != null}<th class="error">{else}<th>{/if} diff --git a/templates/error.tpl b/templates/error.tpl index 50f7343..05a24a9 100644 --- a/templates/error.tpl +++ b/templates/error.tpl @@ -25,9 +25,7 @@ <td>{$message.$errorCode|escape}</td> </tr> </td> - </tr> - </table> </div> <div id="footer"> diff --git a/templates/login.tpl b/templates/login.tpl index e8199ec..b899ced 100644 --- a/templates/login.tpl +++ b/templates/login.tpl @@ -19,9 +19,9 @@ <form action="login.php" method="post" name="Login"> <table> <tfoot> - <tr><td colspan="2"> + <tr><td colspan="2"> <input type="submit" name="Button" value="{$message.strLogin|escape}" /> - </td></tr> + </td></tr> </tfoot> <tbody> <tr> diff --git a/templates/menu.tpl b/templates/menu.tpl index 63b1b4a..52490f1 100644 --- a/templates/menu.tpl +++ b/templates/menu.tpl @@ -13,4 +13,3 @@ <li><a href="help.php?help=errorCode">{$message.strErrorCode|escape}</a></li> {/if} </ul> -
\ No newline at end of file diff --git a/templates/nodeServerStatus.tpl b/templates/nodeServerStatus.tpl index 8c7a259..49ff4bf 100644 --- a/templates/nodeServerStatus.tpl +++ b/templates/nodeServerStatus.tpl @@ -8,7 +8,7 @@ <!-- {literal} function load() { - var xmlhttp = false; + var xmlhttp = false; if (typeof XMLHttpRequest!='undefined') xmlhttp = new XMLHttpRequest(); @@ -35,7 +35,7 @@ function load() { function showDetail(num) { var catalog = "pg_settings"; - var xmlhttp = false; + var xmlhttp = false; var url = ""; if (typeof XMLHttpRequest!='undefined') @@ -66,21 +66,26 @@ function showDetail(num) { </script> {/literal} </head> + <body onload="load()"> <div id="header"> <h1><img src="images/logo.gif" alt="pgpoolAdmin" /></h1> </div> + <div id="menu"> {include file="menu.tpl"} </div> + <div id="content"> <div id="help"><a href="help.php?help={$help|escape}"><img src="images/question.gif" alt="help"/>{$message.strHelp|escape}</a></div> + <h2>{$message.strNodeStatus|escape}</h2> <div id="status">{$message.strPleaseWait|escape}</div> <p> <div id="detailInfo"></div> -</p> +</p> </div> + <div id="footer"> {include file='footer.tpl'} </div> diff --git a/templates/nodeStatus.tpl b/templates/nodeStatus.tpl index da07cbc..00be20a 100644 --- a/templates/nodeStatus.tpl +++ b/templates/nodeStatus.tpl @@ -5,8 +5,10 @@ <title>{$message.strNodeInfo|escape}</title> <link href="screen.css" rel="stylesheet" type="text/css" /> </head> + <body> <h3>{$message.strNodeInfo|escape}</h3> + {if $nodeCount > 0} <table> <thead> @@ -20,6 +22,7 @@ <th></th> </tr> </thead> + {section name=num loop=$nodeInfo} {if ($smarty.section.num.index+1) % 2 == 0} <tr class="even"> @@ -28,6 +31,7 @@ {/if} <td>{$nodeInfo[num][0]|escape}</td> <td>{$nodeInfo[num][1]|escape}</td> + <td> {if $nodeInfo[num][2] == 1} {$message.strNodeStatus1|escape} @@ -36,29 +40,40 @@ {elseif $nodeInfo[num][2] == 3} {$message.strNodeStatus3|escape} {/if} - {if $nodeInfo[num][5] == 1} + {if $nodeInfo[num][5] == 1} {$message.strStandbyRunning|escape} {elseif $nodeInfo[num][5] == 0} {$message.strPrimaryRunning|escape} {/if} </td> + {if $parallelMode == false} <td>{$nodeInfo[num][3]|escape}</td> {/if} + <td> {if $nodeInfo[num][4] == 'disconnect'} - <input type="button" name="command" onclick="sendCommand('detach', {$smarty.section.num.index|escape}, '{$message.msgDetachConfirm|escape}')" value="{$message.strDisconnect|escape}" /> + <input type="button" name="command" + onclick="sendCommand('detach', {$smarty.section.num.index|escape}, '{$message.msgDetachConfirm|escape}')" + value="{$message.strDisconnect|escape}" /> {elseif $nodeInfo[num][4] == 'return'} - <input type="button" name="command" onclick="sendCommand('return', {$smarty.section.num.index|escape}, '{$message.msgReturnConfirm|escape}')" value="{$message.strReturn|escape}" /> + <input type="button" name="command" + onclick="sendCommand('return', {$smarty.section.num.index|escape}, '{$message.msgReturnConfirm|escape}')" + value="{$message.strReturn|escape}" /> {elseif $nodeInfo[num][4] == 'recovery'} - <input type="button" name="command" onclick="sendCommand('recovery', {$smarty.section.num.index|escape}, '{$message.msgRecoveryConfirm|escape}')" value="{$message.strRecovery|escape}" /> + <input type="button" name="command" + onclick="sendCommand('recovery', {$smarty.section.num.index|escape}, '{$message.msgRecoveryConfirm|escape}')" + value="{$message.strRecovery|escape}" /> {/if} - </td> + </td> + </tr> {/section} </table> + {else} {$message.strNoNode|escape} {/if} + </body> </html> diff --git a/templates/pgconfig.tpl b/templates/pgconfig.tpl index 24f63d5..5f124f9 100644 --- a/templates/pgconfig.tpl +++ b/templates/pgconfig.tpl @@ -19,7 +19,7 @@ function resetData(){ } function del(num){ - if(window.confirm(msgDeleteConfirm)){ + if(window.confirm(msgDeleteConfirm)){ document.pgconfig.action.value= "delete"; document.pgconfig.num.value = num; document.pgconfig.submit(); @@ -40,28 +40,33 @@ function cancelNode() { </script> {/literal} </head> + <body> <div id="header"> <h1><img src="images/logo.gif" alt="pgpoolAdmin" /></h1> </div> + <div id="menu"> {include file="menu.tpl"} </div> + <div id="content"> <div id="help"><a href="help.php?help={$help|escape}"><img src="images/question.gif" alt="help"/>{$message.strHelp|escape}</a></div> + {if $status == 'success'} <table> - <tr> - <td>{$message.msgUpdateComplete|escape}</td> - </tr> + <tr> + <td>{$message.msgUpdateComplete|escape}</td> + </tr> </table> {elseif $status == 'fail'} <table> - <tr> - <td>{$message.msgUpdateFailed|escape}</td> - </tr> + <tr> + <td>{$message.msgUpdateFailed|escape}</td> + </tr> </table> - {/if} + {/if} + <h2>{$message.strPgConfSetting|escape}</h2> <div id="submenu"> <h3>Table of Contents</h3> @@ -78,10 +83,16 @@ function cancelNode() { <li><a href="#others">Others</a></li> </ul> </div> + <form name="pgconfig" method="post" action="pgconfig.php"> <input type="hidden" name="action" value="" /> <input type="hidden" name="num" value="" /> + + {* --------------------------------------------------------------------- * + * Connections * + * --------------------------------------------------------------------- *} <h3><a name="connections" id="connections">Connections</a></h3> + <table> <thead> <tr> @@ -95,6 +106,7 @@ function cancelNode() { </tr> </tfoot> <tbody> + <tr> {if $error.listen_addresses != null} <th class="error"><label>{$message.descListen_addresses|escape}</label> <br />listen_addresses (string) *</th> @@ -104,6 +116,7 @@ function cancelNode() { {/if} <td><input type="text" name="listen_addresses" value="{$params.listen_addresses|escape}"/></td> </tr> + <tr> {if $error.port != null} <th class="error"><label>{$message.descPort|escape}</label> <br />port (integer) *</th> @@ -113,6 +126,7 @@ function cancelNode() { {/if} <td><input type="text" name="port" value="{$params.port|escape}"/></td> </tr> + <tr> {if $error.socket_dir != null} <th class="error"><label>{$message.descSocket_dir|escape}</label> <br />socket_dir (string) *</th> @@ -122,6 +136,7 @@ function cancelNode() { {/if} <td><input type="text" name="socket_dir" value="{$params.socket_dir|escape}"/></td> </tr> + <tr> {if $error.num_init_children != null} <th class="error"><label>{$message.descNum_init_children|escape}</label> <br />num_init_children (integer) *</th> @@ -131,6 +146,7 @@ function cancelNode() { {/if} <td><input type="text" name="num_init_children" value="{$params.num_init_children|escape}"/></td> </tr> + <tr> {if $error.max_pool != null} <th class="error"><label>{$message.descMax_pool|escape}</label> <br />max_pool (integer) *</th> @@ -140,6 +156,7 @@ function cancelNode() { {/if} <td><input type="text" name="max_pool" value="{$params.max_pool|escape}"/></td> </tr> + <tr> {if $error.child_life_time != null} <th class="error"><label>{$message.descChild_life_time|escape}</label> <br />child_life_time (integer)</th> @@ -149,6 +166,7 @@ function cancelNode() { {/if} <td><input type="text" name="child_life_time" value="{$params.child_life_time|escape}"/></td> </tr> + <tr> {if $error.connection_life_time != null} <th class="error"><label>{$message.descConnection_life_time|escape}</label> <br />connection_life_time (integer)</th> @@ -158,7 +176,8 @@ function cancelNode() { {/if} <td><input type="text" name="connection_life_time" value="{$params.connection_life_time|escape}"/></td> </tr> - <tr> {if $error.child_max_connections != null} + + <tr> {if $error.child_max_connections != null} <th class="error"><label>{$message.descChild_max_connections|escape}</label> <br />child_max_connections (integer)</th> {else} @@ -167,7 +186,8 @@ function cancelNode() { {/if} <td><input type="text" name="child_max_connections" value="{$params.child_max_connections|escape}"/></td> </tr> - <tr> {if $error.client_idle_limit != null} + + <tr> {if $error.client_idle_limit != null} <th class="error"><label>{$message.descClient_idle_limit|escape}</label> <br />client_idle_limit (integer)</th> {else} @@ -176,7 +196,8 @@ function cancelNode() { {/if} <td><input type="text" name="client_idle_limit" value="{$params.client_idle_limit|escape}"/></td> </tr> - <tr> {if $error.authentication_timeout != null} + + <tr> {if $error.authentication_timeout != null} <th class="error"><label>{$message.descAuthentication_timeout|escape}</label> <br />authentication_timeout (integer)</th> {else} @@ -185,18 +206,20 @@ function cancelNode() { {/if} <td><input type="text" name="authentication_timeout" value="{$params.authentication_timeout|escape}"/></td> </tr> + <tr> {if $error.connection_cache != null} <th class="error"><label>{$message.descConnection_cache|escape}</label> - <br />connection_cache *</th> + <br />connection_cache *</th> {else} <th><label>{$message.descConnection_cache|escape}</label> - <br />connection_cache *</th> + <br />connection_cache *</th> {/if} {if $params.connection_cache == 'true'} <td><input type="checkbox" name="connection_cache" id="connection_cache" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="connection_cache" id="connection_cache" value="false" /></td> {/if} </tr> + <tr> {if $error.pgpool2_hostname != null} <th><label>{$message.descPgpool2_hostname|escape}</label> <br />pgpool2_hostname (string) *</th> @@ -206,9 +229,16 @@ function cancelNode() { {/if} <td><input type="text" name="pgpool2_hostname" value="{$params.pgpool2_hostname|escape}"/></td> </tr> + </tbody> </table> + + + {* --------------------------------------------------------------------- * + * Backends * + * --------------------------------------------------------------------- *} <h3><a name="backends" id="backends">Backends</a></h3> + <table> <thead> <tr> @@ -217,6 +247,7 @@ function cancelNode() { <td></td> </tr> </thead> + {if $isAdd == true} <tfoot> <tr> @@ -231,6 +262,7 @@ function cancelNode() { </tfoot> {/if} <tbody> + <tr> {if $error.backend_socket_dir != null} <th class="error"><label>{$message.descBackend_socket_dir|escape}</label> <br />backend_socket_dir (string)</th> @@ -241,6 +273,7 @@ function cancelNode() { <td><input type="text" name="backend_socket_dir" value="{$params.backend_socket_dir|escape}"/></td> <td></td> </tr> + {section name=num loop=$params.backend_hostname} <tr> {if $error.backend_hostname[num] != null} <th class="error"><label>{$message.descBackend_hostname|escape}</label> @@ -252,6 +285,7 @@ function cancelNode() { <td><input type="text" name="backend_hostname[]" value="{$params.backend_hostname[num]|escape}" /></td> <td rowspan="4"><input type="button" name="delete" value="{$message.strDelete|escape}" onclick="del({$smarty.section.num.index})" /></td> </tr> + <tr> {if $error.backend_port[num] != null} <th class="error"><label>{$message.descBackend_port|escape}</label> <br />backend_port{$smarty.section.num.index|escape} (integer)</th> @@ -261,6 +295,7 @@ function cancelNode() { {/if} <td><input type="text" name="backend_port[]" value="{$params.backend_port[num]|escape}" /></td> </tr> + <tr> {if $error.backend_weight[num] != null} <th class="error"><label>{$message.descBackend_weight|escape}</label> <br />backend_weight{$smarty.section.num.index|escape} (float)</th> @@ -270,6 +305,7 @@ function cancelNode() { {/if} <td><input type="text" name="backend_weight[]" value="{$params.backend_weight[num]|escape}" /></td> </tr> + <tr> {if $error.backend_data_directory[num] != null} <th class="error"><label>{$message.descBackend_data_directory|escape}</label> <br />backend_data_directory{$smarty.section.num.index|escape} (string)</th> @@ -280,31 +316,37 @@ function cancelNode() { <td><input type="text" name="backend_data_directory[]" value="{$params.backend_data_directory[num]|escape}" /></td> </tr> {/section} + {if $isAdd == true} <tr> <th><label>new backend_hostname</label> (string)</th> <td><input type="text" name="backend_hostname[]" value="" /></td> <td rowspan="4"></td> + </tr> <tr><th><label>new backend_port</label> (integer)</th> <td><input type="text" name="backend_port[]" value="" /></td> </tr> + <tr> <th><label>new backend_weight</label> (float)</th> <td><input type="text" name="backend_weight[]" value="" /></td> </tr> + <tr> <th><label>new backend_data_directory</label> (string)</th> <td><input type="text" name="backend_data_directory[]" value="" /></td> </tr> {/if} - </tbody> + </tbody> </table> + <h3><a name="pcp" id="pcp">PCP (pgpool Control Port)</a></h3> + <table> <thead> <tr> @@ -318,6 +360,7 @@ function cancelNode() { </tr> </tfoot> <tbody> + <tr> {if $error.pcp_port != null} <th class="error"><label>{$message.descPcp_port|escape}</label> <br />pcp_port (integer) *</th> @@ -327,6 +370,7 @@ function cancelNode() { {/if} <td><input type="text" name="pcp_port" value="{$params.pcp_port|escape}"/></td> </tr> + <tr> {if $error.pcp_socket_dir != null} <th class="error"><label>{$message.descPcp_socket_dir|escape}</label> <br />pcp_socket_dir (string) *</th> @@ -336,6 +380,7 @@ function cancelNode() { {/if} <td><input type="text" name="pcp_socket_dir" value="{$params.pcp_socket_dir|escape}"/></td> </tr> + <tr> {if $error.pcp_timeout != null} <th class="error"><label>{$message.descPcp_timeout|escape}</label> <br />pcp_timeout (integer)</th> @@ -345,9 +390,16 @@ function cancelNode() { {/if} <td><input type="text" name="pcp_timeout" value="{$params.pcp_timeout|escape}"/></td> </tr> + </tbody> </table> + + {* --------------------------------------------------------------------- * + * Logging * + * --------------------------------------------------------------------- *} + <h3><a name="logging" id="logging">Logging</a></h3> + <table> <thead> <tr> @@ -355,11 +407,13 @@ function cancelNode() { <th>{$message.strValue|escape}</th> </tr> </thead> + <tfoot> <tr> <td colspan="2"></td> </tr> </tfoot> + <tbody> <tr> {if $error.logdir != null} <th class="error"><label>{$message.descLogdir|escape}</label> @@ -383,75 +437,80 @@ function cancelNode() { <tr> {if $error.print_timestamp != null} <th><label>{$message.descPrint_timestamp|escape}</label> - <br />print_timestamp *</th> + <br />print_timestamp *</th> {else} <th><label>{$message.descPrint_timestamp|escape}</label> - <br />print_timestamp *</th> + <br />print_timestamp *</th> {/if} {if $params.print_timestamp == 'true'} <td><input type="checkbox" name="print_timestamp" id="print_timestamp" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="print_timestamp" id="print_timestamp" value="false" /></td> {/if} - </tr> + </tr> <tr> {if $error.log_statement != null} <th class="error"><label>{$message.descLog_statement|escape}</label> - <br />log_statement</th> + <br />log_statement</th> {else} <th><label>{$message.descLog_statement|escape}</label> - <br />log_statement</th> + <br />log_statement</th> {/if} {if $params.log_statement == 'true'} <td><input type="checkbox" name="log_statement" id="log_statement" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="log_statement" id="log_statement" value="false" /></td> {/if} - </tr> + </tr> <tr> {if $error.log_per_node_statement != null} <th class="error"><label>{$message.descLog_per_node_statement|escape}</label> - <br />log_per_node_statement</th> + <br />log_per_node_statement</th> {else} <th><label>{$message.descLog_per_node_statement|escape}</label> - <br />log_per_node_statement</th> + <br />log_per_node_statement</th> {/if} {if $params.log_per_node_statement == 'true'} <td><input type="checkbox" name="log_per_node_statement" id="log_per_node_statement" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="log_per_node_statement" id="log_per_node_statement" value="false" /></td> {/if} - </tr> + </tr> <tr> {if $error.log_connections != null} <th class="error"><label>{$message.descLog_connections|escape}</label> - <br />log_connections</th> + <br />log_connections</th> {else} <th><label>{$message.descLog_connections|escape}</label> - <br />log_connections</th> + <br />log_connections</th> {/if} {if $params.log_connections == 'true'} <td><input type="checkbox" name="log_connections" id="log_connections" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="log_connections" id="log_connections" value="false" /></td> {/if} - </tr> + </tr> <tr> {if $error.log_hostname != null} <th class="error"><label>{$message.descLog_hostname|escape}</label> - <br />log_hostname</th> + <br />log_hostname</th> {else} <th><label>{$message.descLog_hostname|escape}</label> - <br />log_hostname</th> + <br />log_hostname</th> {/if} {if $params.log_hostname == 'true'} <td><input type="checkbox" name="log_hostname" id="log_hostname" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="log_hostname" id="log_hostname" value="false" /></td> {/if} - </tr> + </tr> </tbody> </table> + + {* --------------------------------------------------------------------- * + * Replication * + * --------------------------------------------------------------------- *} <h3><a name="replication" id="replication">Replication</a></h3> + <table> <thead> <tr> @@ -467,10 +526,10 @@ function cancelNode() { <tbody> <tr> {if $error.replication_mode != null} <th class="error"><label>{$message.descReplication_mode|escape}</label> - <br />replication_mode *</th> + <br />replication_mode *</th> {else} <th><label>{$message.descReplication_mode|escape}</label> - <br />replication_mode *</th> + <br />replication_mode *</th> {/if} {if $params.replication_mode == 'true'} <td><input type="checkbox" name="replication_mode" id="replication_mode" value="true" checked="checked" /></td> @@ -489,10 +548,10 @@ function cancelNode() { <tr> {if $error.replication_stop_on_mismatch != null} <th class="error"><label>{$message.descReplication_stop_on_mismatch|escape}</label> - <br />replication_stop_on_mismatch</th> + <br />replication_stop_on_mismatch</th> {else} <th><label>{$message.descReplication_stop_on_mismatch|escape}</label> - <br />replication_stop_on_mismatch</th> + <br />replication_stop_on_mismatch</th> {/if} {if $params.replication_stop_on_mismatch == 'true'} <td><input type="checkbox" name="replication_stop_on_mismatch" id="replication_stop_on_mismatch" value="true" checked="checked" /></td> @@ -502,10 +561,10 @@ function cancelNode() { <tr> {if $error.fail_over_on_backend_error != null} <th class="error"><label>{$message.descFail_over_on_backend_error|escape}</label> - <br />fail_over_on_backend_error</th> + <br />fail_over_on_backend_error</th> {else} <th><label>{$message.descFail_over_on_backend_error|escape}</label> - <br />fail_over_on_backend_error</th> + <br />fail_over_on_backend_error</th> {/if} {if $params.fail_over_on_backend_error == 'true'} <td><input type="checkbox" name="fail_over_on_backend_error" id="fail_over_on_backend_error" value="true" checked="checked" /></td> @@ -514,10 +573,10 @@ function cancelNode() { {/if} </tr> <tr> {if $error.replication_stop_on_mismatch != null} <th class="error"><label>{$message.descFailover_if_affected_tuples_mismatch|escape}</label> - <br />failover_if_affected_tuples_mismatch</th> + <br />failover_if_affected_tuples_mismatch</th> {else} <th><label>{$message.descFailover_if_affected_tuples_mismatch|escape}</label> - <br />failover_if_affected_tuples_mismatch</th> + <br />failover_if_affected_tuples_mismatch</th> {/if} {if $params.failover_if_affected_tuples_mismatch == 'true'} <td><input type="checkbox" name="failover_if_affected_tuples_mismatch" id="failover_if_affected_tuples_mismatch" value="true" checked="checked" /></td> @@ -527,10 +586,10 @@ function cancelNode() { <tr> {if $error.replicate_select != null} <th class="error"><label>{$message.descReplicate_select|escape}</label> - <br />replicate_select</th> + <br />replicate_select</th> {else} <th><label>{$message.descReplicate_select|escape}</label> - <br />replicate_select</th> + <br />replicate_select</th> {/if} {if $params.replicate_select == 'true'} <td><input type="checkbox" name="replicate_select" id="replicate_select" value="true" checked="checked" /></td> @@ -546,7 +605,7 @@ function cancelNode() { <br />reset_query_list (string)</th> {/if} <td><input type="text" name="reset_query_list" value="{$params.reset_query_list|escape}"/></td> - </tr> + </tr> <tr> {if $error.white_function_list != null} <th class="error"><label>{$message.descWhite_function_list|escape}</label> @@ -556,7 +615,7 @@ function cancelNode() { <br />white_function_list (string)</th> {/if} <td><input type="text" name="white_function_list" value="{$params.white_function_list|escape}"/></td> - </tr> + </tr> <tr> {if $error.black_function_list != null} <th class="error"><label>{$message.descBlack_function_list|escape}</label> @@ -566,11 +625,16 @@ function cancelNode() { <br />black_function_list (string)</th> {/if} <td><input type="text" name="black_function_list" value="{$params.black_function_list|escape}"/></td> - </tr> + </tr> </tbody> </table> + + {* --------------------------------------------------------------------- * + * Health Check * + * --------------------------------------------------------------------- *} <h3><a name="health-check" id="health-check">Health Check</a></h3> + <table> <thead> <tr> @@ -583,6 +647,7 @@ function cancelNode() { <td colspan="2"></td> </tr> </tfoot> + <tbody> <tr> {if $error.health_check_timeout != null} <th class="error"><label>{$message.descHealth_check_timeout|escape}</label> @@ -593,6 +658,7 @@ function cancelNode() { {/if} <td><input type="text" name="health_check_timeout" value="{$params.health_check_timeout|escape}"/></td> </tr> + <tr> {if $error.health_check_period != null} <th class="error"><label>{$message.descHealth_check_period|escape}</label> <br />health_check_period (integer)</th> @@ -602,6 +668,7 @@ function cancelNode() { {/if} <td><input type="text" name="health_check_period" value="{$params.health_check_period|escape}"/></td> </tr> + <tr> {if $error.health_check_user != null} <th class="error"><label>{$message.descHealth_check_user|escape}</label> <br />health_check_user (string)</th> @@ -613,7 +680,12 @@ function cancelNode() { </tr> </tbody> </table> + + {* --------------------------------------------------------------------- * + * Online Recovery * + * --------------------------------------------------------------------- *} <h3><a name="recovery" id="recovery">Online Recovery</a></h3> + <table> <thead> <tr> @@ -626,6 +698,7 @@ function cancelNode() { <td colspan="2"></td> </tr> </tfoot> + <tbody> <tr> {if $error.recovery_user != null} <th class="error"><label>{$message.descRecovery_user|escape}</label> @@ -636,6 +709,7 @@ function cancelNode() { {/if} <td><input type="text" name="recovery_user" value="{$params.recovery_user|escape}"/></td> </tr> + <tr> {if $error.recovery_password != null} <th class="error"><label>{$message.descRecovery_password|escape}</label> <br />recovery_password (string)</th> @@ -645,6 +719,7 @@ function cancelNode() { {/if} <td><input type="password" name="recovery_password" value="{$params.recovery_password|escape}"/></td> </tr> + <tr> {if $error.recovery_1st_stage_command != null} <th class="error"><label>{$message.descRecovery_1st_stage_command|escape}</label> <br />recovery_1st_stage_command (string)</th> @@ -654,6 +729,7 @@ function cancelNode() { {/if} <td><input type="text" name="recovery_1st_stage_command" value="{$params.recovery_1st_stage_command|escape}"/></td> </tr> + <tr> {if $error.recovery_2nd_stage_command != null} <th class="error"><label>{$message.descRecovery_2nd_stage_command|escape}</label> <br />recovery_2nd_stage_command (string)</th> @@ -663,6 +739,7 @@ function cancelNode() { {/if} <td><input type="text" name="recovery_2nd_stage_command" value="{$params.recovery_2nd_stage_command|escape}"/></td> </tr> + <tr> {if $error.recovery_timeout != null} <th class="error"><label>{$message.descRecovery_timeout|escape}</label> <br />recovery_timeout (integer)</th> @@ -673,7 +750,7 @@ function cancelNode() { <td><input type="text" name="recovery_timeout" value="{$params.recovery_timeout|escape}"/></td> </tr> - <tr> {if $error.client_idle_limit_in_recovery != null} + <tr> {if $error.client_idle_limit_in_recovery != null} <th class="error"><label>{$message.descClient_idle_limit_in_recovery|escape}</label> <br />client_idle_limit_in_recovery (integer)</th> {else} @@ -682,10 +759,14 @@ function cancelNode() { {/if} <td><input type="text" name="client_idle_limit_in_recovery" value="{$params.client_idle_limit_in_recovery|escape}"/></td> </tr> - </tbody> </table> + + {* --------------------------------------------------------------------- * + * System Database * + * --------------------------------------------------------------------- *} <h3><a name="system-database" id="system-database">System Database</a></h3> + <table> <thead> <tr> @@ -698,7 +779,9 @@ function cancelNode() { <td colspan="2"></td> </tr> </tfoot> + <tbody> + <tr> {if $error.system_db_hostname != null} <th class="error"><label>{$message.descSystem_db_hostname|escape}</label> <br />system_db_hostname (string) *</th> @@ -708,6 +791,7 @@ function cancelNode() { {/if} <td><input type="text" name="system_db_hostname" value="{$params.system_db_hostname|escape}"/></td> </tr> + <tr> {if $error.system_db_port != null} <th class="error"><label>{$message.descSystem_db_port|escape}</label> <br />system_db_port (integer) *</th> @@ -717,6 +801,7 @@ function cancelNode() { {/if} <td><input type="text" name="system_db_port" value="{$params.system_db_port|escape}"/></td> </tr> + <tr> {if $error.system_db_dbname != null} <th class="error"><label>{$message.descSystem_db_dbname|escape}</label> <br />system_db_dbname (string) *</th> @@ -726,6 +811,7 @@ function cancelNode() { {/if} <td><input type="text" name="system_db_dbname" value="{$params.system_db_dbname|escape}"/></td> </tr> + <tr> {if $error.system_db_schema != null} <th class="error"><label>{$message.descSystem_db_schema|escape}</label> <br />system_db_schema (string) *</th> @@ -735,6 +821,7 @@ function cancelNode() { {/if} <td><input type="text" name="system_db_schema" value="{$params.system_db_schema|escape}"/></td> </tr> + <tr> {if $error.system_db_user != null} <th class="error"><label>{$message.descSystem_db_user|escape}</label> <br />system_db_user (string) *</th> @@ -744,6 +831,7 @@ function cancelNode() { {/if} <td><input type="text" name="system_db_user" value="{$params.system_db_user|escape}"/></td> </tr> + <tr> {if $error.system_db_password != null} <th class="error"><label>{$message.descSystem_db_password|escape}</label> <br />system_db_password (string) *</th> @@ -753,9 +841,15 @@ function cancelNode() { {/if} <td><input type="password" name="system_db_password" value="{$params.system_db_password|escape}"/></td> </tr> + </tbody> </table> + + {* --------------------------------------------------------------------- * + * Ssl * + * --------------------------------------------------------------------- *} <h3><a name="ssl" id="ssl">Ssl</a></h3> + <table> <thead> <tr> @@ -768,7 +862,9 @@ function cancelNode() { <td colspan="2"></td> </tr> </tfoot> + <tbody> + <tr> {if $error.ssl != null} <th class="error"><label>{$message.descSsl|escape}</label> <br />ssl</th> @@ -782,6 +878,7 @@ function cancelNode() { <td><input type="checkbox" name="ssl" id="ssl" value="false" /></td> {/if} </tr> </tr> + <tr> {if $error.ssl_key != null} <th class="error"><label>{$message.descSsl_key|escape}</label> <br />ssl_key</th> @@ -791,6 +888,7 @@ function cancelNode() { {/if} <td><input type="text" name="ssl_key" id="ssl_key" value="{$params.ssl_key|escape}" /></td> </tr> + <tr> {if $error.ssl_cert != null} <th class="error"><label>{$message.descSsl_cert|escape}</label> <br />ssl_cert</th> @@ -800,6 +898,7 @@ function cancelNode() { {/if} <td><input type="text" name="ssl_cert" id="ssl_cert" value="{$params.ssl_cert|escape}" /></td> </tr> + <tr> {if $error.ssl_ca_cert != null} <th class="error"><label>{$message.descSsl_ca_cert|escape}</label> <br />ssl_ca_cert</th> @@ -809,6 +908,7 @@ function cancelNode() { {/if} <td><input type="text" name="ssl_ca_cert" id="ssl_ca_cert" value="{$params.ssl_ca_cert|escape}" /></td> </tr> + <tr> {if $error.ssl_ca_cert_dir != null} <th class="error"><label>{$message.descSsl_ca_cert_dir|escape}</label> <br />ssl_ca_cert_dir</th> @@ -821,7 +921,12 @@ function cancelNode() { </tbody> </table> + + {* --------------------------------------------------------------------- * + * Others * + * --------------------------------------------------------------------- *} <h3><a name="others" id="others">Others</a></h3> + <table> <thead> <tr> @@ -835,33 +940,36 @@ function cancelNode() { </tr> </tfoot> <tbody> + <tr> {if $error.load_balance_mode != null} <th class="error"><label>{$message.descLoad_balance_mode|escape}</label> - <br />load_balance_mode *</th> + <br />load_balance_mode *</th> {else} <th><label>{$message.descLoad_balance_mode|escape}</label> - <br />load_balance_mode *</th> + <br />load_balance_mode *</th> {/if} {if $params.load_balance_mode == 'true'} <td><input type="checkbox" name="load_balance_mode" id="load_balance_mode" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="load_balance_mode" id="load_balance_mode" value="false" /></td> {/if} </tr> + <tr> {if $error.master_slave_mode != null} <th class="error"><label>{$message.descMaster_slave_mode|escape}</label> - <br />master_slave_mode *</th> + <br />master_slave_mode *</th> {else} <th><label>{$message.descMaster_slave_mode|escape}</label> - <br />master_slave_mode *</th> + <br />master_slave_mode *</th> {/if} {if $params.master_slave_mode == 'true'} <td><input type="checkbox" name="master_slave_mode" id="master_slave_mode" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="master_slave_mode" id="master_slave_mode" value="false" /></td> {/if} </tr> + <tr> {if $error.master_slave_sub_mode != null} <th class="error"><label>{$message.descMaster_slave_sub_mode|escape}</label> - <br />master_slave_sub_mode *</th> + <br />master_slave_sub_mode *</th> {else} <th><label>{$message.descMaster_slave_sub_mode|escape}</label><br />master_slave_sub_mode *</th> {/if} @@ -870,6 +978,7 @@ function cancelNode() { <option value="stream" {if $params.master_slave_sub_mode == 'stream'}selected{/if}>stream</option> </select></td> </tr> + <tr> {if $error.delay_threshold != null} <th class="error"><label>{$message.descDelay_threshold|escape}</label><br />delay_threshold</th> {else} @@ -877,6 +986,7 @@ function cancelNode() { {/if} <td><input type="text" name="delay_threshold" id="delay_threshold" value="{$params.delay_threshold|escape}" /></td> </tr> + <tr> {if $error.log_standby_delay != null} <th class="error"><label>{$message.descLog_standby_delay|escape}</label><br />log_standby_delay</th> {else} @@ -888,66 +998,72 @@ function cancelNode() { <option value="none" {if $params.log_standby_delay == 'none'}selected{/if}>none</option> </select></td> </tr> + <tr> {if $error.portinsert_lock!= null} <th class="error"><label>{$message.descInsert_lock|escape}</label> - <br />insert_lock</th> + <br />insert_lock</th> {else} <th><label>{$message.descInsert_lock|escape}</label> - <br />insert_lock</th> + <br />insert_lock</th> {/if} {if $params.insert_lock == 'true'} <td><input type="checkbox" name="insert_lock" id="insert_lock" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="insert_lock" id="insert_lock" value="false" /></td> {/if} </tr> + <tr> {if $error.ignore_leading_white_space != null} <th class="error"><label>{$message.descIgnore_leading_white_space|escape}</label> - <br />ignore_leading_white_space</th> + <br />ignore_leading_white_space</th> {else} <th><label>{$message.descIgnore_leading_white_space|escape}</label> - <br />ignore_leading_white_space</th> + <br />ignore_leading_white_space</th> {/if} {if $params.ignore_leading_white_space == 'true'} <td><input type="checkbox" name="ignore_leading_white_space" id="ignore_leading_white_space" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="ignore_leading_white_space" id="ignore_leading_white_space" value="false" /></td> {/if} </tr> + <tr> {if $error.parallel_mode != null} <th class="error"><label>{$message.descParallel_mode|escape}</label> - <br />parallel_mode *</th> + <br />parallel_mode *</th> {else} <th><label>{$message.descParallel_mode|escape}</label> - <br />parallel_mode *</th> + <br />parallel_mode *</th> {/if} {if $params.parallel_mode == 'true'} <td><input type="checkbox" name="parallel_mode" id="parallel_mode" value="true" checked="checked" /></td> {else} <td><input type="checkbox" name="parallel_mode" id="parallel_mode" value="false" /></td> {/if} </tr> + <tr> {if $error.enable_query_cache != null} <th class="error"><label>{$message.descEnable_query_cache|escape}</label> - <br />enable_query_cache *</th> + <br />enable_query_cache *</th> {else} <th><label>{$message.descEnable_query_cache|escape}</label> - <br />enable_query_cache *</th> + <br />enable_query_cache *</th> {/if} {if $params.enable_query_cache == 'true'} <td><input type="checkbox" name="enable_query_cache" id="enable_query_cache" checked="checked" /></td> {else} <td><input type="checkbox" name="enable_query_cache" id="enable_query_cache" /></td> {/if} </tr> + <tr> {if $error.enable_pool_hba != null} <th class="error"><label>{$message.descEnable_pool_hba|escape}</label> - <br />enable_pool_hba</th> + <br />enable_pool_hba</th> {else} <th><label>{$message.descEnable_pool_hba|escape}</label> - <br />enable_pool_hba</th> + <br />enable_pool_hba</th> {/if} {if $params.enable_pool_hba == 'true'} <td><input type="checkbox" name="enable_pool_hba" id="enable_pool_hba" checked="checked" /></td> {else} <td><input type="checkbox" name="enable_pool_hba" id="enable_pool_hba" /></td> {/if} </tr> + <tr> {if $error.failover_command != null} <th class="error"><label>{$message.descFailover_command|escape}</label> <br />failover_command (string)</th> @@ -957,6 +1073,7 @@ function cancelNode() { {/if} <td><input type="text" name="failover_command" value="{$params.failover_command|escape}"/></td> </tr> + <tr> {if $error.failback_command != null} <th class="error"><label>{$message.descFailback_command|escape}</label> <br />failback_command (string)</th> @@ -966,6 +1083,7 @@ function cancelNode() { {/if} <td><input type="text" name="failback_command" value="{$params.failback_command|escape}"/></td> </tr> + <tr> {if $error.lobj_lock_table != null} <th class="error"><label>{$message.descLobj_lock_table|escape}</label> <br />lobj_lock_table</th> @@ -978,13 +1096,19 @@ function cancelNode() { </tbody> </table> + + {* --------------------------------------------------------------------- * + * Form End * + * --------------------------------------------------------------------- *} <p> <input type="button" name="btnSubmit" value="{$message.strUpdate|escape}" onclick="update()"/> <input type="button" name="btnReset" value="{$message.strReset|escape}" onclick="resetData()"/> </p> </form> + <p>{$message.cautionaryNote|escape}</p> </div> + <hr class="hidden" /> <div id="footer"> {include file='footer.tpl'} diff --git a/version.php b/version.php index b712176..1fc2023 100644 --- a/version.php +++ b/version.php @@ -23,6 +23,6 @@ * @version SVN: $Id$
*/
-$version = '3.0.3';
+$version = '3.1.0';
?>
|