Initialize connection params

@param string $host
@param string $user
@param string $password
@param int $port
@param int $timeout (seconds)
169433
public static function forge($host = null, $user = null, $password = null, $port = 21, $timeout = 90)
        {
            static::$_host = $host;
            static::$_user = $user;
            static::$_pwd = $password;
            static::$_port = (int)$port;
            static::$_timeout = (int)$timeout;

            if(!static::$instance) {
                static::$instance = new self();
            }

            return static::$instance;
        }
1164620
protected function setHost($host, $port = null)
    {
        $this->host = $host;
        if ($port !== null) {
            if (is_numeric($port)) {
                $this->port = (int) $port;
            } else {
                throw new ConfigurationException("Port '{$port}' is not numeric");
            }
        }
    }
1056292
private void initializeConnection(String user, String password, String restApiBaseUrl) {
		csrfToken = null;
		cookies = new HashMap<String, Cookie>();
		
		connection = ClientHelper.createClient().register(HttpAuthenticationFeature.basic(user, password)).target(restApiBaseUrl);
	}
533179
function _connect( $host, $username, $password, $ldapbase)
	{
		global $LDAP_CONNECT_OPTIONS;

		if ( !function_exists( 'ldap_connect' ) ) return null;

		if (strpos($host,'ldap://') === 0 || strpos($host,'ldaps://') === 0) {
			$this->_connectionID = @ldap_connect($host);
		} else {
			$conn_info = array( $host,$this->port);

			if ( strstr( $host, ':' ) ) {
				$conn_info = explode( ':', $host );
			}

			$this->_connectionID = @ldap_connect( $conn_info[0], $conn_info[1] );
		}
		if (!$this->_connectionID) {
			$e = 'Could not connect to ' . $conn_info[0];
			$this->_errorMsg = $e;
			if ($this->debug) ADOConnection::outp($e);
			return false;
		}
		if( count( $LDAP_CONNECT_OPTIONS ) > 0 ) {
			$this->_inject_bind_options( $LDAP_CONNECT_OPTIONS );
		}

		if ($username) {
			$bind = @ldap_bind( $this->_connectionID, $username, $password );
		} else {
			$username = 'anonymous';
			$bind = @ldap_bind( $this->_connectionID );
		}

		if (!$bind) {
			$e = sprintf($this->_bind_errmsg,ldap_error($this->_connectionID));
			$this->_errorMsg = $e;
			if ($this->debug) ADOConnection::outp($e);
			return false;
		}
		$this->_errorMsg = '';
		$this->database = $ldapbase;
		return $this->_connectionID;
	}
1162963
private function _openConnection($user = 'anonymous', $password = '')
    {
        $this->_closeConnection();   // Close connection if already open
        if ($this->isSFTP()) {
            $this->sftpConnect($user, $password);
        } else {
            $this->ftpConnect($user, $password);
        }
        $pwd = $this->grabDirectory();
        $this->path = $pwd . ($pwd == '/' ? '' : DIRECTORY_SEPARATOR);
    }
567737
public function connect($host, $user, $password, $database, $newLink = false)
    {
        if (!$this->pdo) {
            try {
                $this->pdo = $this->getAdapter()->connect($host, $user, $password, $database, $newLink);
                $this->setDatabase($database);
            } catch (Exception $e) {
                $e->log();
            }
        }

        return $this;
    }
1046976
function init($host, $port, $path, $user, $pass)
    {
        $headers = array(
            sprintf("HTTP_AUTH_LOGIN: %s", $user),
            sprintf("HTTP_AUTH_PASSWD: %s", $pass),
            "Content-Type: text/xml"
        );

        $url        = sprintf("https://%s:%s/%s", $host, $port, $path);
        $this->curl = curl_init();

        curl_setopt($this->curl, CURLOPT_CONNECTTIMEOUT , 5);
        curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST , 0);
        curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER , false);
        curl_setopt($this->curl, CURLOPT_HTTPHEADER     , $headers);
        curl_setopt($this->curl, CURLOPT_URL            , $url);
    }
