Merge branch '2.0-dev' of git.colosa.net:/processmaker into 2.0-dev

This commit is contained in:
Julio Cesar Laura
2011-11-08 17:38:43 -04:00
4 changed files with 48 additions and 18 deletions

View File

@@ -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) {

View File

@@ -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'],

View File

@@ -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;