diff --git a/gulliver/thirdparty/creole/drivers/mssql/MSSQLConnection.php b/gulliver/thirdparty/creole/drivers/mssql/MSSQLConnection.php index f3bea1b28..2ed187a73 100755 --- a/gulliver/thirdparty/creole/drivers/mssql/MSSQLConnection.php +++ b/gulliver/thirdparty/creole/drivers/mssql/MSSQLConnection.php @@ -74,13 +74,14 @@ class MSSQLConnection extends ConnectionCommon implements Connection { } else { $portDelimiter = ":"; } - - if(!empty($dsninfo['port'])) { - $dbhost .= $portDelimiter.$dsninfo['port']; - } else { - $dbhost .= $portDelimiter.'1433'; - } - + + if(!empty($dsninfo['port'])) { + $dbhost .= $portDelimiter.$dsninfo['port']; + } else { + if(!strpos($dbhost, "\\")){ + $dbhost .= $portDelimiter.'1433'; + } + } $connect_function = $persistent ? 'mssql_pconnect' : 'mssql_connect'; if ($dbhost && $user && $pw) { diff --git a/workflow/engine/classes/class.net.php b/workflow/engine/classes/class.net.php index 802923b6d..6eaf59799 100755 --- a/workflow/engine/classes/class.net.php +++ b/workflow/engine/classes/class.net.php @@ -16,6 +16,7 @@ class NET private $db_passwd; private $db_sourcename; private $db_port; + private $db_instance; /*errors handle*/ public $error; @@ -31,6 +32,7 @@ class NET { $this->errno = 0; $this->errstr = ""; + $this->db_instance = ""; unset($this->db_user); unset($this->db_passwd); @@ -52,16 +54,23 @@ class NET */ function resolv($pHost) { - if ($this->is_ipaddress($pHost)) { - $this->ip = $pHost; - if (!$this->hostname = @gethostbyaddr($pHost)) { + $aHost = explode("\\", $pHost); + if(count($aHost)>1){ + $ipHost = $aHost[0]; + $this->db_instance = $aHost[1]; + } else { + $ipHost = $pHost; + } + if ($this->is_ipaddress($ipHost)) { + $this->ip = $ipHost; + if (!$this->hostname = @gethostbyaddr($ipHost)) { $this->errno = 2000; $this->errstr = "NET::Host down"; $this->error = "Destination Host Unreachable"; } } else { - $ip = @gethostbyname($pHost); + $ip = @gethostbyname($ipHost); $long = ip2long($ip); if ( $long == -1 || $long === FALSE) { $this->errno = 2000; @@ -69,7 +78,7 @@ class NET $this->error = "Destination Host Unreachable"; } else { - $this->ip = @gethostbyname($pHost); + $this->ip = @gethostbyname($ipHost); $this->hostname = $pHost; } } @@ -219,9 +228,14 @@ class NET break; case 'mssql': - $str_port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":".$this->db_port; - $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd); - + if($this->db_instance != ""){ + $str_port = ""; + $link = @mssql_connect($this->ip . "\\". $this->db_instance, $this->db_user, $this->db_passwd); + } else { + $str_port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":".$this->db_port; + $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd); + } + if ($link) { $stat->status = 'SUCCESS'; $this->errstr = ""; @@ -339,8 +353,15 @@ class NET break; case 'mssql': - $str_port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":".$this->db_port; - $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd); +// $str_port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":".$this->db_port; +// $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd); + if($this->db_instance != ""){ + $str_port = ""; + $link = @mssql_connect($this->ip . "\\". $this->db_instance, $this->db_user, $this->db_passwd); + } else { + $str_port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":".$this->db_port; + $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd); + } if ($link) { $db = @mssql_select_db($this->db_sourcename, $link); if ($db) { diff --git a/workflow/engine/methods/dbConnections/dbConnectionsAjax.php b/workflow/engine/methods/dbConnections/dbConnectionsAjax.php index 6bd8cd076..dfb1cb664 100755 --- a/workflow/engine/methods/dbConnections/dbConnectionsAjax.php +++ b/workflow/engine/methods/dbConnections/dbConnectionsAjax.php @@ -147,6 +147,8 @@ switch ( $action ){ $oDBSource = new DbSource(); $oContent = new Content(); + if(strpos($_POST['server'], "\\")) + $_POST['port'] = 'none'; $aData = Array( 'DBS_UID' => $_POST['dbs_uid'], 'PRO_UID' => $_SESSION['PROCESS'], @@ -168,6 +170,8 @@ switch ( $action ){ $oDBSource = new DbSource(); $oContent = new Content(); + if(strpos($_POST['server'], "\\")) + $_POST['port'] = 'none'; $aData = Array( 'PRO_UID' => $_SESSION['PROCESS'], 'DBS_TYPE' => $_POST['type'], diff --git a/workflow/engine/methods/dbConnections/genericDbConnections.php b/workflow/engine/methods/dbConnections/genericDbConnections.php index f1f020a05..125e08f7e 100755 --- a/workflow/engine/methods/dbConnections/genericDbConnections.php +++ b/workflow/engine/methods/dbConnections/genericDbConnections.php @@ -13,7 +13,11 @@ if( isset($_SESSION['PROCESS']) ){ $db['DBS_PASSWORD'] = $oDbConnections->getPassWithoutEncrypt($db); $dbsPort = ($db['DBS_PORT'] == '') ? ('') : (':'.$db['DBS_PORT']); $ENCODE = (trim($db['DBS_ENCODE']) == '')? '': '?encoding=' . $db['DBS_ENCODE']; - $pro['datasources'][$db['DBS_UID']]['connection'] = $db['DBS_TYPE'] . '://' . $db['DBS_USERNAME'] . ':' . $db['DBS_PASSWORD'] . '@' . $db['DBS_SERVER'] .$dbsPort. '/' . $db['DBS_DATABASE_NAME'] . $ENCODE; + if(strpos($db['DBS_SERVER'], "\\") && $db['DBS_TYPE'] == 'mssql'){ + $pro['datasources'][$db['DBS_UID']]['connection'] = $db['DBS_TYPE'] . '://' . $db['DBS_USERNAME'] . ':' . $db['DBS_PASSWORD'] . '@' . $db['DBS_SERVER'] . '/' . $db['DBS_DATABASE_NAME'] . $ENCODE; + } else { + $pro['datasources'][$db['DBS_UID']]['connection'] = $db['DBS_TYPE'] . '://' . $db['DBS_USERNAME'] . ':' . $db['DBS_PASSWORD'] . '@' . $db['DBS_SERVER'] .$dbsPort. '/' . $db['DBS_DATABASE_NAME'] . $ENCODE; + } $pro['datasources'][$db['DBS_UID']]['adapter'] = $db['DBS_TYPE']; } return $pro;