* @copyright 2003-2020 PgPool Global Development Group * @version CVS: $Id$ */ require_once('../version.php'); session_start(); require_once("defaultParameter.php"); require_once('setLang.php'); /* --------------------------------------------------------------------- */ /* Error check */ /* --------------------------------------------------------------------- */ $error = FALSE; $action = ''; if (isset($_POST['action'])) { $action = $_POST['action']; } // check version if (isset($_POST['version']) && $_POST['version']) { $version = $_POST['version']; } // check pgpool.conf if (isset($_POST['pgpool2_config_file']) && $_POST['pgpool2_config_file']) { $pgpool2_config_file = $_POST['pgpool2_config_file']; } else { $pgpool2_config_file = _PGPOOL2_CONFIG_FILE; } $msgPgpoolConfigFile = ''; if (! @is_file($pgpool2_config_file)) { $msgPgpoolConfigFile = 'File not found'; $error = TRUE; } else { if (!is_readable($pgpool2_config_file)) { $msgPgpoolConfigFile = 'Read access denied'; $error = TRUE; } if (!is_writable($pgpool2_config_file)) { $msgPgpoolConfigFile = 'Write access denied'; $error = TRUE; } } // check pcp.conf if (isset($_POST['password_file']) && $_POST['password_file']) { $password_file = $_POST['password_file']; } else { $password_file = _PGPOOL2_PASSWORD_FILE; } $msgPasswordFile = ''; if (! @is_file($password_file)) { $msgPasswordFile = 'File not found'; $error = TRUE; } else { if (!is_readable($password_file)) { $msgPasswordFile = 'Read access denied'; $error = TRUE; } if (!is_writable($password_file)) { $msgPasswordFile = 'Write access denied'; $error = TRUE; } } // check bin directory if (isset($_POST['pgpool_command']) && $_POST['pgpool_command']) { $pgpool_command = $_POST['pgpool_command']; } else { $pgpool_command = _PGPOOL2_COMMAND; } $msgPgpoolCommand = ''; if (! @is_file($pgpool_command)) { $msgPgpoolCommand = 'pgpool command not found'; $error = TRUE; } elseif (!is_executable($pgpool_command)) { $msgPgpoolCommand = 'pgpool command not executable'; $error = TRUE; } // check args of pgpool command $msgCmdC = ''; $msgCmdLargeD = ''; $msgCmdD = ''; $msgCmdN = ''; $msgCmdM = ''; $msgCmdLargeC = ''; $msgPgpoolLogFile = ''; if (isset($_POST['pgpool_logfile']) && $_POST['pgpool_logfile']) { $pgpool_logfile = $_POST['pgpool_logfile']; } else { $pgpool_logfile = _PGPOOL2_LOG_FILE; } if ($pgpool_logfile != '' && strpos($pgpool_logfile, '|') !== FALSE) { // pipe $tmp_str = trim($pgpool_logfile); if (($tmp_str[0] != '|') || ($tmp_str[strlen($tmp_str) - 1] == '|')) { $msgPgpoolLogFile = 'Directory not found'; $error = TRUE; } // check log file directory } elseif (!is_dir(dirname($pgpool_logfile))) { $msgPgpoolLogFile = 'Directory not found'; $error = TRUE; } elseif (!is_writable(dirname($pgpool_logfile))) { $msgPgpoolLogFile = 'Write access denied'; $error = TRUE; } // check pcp parameters if (isset($_POST['pcp_client_dir']) && $_POST['pcp_client_dir']) { $pcp_client_dir = $_POST['pcp_client_dir']; } else { $pcp_client_dir = _PGPOOL2_PCP_DIR; } $msgPcpClientDir = ''; if (!is_dir($pcp_client_dir)) { $msgPcpClientDir = 'Directory not found'; $error = TRUE; } else { $commands = getPcpCommands(); foreach ($commands as $command) { $command_fullpath = "{$pcp_client_dir}/{$command}"; if (! @is_file($command_fullpath)) { $msgPcpClientDir = $command . ' command not found'; $error = TRUE; } elseif (!is_executable($command_fullpath)) { $msgPcpClientDir = $command . ' not executable'; $error = TRUE; } } } $msgPcpHostname = ''; if (isset($_POST['pcp_hostname']) && $_POST['pcp_hostname']) { $pcp_hostname = $_POST['pcp_hostname']; } else { $pcp_hostname = _PGPOOL2_PCP_HOSTNAME; } $proc_user_info = posix_getpwuid(posix_geteuid()); $pcppass_file = "{$proc_user_info['dir']}/.pcppass"; $msgPcpPassFile = ''; if (3.5 <= $version) { if (! is_file($pcppass_file)) { $msgPcpPassFile = 'File not found'; } elseif (fileowner($pcppass_file) != $proc_user_info['uid']) { $msgPcpPassFile = 'Invalid owner'; } elseif (substr(sprintf('%o', fileperms($pcppass_file)), -4) != '0600') { $msgPcpPassFile = 'Invalid permission'; } } $msgPcpTimeout = ''; if (isset($_POST['pcp_timeout']) && $_POST['pcp_timeout']) { $pcp_timeout= $_POST['pcp_timeout']; } else { $pcp_timeout = _PGPOOL2_PCP_TIMEOUT; } $msgPcpRefreshTime = ''; if (isset($_POST['pcp_refreshTime']) && $_POST['pcp_refreshTime']) { $pcp_refreshTime = $_POST['pcp_refreshTime']; } else { $pcp_refreshTime = _PGPOOL2_STATUS_REFRESH_TIME; } $msgPgConnectTimeout = ''; if (isset($_POST['pg_connect_timeout']) && $_POST['pg_connect_timeout']) { $pg_connect_timeout = $_POST['pg_connect_timeout']; } else { $pg_connect_timeout = _PGPOOL2_PG_CONNECT_TIMEOUT; } $msgPhpPgsql= ''; if (!extension_loaded('pgsql')){ $msgPhpPgsql = 'not installed'; $error = TRUE; } /* --------------------------------------------------------------------- */ /* Write pgmt.conf.php */ /* --------------------------------------------------------------------- */ if ($error || (isset($_POST['submitBack']) && $_POST['submitBack'] != NULL)) { } else { $params['lang'] = $_SESSION['lang']; $params['version'] = $_POST['version']; $params['pgpool2_config_file'] = $pgpool2_config_file; $params['password_file'] = $password_file; $params['pcp_client_dir'] = $pcp_client_dir; $params['pcp_hostname'] = $pcp_hostname; $params['pcp_refreshTime'] = $pcp_refreshTime; $params['pg_connect_timeout'] = $pg_connect_timeout; $_SESSION['params'] = $params; } if (!$error && $action == 'next') { $fp = fopen( "../conf/pgmgt.conf.php", "w"); fputs($fp, ""."\n"); fclose($fp); header("Location: finish.php"); } /* --------------------------------------------------------------------- */ /* HTML */ /* --------------------------------------------------------------------- */ ?> <?php echo $message['strParameterCheck']; ?>

Welcome to pgpool-II Administration Tool

'; } else { echo ''; } ?>

'; } else { echo ''; } ?>

' . $msg; echo 'ng'; } else { echo 'ok'; } } /** * Get pcp commands in specified version */ function getPcpCommands() { global $version; $commands = array(); $commands[] = 'pcp_attach_node'; $commands[] = 'pcp_node_count'; $commands[] = 'pcp_proc_info'; $commands[] = 'pcp_recovery_node'; $commands[] = 'pcp_detach_node'; $commands[] = 'pcp_node_info'; $commands[] = 'pcp_proc_count'; $commands[] = 'pcp_stop_pgpool'; // 3.3 - if (3.3 <= $version) { $commands[] = 'pcp_watchdog_info'; } // 3.1 - if (3.1 <= $version) { $commands[] = 'pcp_pool_status'; $commands[] = 'pcp_promote_node'; } // - 3.4 if ($version <= 3.4) { $commands[] = 'pcp_systemdb_info'; } return $commands; }