1330114
function connect($host, $port, $timeout = 0.1, $nonblock = false)
    {
        //判断超时为0或负数
        if (empty($host) or empty($port) or $timeout <= 0)
        {
            $this->errCode = -10001;
            $this->errMsg = "param error";
            return false;
        }
        $this->host = $host;
        $this->port = $port;
        //创建socket
        $this->sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        if ($this->sock === false)
        {
            $this->set_error();
            return false;
        }
        //设置connect超时
        $this->set_timeout($timeout, $timeout);
        $this->setopt(SO_REUSEADDR, 1);
        //非阻塞模式下connect将立即返回
        if ($nonblock)
        {
            socket_set_nonblock($this->sock);
            @socket_connect($this->sock, $this->host, $this->port);
            return true;
        }
        else
        {
            //这里的错误信息没有任何意义，所以屏蔽掉
            if (@socket_connect($this->sock, $this->host, $this->port))
            {
                $this->connected = true;
                return true;
            }
            elseif ($this->try_reconnect)
            {
                if (@socket_connect($this->sock, $this->host, $this->port))
                {
                    $this->connected = true;
                    return true;
                }
            }
        }
        $this->set_error();
        trigger_error("connect server[{$this->host}:{$this->port}] fail. Error: {$this->errMsg}[{$this->errCode}].");
        return false;
    }
1337125
public static function sslConnect($host, $user, $password, $name, $key, $cert, $ca)
    {
        if ($key == "" || $cert == "" || $ca == "") {
            throw new MysqlUtilsException("SSL parameters error");
        }

        $mysqliRef = mysqli_init();
        $mysqliRef->ssl_set($key, $cert, $ca, null, null);

        $connected = @$mysqliRef->real_connect($host,
            $user,
            $password,
            $name,
            3306,
            null,
            MYSQLI_CLIENT_SSL);

        if (!$connected || $mysqliRef->connect_error) {
            throw new MysqlUtilsException('Database connection error ('.$mysqliRef->connect_errno.') '.$mysqliRef->connect_error);
        }

        return $mysqliRef;
    }
893686
public function connect($server,$user,$password,$database){
		if(empty($this->database_info['server']) || $this->database_info['server']==''){
			$this->database_info['server'] = $server;
		}
		if(empty($this->database_info['user']) || $this->database_info['user']==''){
			$this->database_info['user'] = $user;
		}
		if(empty($this->database_info['pass']) || $this->database_info['pass']==''){
			$this->database_info['pass'] = $password;
		}
		if(empty($this->database_info['database']) || $this->database_info['database']==''){
			$this->database_info['database'] = $database;
		}

		mysql_connect(
		$this->database_info['server'],
		$this->database_info['user'],
		$this->database_info['pass']
		);
		@mysql_select_db($this->database_info['database']) or die("Unable to connect to ".$this->database_info['database']." database.");
	}
305434
public function checkPermission($host, $context)
    {
        if (!is_string($host)) {
            throw new \TypeError('The host parameter must be a string.');
        }
        if (!$host) {
            throw new \InvalidArgumentException('The host parameter cannot be empty.');
        }

        $currentRequest = $this->requestStack->getCurrentRequest();

        if (!$currentRequest) {
            return false;
        }

        return !!preg_match('{'.$host.'}i', $currentRequest->getHost());
    }
446331
public function connect($host = null, $port = null)
    {
        return $this->driver->connect(
            $host ? $host : $this->host,
            $port ? $port : $this->port
        );
    }
46657
public function connect($host = false, $user = false, $password = false, $database = false, $newLink = false)
    {
        $this->connection = mysqli_connect($host, $user, $password, $newLink);

        if ($this->connection) {
            if ($this->selectDatabase($database)) {
                $this->query("SET CHARACTER SET utf8");
                $this->query("SET NAMES utf8");
                return $this->connection;
            } else {
                $message = 'Cannot select database ' . $database;
            }
        } else {
            $message = mysqli_error($this->connection);
        }

        if (!$this->connection) {
            trigger_error($message, E_USER_WARNING);
        }
    }
1332985
public function addConnection($host, $user, $pass, $dbname, $charset = 'utf8', $name = null)
  {
    $this->connections[$name ?: 'default'] = array(
      'pdo'     => false,
      'host'    => $host,
      'user'    => $user,
      'pass'    => $pass,
      'db'      => $dbname,
      'charset' => $charset
    );

    return $this;
  }
