78 $this->enable = $this->enable &&
$bearsamppConfig->getRaw( self::ROOT_CFG_ENABLE );
80 $this->errorLog =
$bearsamppRoot->getLogsPath() .
'/postgresql.log';
82 if ( $this->bearsamppConfRaw !==
false ) {
83 $this->ctlExe = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CTL_EXE];
84 $this->cliExe = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CLI_EXE];
85 $this->dumpExe = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_DUMP_EXE];
86 $this->dumpAllExe = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_DUMP_ALL_EXE];
87 $this->conf = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_CONF];
88 $this->hbaConf = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_HBA_CONF];
89 $this->altConf = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_ALT_CONF];
90 $this->altHbaConf = $this->symlinkPath .
'/' . $this->bearsamppConfRaw[self::LOCAL_CFG_ALT_HBA_CONF];
91 $this->port = $this->bearsamppConfRaw[self::LOCAL_CFG_PORT];
92 $this->rootUser = isset( $this->bearsamppConfRaw[self::LOCAL_CFG_ROOT_USER] ) ? $this->bearsamppConfRaw[self::LOCAL_CFG_ROOT_USER] :
'postgres';
93 $this->rootPwd = isset( $this->bearsamppConfRaw[self::LOCAL_CFG_ROOT_PWD] ) ? $this->bearsamppConfRaw[self::LOCAL_CFG_ROOT_PWD] :
'';
96 if ( !$this->enable ) {
101 if ( !is_dir( $this->currentPath ) ) {
106 if ( !is_dir( $this->symlinkPath ) ) {
111 if ( !is_file( $this->bearsamppConf ) ) {
116 if ( !file_exists( $this->conf ) ) {
119 if ( !file_exists( $this->hbaConf ) ) {
123 if ( !is_file( $this->ctlExe ) ) {
128 if ( !is_file( $this->cliExe ) ) {
133 if ( !is_file( $this->dumpExe ) ) {
138 if ( !is_file( $this->dumpAllExe ) ) {
143 if ( !is_file( $this->conf ) ) {
148 if ( !is_file( $this->hbaConf ) ) {
153 if ( !is_numeric( $this->port ) || $this->port <= 0 ) {
158 if ( empty( $this->rootUser ) ) {
165 $this->service->setBinPath( $this->ctlExe );
177 $content = file_get_contents( $this->bearsamppConf );
179 foreach ( $params as $key => $value ) {
180 $content = preg_replace(
'|' . $key .
' = .*|', $key .
' = ' .
'"' . $value .
'"', $content );
181 $this->bearsamppConfRaw[$key] = $value;
183 case self::LOCAL_CFG_PORT:
184 $this->port = $value;
186 case self::LOCAL_CFG_ROOT_USER:
187 $this->rootUser = $value;
189 case self::LOCAL_CFG_ROOT_PWD:
190 $this->rootPwd = $value;
195 file_put_contents( $this->bearsamppConf, $content );
317 global $bearsamppWinbinder;
320 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
321 $dbLink = pg_connect(
'host=127.0.0.1 port=' . $this->port .
' user=' . $this->rootUser .
' password=' . $currentPwd );
324 $error = pg_last_error( $dbLink );
327 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
328 $pgr = pg_query_params( $dbLink,
'SELECT quote_ident($1)', array(pg_escape_string( $this->rootUser )) );
329 list( $quoted_user ) = pg_fetch_array( $pgr );
330 $password = pg_escape_string( $newPwd );
331 $result = pg_query( $dbLink,
"ALTER USER $quoted_user WITH PASSWORD '$password'" );
332 if ( empty( $error ) && !
$result ) {
333 $error = pg_last_error( $dbLink );
336 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
341 if ( !empty( $error ) ) {
346 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
351 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
366 global $bearsamppWinbinder;
367 $currentPwd = $currentPwd ==
null ? $this->rootPwd : $currentPwd;
370 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
371 $dbLink = pg_connect(
'host=127.0.0.1 port=' . $this->port .
' user=' . $this->rootUser .
' password=' . $currentPwd );
373 $error = pg_last_error( $dbLink );
376 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
381 if ( !empty( $error ) ) {
416 if ( !$this->enable ) {
421 Util::logDebug( ($sub > 0 ? str_repeat(
' ', 2 * $sub ) :
'') .
'Update ' . $this->name .
' ' .
$version .
' config' );
436 $bearsamppWinbinder->messageBoxError(
449 $bearsamppWinbinder->messageBoxError(
463 '/^port(.*?)=(.*?)(\d+)/' =>
'port = ' . $this->port
467 $bearsamppApps->getPhppgadmin()->update( $sub + 1 );