73 $this->enable = $this->enable &&
$bearsamppConfig->getRaw( self::ROOT_CFG_ENABLE );
77 if ( $this->bearsamppConfRaw !==
false ) {
81 $this->rootUser = isset( $this->bearsamppConfRaw[self::LOCAL_CFG_ROOT_USER] ) ? $this->bearsamppConfRaw[
self::LOCAL_CFG_ROOT_USER] :
'root';
82 $this->rootPwd = isset( $this->bearsamppConfRaw[self::LOCAL_CFG_ROOT_PWD] ) ? $this->bearsamppConfRaw[
self::LOCAL_CFG_ROOT_PWD] :
'';
87 if ( !$this->enable ) {
92 if ( !is_dir( $this->currentPath ) ) {
97 if ( !is_dir( $this->symlinkPath ) ) {
102 if ( !is_file( $this->bearsamppConf ) ) {
107 if ( !is_file( $this->exe ) ) {
112 if ( !is_file( $this->conf ) ) {
117 if ( !is_numeric( $this->port ) || $this->port <= 0 ) {
122 if ( empty( $this->rootUser ) ) {
127 if ( !is_file( $this->cliExe ) ) {
132 if ( !is_file( $this->admin ) ) {
139 $this->service->setBinPath( $this->exe );
140 $this->service->setParams( self::SERVICE_NAME );
232 $fp = @fsockopen(
'127.0.0.1',
$port, $errno, $errstr, 5 );
234 if ( version_compare( phpversion(),
'5.3' ) === -1 ) {
235 $dbLink = mysqli_connect(
'127.0.0.1', $this->rootUser, $this->rootPwd,
'',
$port );
238 $dbLink = mysqli_connect(
'127.0.0.1:' .
$port, $this->rootUser, $this->rootPwd );
244 $result = mysqli_query( $dbLink,
'SHOW VARIABLES' );
246 while (
false !== ($row = mysqli_fetch_array(
$result, MYSQLI_NUM )) ) {
247 if ( $row[0] ==
'version' ) {
251 if ( $row[0] ==
'version_comment' &&
Util::startWith( strtolower( $row[1] ),
'mariadb' ) ) {
254 if ( $isMariadb &&
$version !==
false ) {
261 $bearsamppWinbinder->messageBoxWarning(
270 $bearsamppWinbinder->messageBoxInfo(
279 mysqli_close( $dbLink );
284 $bearsamppWinbinder->messageBoxWarning(
294 $bearsamppWinbinder->messageBoxError(
315 global $bearsamppWinbinder;
318 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
319 if ( version_compare( phpversion(),
'5.3' ) === -1 ) {
320 $dbLink = @mysqli_connect(
'127.0.0.1', $this->rootUser, $currentPwd,
'', $this->port );
323 $dbLink = @mysqli_connect(
'127.0.0.1:' . $this->port, $this->rootUser, $currentPwd );
326 $error = mysqli_connect_error();
329 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
330 $stmt = @mysqli_prepare( $dbLink,
'UPDATE mysql.user SET Password=PASSWORD(?) WHERE User=?' );
331 if ( empty( $error ) && $stmt ===
false ) {
332 $error = mysqli_error( $dbLink );
335 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
336 if ( empty( $error ) && !@mysqli_stmt_bind_param( $stmt,
'ss', $newPwd, $this->rootUser ) ) {
337 $error = mysqli_stmt_error( $stmt );
340 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
341 if ( empty( $error ) && !@mysqli_stmt_execute( $stmt ) ) {
342 $error = mysqli_stmt_error( $stmt );
345 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
346 if ( $stmt !==
false ) {
347 mysqli_stmt_close( $stmt );
350 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
351 if ( empty( $error ) && @mysqli_query( $dbLink,
'FLUSH PRIVILEGES' ) ===
false ) {
352 $error = mysqli_error( $dbLink );
355 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
357 mysqli_close( $dbLink );
360 if ( !empty( $error ) ) {
365 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
370 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
385 global $bearsamppWinbinder;
386 $currentPwd = $currentPwd ==
null ? $this->rootPwd : $currentPwd;
389 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
390 if ( version_compare( phpversion(),
'5.3' ) === -1 ) {
391 $dbLink = @mysqli_connect(
'127.0.0.1', $this->rootUser, $currentPwd,
'', $this->port );
394 $dbLink = @mysqli_connect(
'127.0.0.1:' . $this->port, $this->rootUser, $currentPwd );
397 $error = mysqli_connect_error();
400 $bearsamppWinbinder->incrProgressBar( $wbProgressBar );
402 mysqli_close( $dbLink );
405 if ( !empty( $error ) ) {
439 if (!$this->enable) {
444 Util::logDebug(($sub > 0 ? str_repeat(
' ', 2 * $sub) :
'') .
'Update ' . $this->name .
' ' .
$version .
' config');
454 $bearsamppWinbinder->messageBoxError(
466 $bearsamppWinbinder->messageBoxError(
479 '/^port(.*?)=(.*?)(\d+)/' =>
'port = ' . $this->port
483 $bearsamppApps->getPhpmyadmin()->update($sub + 1);
486 $bearsamppApps->getAdminer()->update($sub + 1);
507 if ($cmd == self::CMD_SYNTAX_CHECK) {
509 } elseif ($cmd == self::CMD_VARIABLES) {
518 if (file_exists($bin)) {
519 $tmpResult =
Batch::exec(
'mariadbGetCmdLineOutput',
'"' . $bin .
'" ' . $cmd .
' ' . $outputFrom, 5);
520 if ($tmpResult !==
false && is_array($tmpResult)) {
521 $result[
'syntaxOk'] = empty($tmpResult) || !
Util::contains(trim($tmpResult[count($tmpResult) - 1]),
'[ERROR]');
522 for ($i = 0; $i < $removeLines; $i++) {
523 unset($tmpResult[$i]);
525 $result[
'content'] = trim(str_replace($bin,
'', implode(PHP_EOL, $tmpResult)));
559public function setEnable($enabled, $showWindow =
false) {
565 $bearsamppWinbinder->messageBoxError(