261252
public static void configureExample(String host, int port, String user, String password, Authentication authType)
    throws IOException, ResourceNotFoundException, ForbiddenUserException, FailedRequestException, ResourceNotResendableException
  {
    // create the client
    DatabaseClient client = DatabaseClientFactory.newClient(host, port, user, password, authType);

    installResourceExtension(client);

    configureQueryOptions(client);

    setUpExample(client);

    // release the client
    client.release();
  }
234105
static function create($user, $host)
    {
        $user_name  = '';
        $user_email = '';
        $rcube      = rcube::get_instance();
        $dbh        = $rcube->get_dbh();

        // try to resolve user in virtuser table and file
        if ($email_list = self::user2email($user, false, true)) {
            $user_email = is_array($email_list[0]) ? $email_list[0]['email'] : $email_list[0];
        }

        $data = $rcube->plugins->exec_hook('user_create', array(
            'host'       => $host,
            'user'       => $user,
            'user_name'  => $user_name,
            'user_email' => $user_email,
            'email_list' => $email_list,
            'language'   =>  $_SESSION['language'],
        ));

        // plugin aborted this operation
        if ($data['abort']) {
            return false;
        }

        $insert = $dbh->query(
            "INSERT INTO ".$dbh->table_name('users', true).
            " (`created`, `last_login`, `username`, `mail_host`, `language`)".
            " VALUES (".$dbh->now().", ".$dbh->now().", ?, ?, ?)",
            $data['user'],
            $data['host'],
            $data['language']);

        if ($dbh->affected_rows($insert) && ($user_id = $dbh->insert_id('users'))) {
            // create rcube_user instance to make plugin hooks work
            $user_instance = new rcube_user($user_id, array(
                'user_id'   => $user_id,
                'username'  => $data['user'],
                'mail_host' => $data['host'],
                'language'  => $data['language'],
            ));
            $rcube->user = $user_instance;
            $mail_domain = $rcube->config->mail_domain($data['host']);
            $user_name   = $data['user_name'];
            $user_email  = $data['user_email'];
            $email_list  = $data['email_list'];

            if (empty($email_list)) {
                if (empty($user_email)) {
                    $user_email = strpos($data['user'], '@') ? $user : sprintf('%s@%s', $data['user'], $mail_domain);
                }
                $email_list[] = $user_email;
            }
            // identities_level check
            else if (count($email_list) > 1 && $rcube->config->get('identities_level', 0) > 1) {
                $email_list = array($email_list[0]);
            }

            if (empty($user_name)) {
                $user_name = $data['user'];
            }

            // create new identities records
            $standard = 1;
            foreach ($email_list as $row) {
                $record = array();

                if (is_array($row)) {
                    if (empty($row['email'])) {
                        continue;
                    }
                    $record = $row;
                }
                else {
                    $record['email'] = $row;
                }

                if (empty($record['name'])) {
                    $record['name'] = $user_name != $record['email'] ? $user_name : '';
                }

                $record['user_id']  = $user_id;
                $record['standard'] = $standard;

                $plugin = $rcube->plugins->exec_hook('identity_create',
                    array('login' => true, 'record' => $record));

                if (!$plugin['abort'] && $plugin['record']['email']) {
                    $rcube->user->insert_identity($plugin['record']);
                }
                $standard = 0;
            }
        }
        else {
            rcube::raise_error(array(
                'code' => 500,
                'type' => 'php',
                'line' => __LINE__,
                'file' => __FILE__,
                'message' => "Failed to create new user"), true, false);
        }

        return $user_id ? $user_instance : false;
    }
1254463
public static function mysql($host, $database, $user, $password, $prefix = null)
    {
        if (is_null($prefix)) {
            $prefixing = 'false';
            $prefix = 'ysf';
        } else {
            $prefixing = 'true';
        }
        //
        $content = Database::set('mysql', $host, $database, $user, $password, $prefixing, $prefix);
        //
        file_put_contents(Application::$root.'config/database.php', $content, 0);
        //
        return true;
    }