/** * connects to the database server * * @param string $user user name * @param string $password user password * @param bool $is_controluser whether this is a control user connection * @param array $server host/port/socket/persistent * @param bool $auxiliary_connection (when true, don't go back to login if * connection fails) * * @return mixed false on error or a connection object on success */ public function connect($user, $password, $is_controluser = false, $server = null, $auxiliary_connection = false) { $error_count = $GLOBALS['error_handler']->countErrors(); $result = $this->_extension->connect($user, $password, $is_controluser, $server, $auxiliary_connection); /* Any errors from connection? */ if ($GLOBALS['error_handler']->countErrors() > $error_count) { $errors = $GLOBALS['error_handler']->sliceErrors($error_count); foreach ($errors as $error) { trigger_error($error->getMessage(), E_USER_ERROR); } } if ($result) { if (!$auxiliary_connection && !$is_controluser) { $GLOBALS['dbi']->postConnect($result); } return $result; } if ($is_controluser) { trigger_error(__('Connection for controluser as defined in your ' . 'configuration failed.'), E_USER_WARNING); return false; } // Do not go back to main login if connection failed // (currently used only in unit testing) if ($auxiliary_connection) { return false; } PMA_logUser($user, 'mysql-denied'); $GLOBALS['auth_plugin']->authFails(); return $result; }
/** * connects to the database server * * @param integer $mode Connection mode on of CONNECT_USER, CONNECT_CONTROL * or CONNECT_AUXILIARY. * @param array $server Server information like host/port/socket/persistent * * @return mixed false on error or a connection object on success */ public function connect($mode, $server = null) { list($user, $password, $server) = $this->getConnectionParams($mode, $server); if (is_null($user) || is_null($password)) { trigger_error(__('Missing connection parameters!'), E_USER_WARNING); return false; } // Do not show location and backtrace for connection errors $GLOBALS['error_handler']->setHideLocation(true); $result = $this->_extension->connect($user, $password, $server); $GLOBALS['error_handler']->setHideLocation(false); if ($result) { /* Run post connect for user connections */ if ($mode == DatabaseInterface::CONNECT_USER) { $this->postConnect($result); } return $result; } if ($mode == DatabaseInterface::CONNECT_CONTROL) { trigger_error(__('Connection for controluser as defined in your ' . 'configuration failed.'), E_USER_WARNING); return false; } else { if ($mode == DatabaseInterface::CONNECT_AUXILIARY) { // Do not go back to main login if connection failed // (currently used only in unit testing) return false; } } Logging::logUser($user, 'mysql-denied'); $GLOBALS['auth_plugin']->authFails(); return $result; }
/** * connects to the database server * * @param string $user user name * @param string $password user password * @param bool $is_controluser whether this is a control user connection * @param array $server host/port/socket/persistent * @param bool $auxiliary_connection (when true, don't go back to login if * connection fails) * * @return mixed false on error or a connection object on success */ public function connect($user, $password, $is_controluser = false, $server = null, $auxiliary_connection = false) { // Do not show location and backtrace for connection errors $GLOBALS['error_handler']->setHideLocation(true); $result = $this->_extension->connect($user, $password, $is_controluser, $server, $auxiliary_connection); $GLOBALS['error_handler']->setHideLocation(false); if ($result) { if (!$auxiliary_connection && !$is_controluser) { $GLOBALS['dbi']->postConnect($result); } return $result; } if ($is_controluser) { trigger_error(__('Connection for controluser as defined in your ' . 'configuration failed.'), E_USER_WARNING); return false; } // Do not go back to main login if connection failed // (currently used only in unit testing) if ($auxiliary_connection) { return false; } PMA_logUser($user, 'mysql-denied'); $GLOBALS['auth_plugin']->authFails(); return $result; }
/** * connects to the database server * * @param string $user user name * @param string $password user password * @param bool $is_controluser whether this is a control user connection * @param array $server host/port/socket/persistent * @param bool $auxiliary_connection (when true, don't go back to login if * connection fails) * * @return mixed false on error or a connection object on success */ public function connect($user, $password, $is_controluser = false, $server = null, $auxiliary_connection = false) { $result = $this->_extension->connect($user, $password, $is_controluser, $server, $auxiliary_connection); if ($result) { if (!$auxiliary_connection && !$is_controluser) { $GLOBALS['dbi']->postConnect($result); } return $result; } if ($is_controluser) { trigger_error(__('Connection for controluser as defined in your ' . 'configuration failed.'), E_USER_WARNING); return false; } // we could be calling $GLOBALS['dbi']->connect() to connect to another // server, for example in the Synchronize feature, so do not // go back to main login if it fails if ($auxiliary_connection) { return false; } PMA_logUser($user, 'mysql-denied'); $GLOBALS['auth_plugin']->authFails(); return $result; }