Merge pull request #2417 from luisfernandosl/BUG-14056-3

BUG 14056 "Oracle Connection Parameters with TNS" SOLVED
This commit is contained in:
julceslauhub
2014-05-22 16:51:55 -04:00
19 changed files with 705 additions and 286 deletions

View File

@@ -74,6 +74,8 @@ class dbConnections
$c->addSelectColumn( DbSourcePeer::DBS_PASSWORD );
$c->addSelectColumn( DbSourcePeer::DBS_PORT );
$c->addSelectColumn( DbSourcePeer::DBS_ENCODE );
$c->addSelectColumn(DbSourcePeer::DBS_CONNECTION_TYPE);
$c->addSelectColumn(DbSourcePeer::DBS_TNS);
$c->addSelectColumn( ContentPeer::CON_VALUE );
$c->add( DbSourcePeer::PRO_UID, $this->PRO_UID );
@@ -85,8 +87,20 @@ class dbConnections
$row = $result->getRow();
while ($row = $result->getRow()) {
$connections[] = Array ('DBS_UID' => $row[0],'DBS_TYPE' => $row[2],'DBS_SERVER' => $row[3],'DBS_DATABASE_NAME' => $row[4],'DBS_USERNAME' => $row[5],'DBS_PASSWORD' => $row[6],'DBS_PORT' => $row[7],'DBS_ENCODE' => $row[8],'CON_VALUE' => $row[9]
$connections[] = array (
"DBS_UID" => $row[0],
"DBS_TYPE" => $row[2],
"DBS_SERVER" => $row[3],
"DBS_DATABASE_NAME" => $row[4],
"DBS_USERNAME" => $row[5],
"DBS_PASSWORD" => $row[6],
"DBS_PORT" => $row[7],
"DBS_ENCODE" => $row[8],
"DBS_CONNECTION_TYPE" => $row[9],
"DBS_TNS" => $row[10],
"CON_VALUE" => $row[11]
);
$result->next();
}
if (! in_array( $row[2], $types )) {
@@ -424,8 +438,14 @@ class dbConnections
if ($aInfoCon['DBS_PASSWORD'] != '') {
$aPassw = explode( '_', $aInfoCon['DBS_PASSWORD'] );
$passw = $aPassw[0];
if (sizeof( $aPassw ) > 1)
$passw = ($passw == 'none') ? "" : G::decrypt( $passw, $aInfoCon['DBS_DATABASE_NAME'] );
$flagTns = ($aInfoCon["DBS_TYPE"] == "oracle" && $aInfoCon["DBS_CONNECTION_TYPE"] == "TNS")? 1 : 0;
if (sizeof($aPassw) > 1 && $flagTns == 0) {
$passw = ($passw == "none")? "" : G::decrypt($passw, $aInfoCon["DBS_DATABASE_NAME"]);
} else {
$passw = ($passw == "none")? "" : G::decrypt($passw, $aInfoCon["DBS_TNS"]);
}
}
return $passw;
}

View File

@@ -25,13 +25,34 @@ class NET
public $errno;
public $errstr;
public function __construct()
{
$a = func_get_args();
$f = "__construct" . func_num_args();
if (method_exists($this, $f)) {
call_user_func_array(array($this, $f), $a);
}
}
/**
* This function is the constructor of the class net
*
* return void
*/
public function __construct0()
{
$this->errno = 0;
$this->error = "";
}
/**
* This function is the constructor of the class net
*
* @param string $pHost
* @return void
*/
public function __construct ($pHost)
public function __construct1($pHost)
{
$this->errno = 0;
$this->errstr = "";
@@ -181,16 +202,20 @@ class NET
* This function tries to connect to server
*
* @param string $pDbDriver
* @param array $arrayServerData
*
* @return void
*/
public function tryConnectServer ($pDbDriver)
public function tryConnectServer($pDbDriver, array $arrayServerData = array())
{
if ($this->errno != 0) {
return 0;
}
$stat = new Stat();
if (isset( $this->db_user ) && (isset( $this->db_passwd ) || ('' == $this->db_passwd)) && isset( $this->db_sourcename )) {
$flagTns = (isset($arrayServerData["connectionType"]) && $arrayServerData["connectionType"] == "TNS")? 1 : 0;
if (isset($this->db_user) && (isset($this->db_passwd) || $this->db_passwd == "") && (isset($this->db_sourcename) || $flagTns == 1)) {
switch ($pDbDriver) {
case 'mysql':
if ($this->db_passwd == '') {
@@ -247,11 +272,17 @@ class NET
}
break;
case 'oracle':
$this->db_port = (($this->db_port == "") || ($this->db_port == 0)) ? "1521" : $this->db_port;
try {
$link = $conn = @oci_connect( $this->db_user, $this->db_passwd, "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=$this->ip) (PORT=$this->db_port) )) (CONNECT_DATA=(SERVICE_NAME=$this->db_sourcename)))" );
if ($link) {
$stat->status = 'SUCCESS';
if ($flagTns == 0) {
$this->db_port = ($this->db_port == "" || $this->db_port == 0)? "1521" : $this->db_port;
$cnn = @oci_connect($this->db_user, $this->db_passwd, "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=$this->ip) (PORT=$this->db_port) )) (CONNECT_DATA=(SERVICE_NAME=$this->db_sourcename)))");
} else {
$cnn = @oci_connect($this->db_user, $this->db_passwd, $arrayServerData["tns"]);
}
if ($cnn) {
$stat->status = "SUCCESS";
$this->errstr = "";
$this->errno = 0;
} else {
@@ -279,9 +310,11 @@ class NET
* This function tries to open to the DB
*
* @param string $pDbDriver
* @param array $arrayServerData
*
* @return void
*/
public function tryOpenDataBase ($pDbDriver)
public function tryOpenDataBase($pDbDriver, array $arrayServerData = array())
{
if ($this->errno != 0) {
return 0;
@@ -290,7 +323,9 @@ class NET
set_time_limit( 0 );
$stat = new Stat();
if (isset( $this->db_user ) && (isset( $this->db_passwd ) || ('' == $this->db_passwd)) && isset( $this->db_sourcename )) {
$flagTns = (isset($arrayServerData["connectionType"]) && $arrayServerData["connectionType"] == "TNS")? 1 : 0;
if (isset($this->db_user) && (isset($this->db_passwd) || $this->db_passwd == "") && (isset($this->db_sourcename) || $flagTns == 1)) {
switch ($pDbDriver) {
case 'mysql':
$link = @mysql_connect( $this->ip . (($this->db_port != '') && ($this->db_port != 0) ? ':' . $this->db_port : ''), $this->db_user, $this->db_passwd );
@@ -366,16 +401,22 @@ class NET
}
break;
case 'oracle':
$this->db_port = (($this->db_port == "") || ($this->db_port == 0)) ? "1521" : $this->db_port;
$link = @oci_connect( $this->db_user, $this->db_passwd, "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=$this->ip) (PORT=$this->db_port) )) (CONNECT_DATA=(SERVICE_NAME=$this->db_sourcename)))" );
if ($link) {
$stid = @oci_parse( $link, 'select AUTHENTICATION_TYPE from v$session_connect_info' );
if ($flagTns == 0) {
$this->db_port = ($this->db_port == "" || $this->db_port == 0)? "1521" : $this->db_port;
$cnn = @oci_connect($this->db_user, $this->db_passwd, "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=$this->ip) (PORT=$this->db_port) )) (CONNECT_DATA=(SERVICE_NAME=$this->db_sourcename)))");
} else {
$cnn = @oci_connect($this->db_user, $this->db_passwd, $arrayServerData["tns"]);
}
if ($cnn) {
$stid = @oci_parse($cnn, 'select AUTHENTICATION_TYPE from v$session_connect_info');
$result = @oci_execute( $stid, OCI_DEFAULT );
if ($result) {
$stat->status = 'SUCCESS';
$this->errstr = "";
$this->errno = 0;
@oci_close( $link );
@oci_close($cnn);
} else {
$this->error = "the user $this->db_user doesn't have privileges to run queries!";
$this->errstr = "NET::ORACLE->Couldn't execute any query on this server!";

View File

@@ -710,8 +710,8 @@ function getEngineDataBaseName ($connection)
*/
function executeQueryOci ($sql, $connection, $aParameter = array())
{
$aDNS = $connection->getDSN();
$sUsername = $aDNS["username"];
$sPassword = $aDNS["password"];
$sHostspec = $aDNS["hostspec"];
@@ -719,8 +719,14 @@ function executeQueryOci ($sql, $connection, $aParameter = array())
$sPort = $aDNS["port"];
if ($sPort != "1521") {
// if not default port
$conn = oci_connect( $sUsername, $sPassword, $sHostspec . ":" . $sPort . "/" . $sDatabse );
$flagTns = ($sDatabse == "" && ($sPort . "" == "" || $sPort . "" == "0"))? 1 : 0;
if ($flagTns == 0) {
// if not default port
$conn = oci_connect($sUsername, $sPassword, $sHostspec . ":" . $sPort . "/" . $sDatabse);
} else {
$conn = oci_connect($sUsername, $sPassword, $sHostspec);
}
} else {
$conn = oci_connect( $sUsername, $sPassword, $sHostspec . "/" . $sDatabse );
}
@@ -734,6 +740,7 @@ function executeQueryOci ($sql, $connection, $aParameter = array())
switch (true) {
case preg_match( "/^(SELECT|SHOW|DESCRIBE|DESC|WITH)\s/i", $sql ):
$stid = oci_parse( $conn, $sql );
if (count( $aParameter ) > 0) {
foreach ($aParameter as $key => $val) {
oci_bind_by_name( $stid, $key, $val );

View File

@@ -68,8 +68,8 @@ class DbSource extends BaseDbSource
$oCriteria->addSelectColumn(DbSourcePeer::DBS_UID);
$oCriteria->addSelectColumn(DbSourcePeer::PRO_UID);
$oCriteria->addSelectColumn(DbSourcePeer::DBS_TYPE);
$oCriteria->addSelectColumn(DbSourcePeer::DBS_SERVER);
$oCriteria->addSelectColumn(DbSourcePeer::DBS_DATABASE_NAME);
$oCriteria->addAsColumn("DBS_SERVER", "CASE WHEN " . DbSourcePeer::DBS_TYPE . " = 'oracle' AND " . DbSourcePeer::DBS_CONNECTION_TYPE . " = 'TNS' THEN CONCAT('[', " . DbSourcePeer::DBS_TNS . ", ']') ELSE " . DbSourcePeer::DBS_SERVER . " END");
$oCriteria->addAsColumn("DBS_DATABASE_NAME", "CASE WHEN " . DbSourcePeer::DBS_TYPE . " = 'oracle' AND " . DbSourcePeer::DBS_CONNECTION_TYPE . " = 'TNS' THEN CONCAT('[', " . DbSourcePeer::DBS_TNS . ", ']') ELSE " . DbSourcePeer::DBS_DATABASE_NAME . " END");
$oCriteria->addSelectColumn(DbSourcePeer::DBS_USERNAME);
$oCriteria->addSelectColumn(DbSourcePeer::DBS_PASSWORD);
$oCriteria->addSelectColumn(DbSourcePeer::DBS_PORT);

View File

@@ -83,6 +83,10 @@ class DbSourceMapBuilder
$tMap->addColumn('DBS_ENCODE', 'DbsEncode', 'string', CreoleTypes::VARCHAR, false, 32);
$tMap->addColumn('DBS_CONNECTION_TYPE', 'DbsConnectionType', 'string', CreoleTypes::VARCHAR, false, 32);
$tMap->addColumn('DBS_TNS', 'DbsTns', 'string', CreoleTypes::VARCHAR, false, 256);
} // doBuild()
} // DbSourceMapBuilder

View File

@@ -81,6 +81,18 @@ abstract class BaseDbSource extends BaseObject implements Persistent
*/
protected $dbs_encode = '';
/**
* The value for the dbs_connection_type field.
* @var string
*/
protected $dbs_connection_type = 'NORMAL';
/**
* The value for the dbs_tns field.
* @var string
*/
protected $dbs_tns = '';
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
@@ -194,6 +206,28 @@ abstract class BaseDbSource extends BaseObject implements Persistent
return $this->dbs_encode;
}
/**
* Get the [dbs_connection_type] column value.
*
* @return string
*/
public function getDbsConnectionType()
{
return $this->dbs_connection_type;
}
/**
* Get the [dbs_tns] column value.
*
* @return string
*/
public function getDbsTns()
{
return $this->dbs_tns;
}
/**
* Set the value of [dbs_uid] column.
*
@@ -392,6 +426,50 @@ abstract class BaseDbSource extends BaseObject implements Persistent
} // setDbsEncode()
/**
* Set the value of [dbs_connection_type] column.
*
* @param string $v new value
* @return void
*/
public function setDbsConnectionType($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->dbs_connection_type !== $v || $v === 'NORMAL') {
$this->dbs_connection_type = $v;
$this->modifiedColumns[] = DbSourcePeer::DBS_CONNECTION_TYPE;
}
} // setDbsConnectionType()
/**
* Set the value of [dbs_tns] column.
*
* @param string $v new value
* @return void
*/
public function setDbsTns($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->dbs_tns !== $v || $v === '') {
$this->dbs_tns = $v;
$this->modifiedColumns[] = DbSourcePeer::DBS_TNS;
}
} // setDbsTns()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
@@ -427,12 +505,16 @@ abstract class BaseDbSource extends BaseObject implements Persistent
$this->dbs_encode = $rs->getString($startcol + 8);
$this->dbs_connection_type = $rs->getString($startcol + 9);
$this->dbs_tns = $rs->getString($startcol + 10);
$this->resetModified();
$this->setNew(false);
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 9; // 9 = DbSourcePeer::NUM_COLUMNS - DbSourcePeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 11; // 11 = DbSourcePeer::NUM_COLUMNS - DbSourcePeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating DbSource object", $e);
@@ -663,6 +745,12 @@ abstract class BaseDbSource extends BaseObject implements Persistent
case 8:
return $this->getDbsEncode();
break;
case 9:
return $this->getDbsConnectionType();
break;
case 10:
return $this->getDbsTns();
break;
default:
return null;
break;
@@ -692,6 +780,8 @@ abstract class BaseDbSource extends BaseObject implements Persistent
$keys[6] => $this->getDbsPassword(),
$keys[7] => $this->getDbsPort(),
$keys[8] => $this->getDbsEncode(),
$keys[9] => $this->getDbsConnectionType(),
$keys[10] => $this->getDbsTns(),
);
return $result;
}
@@ -750,6 +840,12 @@ abstract class BaseDbSource extends BaseObject implements Persistent
case 8:
$this->setDbsEncode($value);
break;
case 9:
$this->setDbsConnectionType($value);
break;
case 10:
$this->setDbsTns($value);
break;
} // switch()
}
@@ -809,6 +905,14 @@ abstract class BaseDbSource extends BaseObject implements Persistent
$this->setDbsEncode($arr[$keys[8]]);
}
if (array_key_exists($keys[9], $arr)) {
$this->setDbsConnectionType($arr[$keys[9]]);
}
if (array_key_exists($keys[10], $arr)) {
$this->setDbsTns($arr[$keys[10]]);
}
}
/**
@@ -856,6 +960,14 @@ abstract class BaseDbSource extends BaseObject implements Persistent
$criteria->add(DbSourcePeer::DBS_ENCODE, $this->dbs_encode);
}
if ($this->isColumnModified(DbSourcePeer::DBS_CONNECTION_TYPE)) {
$criteria->add(DbSourcePeer::DBS_CONNECTION_TYPE, $this->dbs_connection_type);
}
if ($this->isColumnModified(DbSourcePeer::DBS_TNS)) {
$criteria->add(DbSourcePeer::DBS_TNS, $this->dbs_tns);
}
return $criteria;
}
@@ -936,6 +1048,10 @@ abstract class BaseDbSource extends BaseObject implements Persistent
$copyObj->setDbsEncode($this->dbs_encode);
$copyObj->setDbsConnectionType($this->dbs_connection_type);
$copyObj->setDbsTns($this->dbs_tns);
$copyObj->setNew(true);

View File

@@ -25,7 +25,7 @@ abstract class BaseDbSourcePeer
const CLASS_DEFAULT = 'classes.model.DbSource';
/** The total number of columns. */
const NUM_COLUMNS = 9;
const NUM_COLUMNS = 11;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@@ -58,6 +58,12 @@ abstract class BaseDbSourcePeer
/** the column name for the DBS_ENCODE field */
const DBS_ENCODE = 'DB_SOURCE.DBS_ENCODE';
/** the column name for the DBS_CONNECTION_TYPE field */
const DBS_CONNECTION_TYPE = 'DB_SOURCE.DBS_CONNECTION_TYPE';
/** the column name for the DBS_TNS field */
const DBS_TNS = 'DB_SOURCE.DBS_TNS';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
@@ -69,10 +75,10 @@ abstract class BaseDbSourcePeer
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbsUid', 'ProUid', 'DbsType', 'DbsServer', 'DbsDatabaseName', 'DbsUsername', 'DbsPassword', 'DbsPort', 'DbsEncode', ),
BasePeer::TYPE_COLNAME => array (DbSourcePeer::DBS_UID, DbSourcePeer::PRO_UID, DbSourcePeer::DBS_TYPE, DbSourcePeer::DBS_SERVER, DbSourcePeer::DBS_DATABASE_NAME, DbSourcePeer::DBS_USERNAME, DbSourcePeer::DBS_PASSWORD, DbSourcePeer::DBS_PORT, DbSourcePeer::DBS_ENCODE, ),
BasePeer::TYPE_FIELDNAME => array ('DBS_UID', 'PRO_UID', 'DBS_TYPE', 'DBS_SERVER', 'DBS_DATABASE_NAME', 'DBS_USERNAME', 'DBS_PASSWORD', 'DBS_PORT', 'DBS_ENCODE', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
BasePeer::TYPE_PHPNAME => array ('DbsUid', 'ProUid', 'DbsType', 'DbsServer', 'DbsDatabaseName', 'DbsUsername', 'DbsPassword', 'DbsPort', 'DbsEncode', 'DbsConnectionType', 'DbsTns', ),
BasePeer::TYPE_COLNAME => array (DbSourcePeer::DBS_UID, DbSourcePeer::PRO_UID, DbSourcePeer::DBS_TYPE, DbSourcePeer::DBS_SERVER, DbSourcePeer::DBS_DATABASE_NAME, DbSourcePeer::DBS_USERNAME, DbSourcePeer::DBS_PASSWORD, DbSourcePeer::DBS_PORT, DbSourcePeer::DBS_ENCODE, DbSourcePeer::DBS_CONNECTION_TYPE, DbSourcePeer::DBS_TNS, ),
BasePeer::TYPE_FIELDNAME => array ('DBS_UID', 'PRO_UID', 'DBS_TYPE', 'DBS_SERVER', 'DBS_DATABASE_NAME', 'DBS_USERNAME', 'DBS_PASSWORD', 'DBS_PORT', 'DBS_ENCODE', 'DBS_CONNECTION_TYPE', 'DBS_TNS', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
);
/**
@@ -82,10 +88,10 @@ abstract class BaseDbSourcePeer
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbsUid' => 0, 'ProUid' => 1, 'DbsType' => 2, 'DbsServer' => 3, 'DbsDatabaseName' => 4, 'DbsUsername' => 5, 'DbsPassword' => 6, 'DbsPort' => 7, 'DbsEncode' => 8, ),
BasePeer::TYPE_COLNAME => array (DbSourcePeer::DBS_UID => 0, DbSourcePeer::PRO_UID => 1, DbSourcePeer::DBS_TYPE => 2, DbSourcePeer::DBS_SERVER => 3, DbSourcePeer::DBS_DATABASE_NAME => 4, DbSourcePeer::DBS_USERNAME => 5, DbSourcePeer::DBS_PASSWORD => 6, DbSourcePeer::DBS_PORT => 7, DbSourcePeer::DBS_ENCODE => 8, ),
BasePeer::TYPE_FIELDNAME => array ('DBS_UID' => 0, 'PRO_UID' => 1, 'DBS_TYPE' => 2, 'DBS_SERVER' => 3, 'DBS_DATABASE_NAME' => 4, 'DBS_USERNAME' => 5, 'DBS_PASSWORD' => 6, 'DBS_PORT' => 7, 'DBS_ENCODE' => 8, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
BasePeer::TYPE_PHPNAME => array ('DbsUid' => 0, 'ProUid' => 1, 'DbsType' => 2, 'DbsServer' => 3, 'DbsDatabaseName' => 4, 'DbsUsername' => 5, 'DbsPassword' => 6, 'DbsPort' => 7, 'DbsEncode' => 8, 'DbsConnectionType' => 9, 'DbsTns' => 10, ),
BasePeer::TYPE_COLNAME => array (DbSourcePeer::DBS_UID => 0, DbSourcePeer::PRO_UID => 1, DbSourcePeer::DBS_TYPE => 2, DbSourcePeer::DBS_SERVER => 3, DbSourcePeer::DBS_DATABASE_NAME => 4, DbSourcePeer::DBS_USERNAME => 5, DbSourcePeer::DBS_PASSWORD => 6, DbSourcePeer::DBS_PORT => 7, DbSourcePeer::DBS_ENCODE => 8, DbSourcePeer::DBS_CONNECTION_TYPE => 9, DbSourcePeer::DBS_TNS => 10, ),
BasePeer::TYPE_FIELDNAME => array ('DBS_UID' => 0, 'PRO_UID' => 1, 'DBS_TYPE' => 2, 'DBS_SERVER' => 3, 'DBS_DATABASE_NAME' => 4, 'DBS_USERNAME' => 5, 'DBS_PASSWORD' => 6, 'DBS_PORT' => 7, 'DBS_ENCODE' => 8, 'DBS_CONNECTION_TYPE' => 9, 'DBS_TNS' => 10, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, )
);
/**
@@ -204,6 +210,10 @@ abstract class BaseDbSourcePeer
$criteria->addSelectColumn(DbSourcePeer::DBS_ENCODE);
$criteria->addSelectColumn(DbSourcePeer::DBS_CONNECTION_TYPE);
$criteria->addSelectColumn(DbSourcePeer::DBS_TNS);
}
const COUNT = 'COUNT(DB_SOURCE.DBS_UID)';

View File

@@ -1657,6 +1657,8 @@
<column name="DBS_PASSWORD" type="VARCHAR" size="32" default=""/>
<column name="DBS_PORT" type="INTEGER" default="0"/>
<column name="DBS_ENCODE" type="VARCHAR" size="32" default=""/>
<column name="DBS_CONNECTION_TYPE" type="VARCHAR" size="32" default="NORMAL"/>
<column name="DBS_TNS" type="VARCHAR" size="256" default=""/>
<index name="indexDBSource">
<index-column name="PRO_UID"/>
<vendor type="mysql">

View File

@@ -1714,6 +1714,8 @@ CREATE TABLE [DB_SOURCE]
[DBS_PASSWORD] VARCHAR(32) default '' NULL,
[DBS_PORT] INT default 0 NULL,
[DBS_ENCODE] VARCHAR(32) default '' NULL,
[DBS_CONNECTION_TYPE] VARCHAR(32) default 'NORMAL' NULL,
[DBS_TNS] VARCHAR(256) default '' NULL,
CONSTRAINT DB_SOURCE_PK PRIMARY KEY ([DBS_UID],[PRO_UID])
);

View File

@@ -785,6 +785,8 @@ CREATE TABLE `DB_SOURCE`
`DBS_PASSWORD` VARCHAR(32) default '',
`DBS_PORT` INTEGER default 0,
`DBS_ENCODE` VARCHAR(32) default '',
`DBS_CONNECTION_TYPE` VARCHAR(32) default 'NORMAL',
`DBS_TNS` VARCHAR(256) default '',
PRIMARY KEY (`DBS_UID`,`PRO_UID`),
KEY `indexDBSource`(`PRO_UID`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8' COMMENT='DB_SOURCE';

View File

@@ -972,7 +972,9 @@ CREATE TABLE "DB_SOURCE"
"DBS_USERNAME" VARCHAR2(32) default '0' NOT NULL,
"DBS_PASSWORD" VARCHAR2(32) default '',
"DBS_PORT" NUMBER default 0,
"DBS_ENCODE" VARCHAR2(32) default ''
"DBS_ENCODE" VARCHAR2(32) default '',
"DBS_CONNECTION_TYPE" VARCHAR2(32) default 'NORMAL',
"DBS_TNS" VARCHAR2(256) default ''
);
ALTER TABLE "DB_SOURCE"

View File

@@ -56,7 +56,10 @@ var saveDBConnection = function() {
var desc = $('form[DBS_DESCRIPTION]').value;
var enc = $('form[DBS_ENCODE]').value;
var uri = 'action=saveConnection&type='+type+'&server='+server+'&db_name='+db_name+'&user='+user+'&passwd='+passwd+'&port='+port+'&desc='+desc+'&enc='+enc;
var connectionType = getField("DBS_CONNECTION_TYPE").value;
var tns = getField("DBS_TNS").value;
var uri = 'action=saveConnection&type='+type+'&server='+server+'&db_name='+db_name+'&user='+user+'&passwd='+passwd+'&port='+port+'&desc='+desc+'&enc='+enc + "&connectionType=" + connectionType + "&tns=" + tns;
var oRPC = new leimnud.module.rpc.xmlhttp({
url : PROCESS_REQUEST_FILE,
@@ -97,7 +100,10 @@ function saveEditDBConnection()
var desc = $('form[DBS_DESCRIPTION]').value;
var enc = $('form[DBS_ENCODE]').value;
var uri = 'action=saveEditConnection&type='+type+'&server='+server+'&db_name='+db_name+'&user='+user+'&passwd='+passwd+'&port='+port+'&dbs_uid='+dbs_uid+'&desc='+desc+'&enc='+enc;
var connectionType = getField("DBS_CONNECTION_TYPE").value;
var tns = getField("DBS_TNS").value;
var uri = 'action=saveEditConnection&type='+type+'&server='+server+'&db_name='+db_name+'&user='+user+'&passwd='+passwd+'&port='+port+'&dbs_uid='+dbs_uid+'&desc='+desc+'&enc='+enc + "&connectionType=" + connectionType + "&tns=" + tns;
var oRPC = new leimnud.module.rpc.xmlhttp({
url : PROCESS_REQUEST_FILE,
@@ -231,6 +237,10 @@ function testDBConnection()
var user = $('form[DBS_USERNAME]').value;
var passwd = $('form[DBS_PASSWORD]').value;
var port = $('form[DBS_PORT]').value;
var connectionType = getField("DBS_CONNECTION_TYPE").value;
var tns = getField("DBS_TNS").value;
if(port.trim() == ''){
port = 'default';
}
@@ -256,7 +266,7 @@ function testDBConnection()
myPanel.loader.show();
var requestfile = PROCESS_REQUEST_FILE;
var uri = 'action=showTestConnection&type='+type+'&server='+server+'&db_name='+db_name+'&user='+user+'&passwd='+passwd+'&port='+port;
var uri = 'action=showTestConnection&type='+type+'&server='+server+'&db_name='+db_name+'&user='+user+'&passwd='+passwd+'&port='+port + "&connectionType=" + connectionType + "&tns=" + tns;
var ajax = AJAX();
ajax.open("POST", requestfile, true);
@@ -298,8 +308,11 @@ function testHost(step)
var port = 'none';
}
var connectionType = getField("DBS_CONNECTION_TYPE").value;
var tns = getField("DBS_TNS").value;
var requestfile = PROCESS_REQUEST_FILE;
var uri = 'action=testConnection&step='+step+'&type='+type+'&server='+server+'&db_name='+db_name+'&user='+user+'&port='+port+'&passwd='+passwd;
var uri = 'action=testConnection&step='+step+'&type='+type+'&server='+server+'&db_name='+db_name+'&user='+user+'&port='+port+'&passwd='+passwd + "&connectionType=" + connectionType + "&tns=" + tns;
var ajax = AJAX();
mainRequest = ajax;
@@ -370,68 +383,78 @@ function cancelTestConnection()
currentPopupWindow.remove();
}
function validateFields()
{
if( getField('DBS_PORT').value.trim() == '' || getField('DBS_PORT').value.trim() == '0' ) {
onChangeType();
}
if (FLAG_DBS_TNS == 1) {
var res = true;
var tns = new input(getField("DBS_TNS"));
var res = true;
var o = new input(getField('DBS_SERVER'));
if($('form[DBS_SERVER]').value == '') {
//new leimnud.module.app.alert().make({label: G_STRINGS.DBCONNECTIONS_MSG4});
o.failed();
res = false;
} else
o.passed();
if($("form[DBS_TNS]").value == "") {
tns.failed();
res = false;
} else {
tns.passed();
}
} else {
if( getField('DBS_PORT').value.trim() == '' || getField('DBS_PORT').value.trim() == '0' ) {
onChangeType();
}
var o = new input(getField('DBS_DATABASE_NAME'));
if($('form[DBS_DATABASE_NAME]').value == '') {
//new leimnud.module.app.alert().make({label: G_STRINGS.DBCONNECTIONS_MSG5});
o.failed();
res = false;
} else
o.passed();
var res = true;
var o = new input(getField('DBS_SERVER'));
if($('form[DBS_SERVER]').value == '') {
//new leimnud.module.app.alert().make({label: G_STRINGS.DBCONNECTIONS_MSG4});
o.failed();
res = false;
} else
o.passed();
var o = new input(getField('DBS_USERNAME'));
if($('form[DBS_USERNAME]').value == '') {
//new leimnud.module.app.alert().make({label: G_STRINGS.DBCONNECTIONS_MSG6});
o.failed();
res = false;
} else
o.passed();
var o = new input(getField('DBS_DATABASE_NAME'));
if($('form[DBS_DATABASE_NAME]').value == '') {
//new leimnud.module.app.alert().make({label: G_STRINGS.DBCONNECTIONS_MSG5});
o.failed();
res = false;
} else
o.passed();
/*var o = new input(getField('DBS_PORT'));
if($('form[DBS_PORT]').value == '') {
o.failed();
res = false;
} else
o.passed();*/
var o = new input(getField('DBS_USERNAME'));
if($('form[DBS_USERNAME]').value == '') {
//new leimnud.module.app.alert().make({label: G_STRINGS.DBCONNECTIONS_MSG6});
o.failed();
res = false;
} else
o.passed();
var o = new input(getField('DBS_TYPE'));
if($('form[DBS_TYPE]').value == '0') {
o.failed();
res = false;
} else
o.passed();
/*var o = new input(getField('DBS_PORT'));
if($('form[DBS_PORT]').value == '') {
o.failed();
res = false;
} else
o.passed();*/
oType = getField('DBS_TYPE');
if( oType.value != 'mssql' && oType.value != 'oracle' ){
var o = new input(getField('DBS_ENCODE'));
if($('form[DBS_ENCODE]').value == '0') {
o.failed();
res = false;
} else
o.passed();
}
var o = new input(getField('DBS_TYPE'));
if($('form[DBS_TYPE]').value == '0') {
o.failed();
res = false;
} else
o.passed();
oType = getField('DBS_TYPE');
if( oType.value != 'mssql' && oType.value != 'oracle' ){
var o = new input(getField('DBS_ENCODE'));
if($('form[DBS_ENCODE]').value == '0') {
o.failed();
res = false;
} else
o.passed();
}
}
if(!res){
new leimnud.module.app.alert().make({label: G_STRINGS.DBCONNECTIONS_ALERT});
}
return res;
if(!res){
new leimnud.module.app.alert().make({label: G_STRINGS.DBCONNECTIONS_ALERT});
}
return res;
}
var onChangeType = function() {
@@ -456,10 +479,25 @@ var onChangeType = function() {
};
var FLAG_DBS_TNS = 0;
function showEncodes(pre){
oType = getField('DBS_TYPE');
//if( oType.value != 'mssql' && oType.value != 'oracle' ){
if( oType.value != 'oracle' ){
FLAG_DBS_TNS = 0;
hideRowById("DBS_CONNECTION_TYPE");
getField("DBS_TNS").value = "";
hideRowById("DBS_TNS");
showRowById("DBS_SERVER");
showRowById("DBS_DATABASE_NAME");
showRowById("DBS_USERNAME");
showRowById("DBS_PASSWORD");
showRowById("DBS_PORT");
showRowById('DBS_ENCODE');
var o = new input(getField('DBS_TYPE'));
if($('form[DBS_TYPE]').value == '0') {
@@ -499,6 +537,40 @@ function showEncodes(pre){
}.extend(this);
oRPC.make();
} else {
hideRowById('DBS_ENCODE');
hideRowById('DBS_ENCODE');
showRowById("DBS_CONNECTION_TYPE");
showRowById("DBS_SERVER");
showRowById("DBS_DATABASE_NAME");
showRowById("DBS_USERNAME");
showRowById("DBS_PASSWORD");
showRowById("DBS_PORT");
var connectionType = getField("DBS_CONNECTION_TYPE").value;
if (connectionType == "TNS") {
FLAG_DBS_TNS = 1;
document.getElementById("userName").style.display = "none";
removeRequiredById("DBS_USERNAME");
showRowById("DBS_TNS");
hideRowById("DBS_SERVER");
hideRowById("DBS_DATABASE_NAME");
hideRowById("DBS_PORT");
getField("DBS_USERNAME").required = false;
getField("DBS_PASSWORD").required = false;
} else {
FLAG_DBS_TNS = 0;
getField("DBS_TNS").value = "";
hideRowById("DBS_TNS");
document.getElementById("userName").style.display = "inline";
enableRequiredById("DBS_USERNAME");
}
}
}

View File

@@ -144,8 +144,16 @@ switch ($action) {
if (strpos( $_POST['server'], "\\" )) {
$_POST['port'] = 'none';
}
$aData = Array ('DBS_UID' => $_POST['dbs_uid'],'PRO_UID' => $_SESSION['PROCESS'],'DBS_TYPE' => $_POST['type'],'DBS_SERVER' => $_POST['server'],'DBS_DATABASE_NAME' => $_POST['db_name'],'DBS_USERNAME' => $_POST['user'],'DBS_PASSWORD' => (($_POST['passwd'] == 'none') ? "" : G::encrypt( $_POST['passwd'], $_POST['db_name'] )) . "_2NnV3ujj3w",'DBS_PORT' => (($_POST['port'] == 'none') ? "" : $_POST['port']),'DBS_ENCODE' => $_POST['enc']
);
$flagTns = ($_POST["type"] == "oracle" && $_POST["connectionType"] == "TNS")? 1 : 0;
if ($flagTns == 0) {
$_POST["connectionType"] = "NORMAL";
$aData = array("DBS_UID" => $_POST["dbs_uid"], "PRO_UID" => $_SESSION["PROCESS"], "DBS_TYPE" => $_POST["type"], "DBS_SERVER" => $_POST["server"], "DBS_DATABASE_NAME" => $_POST["db_name"], "DBS_USERNAME" => $_POST["user"], "DBS_PASSWORD" => (($_POST["passwd"] == "none")? "" : G::encrypt($_POST["passwd"], $_POST["db_name"])) . "_2NnV3ujj3w", "DBS_PORT" => (($_POST["port"] == "none")? "" : $_POST["port"]), "DBS_ENCODE" => $_POST["enc"], "DBS_CONNECTION_TYPE" => $_POST["connectionType"], "DBS_TNS" => "");
} else {
$aData = array("DBS_UID" => $_POST["dbs_uid"], "PRO_UID" => $_SESSION["PROCESS"], "DBS_TYPE" => $_POST["type"], "DBS_SERVER" => "", "DBS_DATABASE_NAME" => "", "DBS_USERNAME" => $_POST["user"], "DBS_PASSWORD" => (($_POST["passwd"] == "none")? "" : G::encrypt($_POST["passwd"], $_POST["tns"])) . "_2NnV3ujj3w", "DBS_PORT" => "", "DBS_ENCODE" => "", "DBS_CONNECTION_TYPE" => $_POST["connectionType"], "DBS_TNS" => $_POST["tns"]);
}
$oDBSource->update( $aData );
$oContent->addContent( 'DBS_DESCRIPTION', '', $_POST['dbs_uid'], SYS_LANG, $_POST['desc'] );
@@ -156,8 +164,17 @@ switch ($action) {
if (strpos( $_POST['server'], "\\" )) {
$_POST['port'] = 'none';
}
$aData = Array ('PRO_UID' => $_SESSION['PROCESS'],'DBS_TYPE' => $_POST['type'],'DBS_SERVER' => $_POST['server'],'DBS_DATABASE_NAME' => $_POST['db_name'],'DBS_USERNAME' => $_POST['user'],'DBS_PASSWORD' => (($_POST['passwd'] == 'none') ? "" : G::encrypt( $_POST['passwd'], $_POST['db_name'] )) . "_2NnV3ujj3w",'DBS_PORT' => (($_POST['port'] == 'none') ? "" : $_POST['port']),'DBS_ENCODE' => $_POST['enc']
);
$flagTns = ($_POST["type"] == "oracle" && $_POST["connectionType"] == "TNS")? 1 : 0;
if ($flagTns == 0) {
$_POST["connectionType"] = "NORMAL";
$aData = array("PRO_UID" => $_SESSION["PROCESS"], "DBS_TYPE" => $_POST["type"], "DBS_SERVER" => $_POST["server"], "DBS_DATABASE_NAME" => $_POST["db_name"], "DBS_USERNAME" => $_POST["user"], "DBS_PASSWORD" => (($_POST["passwd"] == "none")? "" : G::encrypt($_POST["passwd"], $_POST["db_name"])) . "_2NnV3ujj3w", "DBS_PORT" => (($_POST["port"] == "none") ? "" : $_POST["port"]), "DBS_ENCODE" => $_POST["enc"], "DBS_CONNECTION_TYPE" => $_POST["connectionType"], "DBS_TNS" => "");
} else {
$aData = array("PRO_UID" => $_SESSION["PROCESS"], "DBS_TYPE" => $_POST["type"], "DBS_SERVER" => "", "DBS_DATABASE_NAME" => "", "DBS_USERNAME" => $_POST["user"], "DBS_PASSWORD" => (($_POST["passwd"] == "none")? "" : G::encrypt($_POST["passwd"], $_POST["tns"])) . "_2NnV3ujj3w", "DBS_PORT" => "", "DBS_ENCODE" => "", "DBS_CONNECTION_TYPE" => $_POST["connectionType"], "DBS_TNS" => $_POST["tns"]);
}
$newid = $oDBSource->create( $aData );
$sDelimiter = DBAdapter::getStringDelimiter();
$oContent->addContent( 'DBS_DESCRIPTION', '', $newid, SYS_LANG, $_POST['desc'] );
@@ -186,90 +203,138 @@ switch ($action) {
break;
case 'testConnection':
sleep( 0 );
$step = $_POST['step'];
$type = $_POST['type'];
$server = $_POST['server'];
$db_name = $_POST['db_name'];
$user = $_POST['user'];
$passwd = ($_POST['passwd'] == 'none') ? "" : $_POST['passwd'];
$port = $_POST['port'];
if (($port == 'none') || ($port == 0)) {
//setting defaults ports
switch ($type) {
case 'mysql':
$port = 3306;
break;
case 'pgsql':
$port = 5432;
break;
case 'mssql':
$port = 1433;
break;
case 'oracle':
$port = 1521;
break;
G::LoadClass("net");
define("SUCCESSFULL", "SUCCESSFULL");
define("FAILED", "FAILED");
$step = $_POST["step"];
$type = $_POST["type"];
$user = $_POST["user"];
$passwd = ($_POST["passwd"] == "none")? "" : $_POST["passwd"];
$flagTns = ($_POST["type"] == "oracle" && $_POST["connectionType"] == "TNS")? 1 : 0;
if ($flagTns == 0) {
$server = $_POST["server"];
$db_name = $_POST["db_name"];
$port = $_POST["port"];
if ($port == "none" || $port == 0) {
//setting defaults ports
switch ($type) {
case "mysql":
$port = 3306;
break;
case "pgsql":
$port = 5432;
break;
case "mssql":
$port = 1433;
break;
case "oracle":
$port = 1521;
break;
}
}
}
G::LoadClass( 'net' );
$Server = new NET( $server );
$Server = new NET($server);
define( "SUCCESSFULL", 'SUCCESSFULL' );
define( "FAILED", 'FAILED' );
switch ($step) {
case 1:
if ($Server->getErrno() == 0) {
print (SUCCESSFULL . ',') ;
} else {
print (FAILED . ',' . $Server->error) ;
}
break;
case 2:
$Server->scannPort( $port );
if ($Server->getErrno() == 0) {
print (SUCCESSFULL . ',') ;
} else {
print (FAILED . ',' . $Server->error) ;
}
break;
case 3:
$Server->loginDbServer( $user, $passwd );
$Server->setDataBase( $db_name, $port );
if ($Server->errno == 0) {
$response = $Server->tryConnectServer( $type );
if ($response->status == 'SUCCESS') {
print (SUCCESSFULL . ',') ;
switch ($step) {
case 1:
if ($Server->getErrno() == 0) {
echo SUCCESSFULL . ",";
} else {
print (FAILED . ',' . $Server->error) ;
echo FAILED . "," . $Server->error;
}
} else {
print (FAILED . ',' . $Server->error) ;
}
break;
case 4:
$Server->loginDbServer( $user, $passwd );
$Server->setDataBase( $db_name, $port );
if ($Server->errno == 0) {
$response = $Server->tryConnectServer( $type );
if ($response->status == 'SUCCESS') {
$response = $Server->tryOpenDataBase( $type );
if ($response->status == 'SUCCESS') {
print (SUCCESSFULL . ',' . $Server->error) ;
break;
case 2:
$Server->scannPort($port);
if ($Server->getErrno() == 0) {
echo SUCCESSFULL . ",";
} else {
echo FAILED . "," . $Server->error;
}
break;
case 3:
$Server->loginDbServer($user, $passwd);
$Server->setDataBase($db_name, $port);
if ($Server->errno == 0) {
$response = $Server->tryConnectServer($type);
if ($response->status == "SUCCESS") {
echo SUCCESSFULL . ",";
} else {
print (FAILED . ',' . $Server->error) ;
echo FAILED . "," . $Server->error;
}
} else {
print (FAILED . ',' . $Server->error) ;
echo FAILED . "," . $Server->error;
}
} else {
print (FAILED . ',' . $Server->error) ;
}
break;
default:
print ('finished') ;
break;
case 4:
$Server->loginDbServer($user, $passwd);
$Server->setDataBase($db_name, $port);
if ($Server->errno == 0) {
$response = $Server->tryConnectServer($type);
if ($response->status == "SUCCESS") {
$response = $Server->tryOpenDataBase($type);
if ($response->status == "SUCCESS") {
echo SUCCESSFULL . "," . $Server->error;
} else {
echo FAILED . "," . $Server->error;
}
} else {
echo FAILED . "," . $Server->error;
}
} else {
echo FAILED . "," . $Server->error;
}
break;
default:
echo "finished";
break;
}
} else {
$connectionType = $_POST["connectionType"];
$tns = $_POST["tns"];
$net = new NET();
switch ($step) {
case 1:
$net->loginDbServer($user, $passwd);
if ($net->errno == 0) {
$arrayServerData = array("connectionType" => $connectionType, "tns" => $tns);
$response = $net->tryConnectServer($type, $arrayServerData);
if ($response->status == "SUCCESS") {
$response = $net->tryOpenDataBase($type, $arrayServerData);
if ($response->status == "SUCCESS") {
echo SUCCESSFULL . "," . $net->error;
} else {
echo FAILED . "," . $net->error;
}
} else {
echo FAILED . "," . $net->error;
}
} else {
echo FAILED . "," . $net->error;
}
break;
default:
echo "finished";
break;
}
}
break;
case 'showEncodes':

View File

@@ -13,13 +13,21 @@ if (isset( $_SESSION['PROCESS'] )) {
$oDbConnections = new dbConnections( $_SESSION['PROCESS'] );
foreach ($oDbConnections->connections as $db) {
$db['DBS_PASSWORD'] = $oDbConnections->getPassWithoutEncrypt( $db );
$dbsPort = ($db['DBS_PORT'] == '') ? ('') : (':' . $db['DBS_PORT']);
$ENCODE = (trim( $db['DBS_ENCODE'] ) == '') ? '' : '?encoding=' . $db['DBS_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;
$flagTns = ($db["DBS_TYPE"] == "oracle" && $db["DBS_CONNECTION_TYPE"] == "TNS")? 1 : 0;
if ($flagTns == 0) {
$dbsPort = ($db['DBS_PORT'] == '') ? ('') : (':' . $db['DBS_PORT']);
$ENCODE = (trim( $db['DBS_ENCODE'] ) == '') ? '' : '?encoding=' . $db['DBS_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;
}
} 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"]]["connection"] = $db["DBS_TYPE"] . "://" . $db["DBS_USERNAME"] . ":" . $db["DBS_PASSWORD"] . "@" . $db["DBS_TNS"];
}
$pro['datasources'][$db['DBS_UID']]['adapter'] = $db['DBS_TYPE'];
}
return $pro;

View File

@@ -30,84 +30,97 @@
* @LastModification 30/05/2008
*/
G::LoadClass('tree');
G::LoadClass('net');
$host = new net($_POST['server']);
$width_content = '430px';
$html = '
<div class="boxTopBlue"><div class="a"></div><div class="b"></div><div class="c"></div></div>
<div class="boxContentBlue">
<table style="margin:0px;" cellspacing="0" cellpadding="0">
<tr>
<td class="userGroupTitle"><center>'.G::loadTranslation('DBCONNECTIONS_TITLE').'</center></td>
</tr>
</table>
</div>
<div class="boxBottomBlue"><div class="a"></div><div class="b"></div><div class="c"></div></div>
';
G::LoadClass('tree');
G::LoadClass('net');
$port = $_POST['port'];
if( $port == 'default' ){
//setting defaults ports
switch ($_POST['type']){
case 'mysql': $port = 3306; break;
case 'pgsql': $port = 5432; break;
case 'mssql': $port = 1433; break;
case 'oracle': $port = 1521; break;
}
$_POST['port'] = $port;
$port = "default ($port)";
}
$tests = Array('',
G::loadTranslation('ID_HOST_NAME').' <b>'.$_POST['server'].'</b>',
G::loadTranslation('ID_CHECK_PORT').' <b>'.$port.'</b>',
G::loadTranslation('ID_CONNECT_HOST').' <b>'.$host->ip.':'.$_POST['port'].'</b>',
$width_content = '430px';
$html = '
<div class="boxTopBlue"><div class="a"></div><div class="b"></div><div class="c"></div></div>
<div class="boxContentBlue">
<table style="margin:0px;" cellspacing="0" cellpadding="0">
<tr>
<td class="userGroupTitle"><center>'.G::loadTranslation('DBCONNECTIONS_TITLE').'</center></td>
</tr>
</table>
</div>
<div class="boxBottomBlue"><div class="a"></div><div class="b"></div><div class="c"></div></div>
';
$flagTns = ($_POST["type"] == "oracle" && $_POST["connectionType"] == "TNS")? 1 : 0;
if ($flagTns == 0) {
$host = new NET($_POST["server"]);
$port = $_POST["port"];
if ($port == "default") {
//setting defaults ports
switch ($_POST["type"]) {
case "mysql": $port = 3306; break;
case "pgsql": $port = 5432; break;
case "mssql": $port = 1433; break;
case "oracle": $port = 1521; break;
}
$_POST["port"] = $port;
$port = "default ($port)";
}
$tests = array(
"",
G::loadTranslation('ID_HOST_NAME').' <b>'.$_POST['server'].'</b>',
G::loadTranslation('ID_CHECK_PORT').' <b>'.$port.'</b>',
G::loadTranslation('ID_CONNECT_HOST').' <b>'.$host->ip.':'.$_POST['port'].'</b>',
G::loadTranslation('ID_OPEN_DB').'['.$_POST['db_name'].'] '.G::loadTranslation('ID_IN').' '.$_POST['type'].' '.G::loadTranslation('ID_SERVICE')
);
$n = Array('','uno','dos','tres','cuatro','cinco');
for($i=1; $i<count($tests);$i++)
{
$html .= "
<div id='test_$i' style='display:none'>
<table width='100%' cellspacing='0' cellpadding='0' border='1' style='border:1px;'>
<tr>
<td width='10px' class='treeNode' style='border:0px;background-color:transparent;'>
<IMG src=\"/images/".$n[$i].".gif\" width=\"25\" height=\"25\" align=\"left\" border=\"0\">
</td>
<td width='410px' class='treeNode' style='border:0px;background-color:transparent;'>
<div id='action_$i'>$tests[$i]</div>
</td>
</tr>
<tr>
<td width='10px' class='treeNode' style='border:0px;background-color:transparent;'>
</td>
<td class='treeNode' style='border:0px;background-color:transparent;'>
<div id='status_$i'></div>
</td>
</tr>
</table>
</div>";
}
echo '<div class="grid" style="width:'.$width_content.'">
<div class="boxTop"><div class="a"></div><div class="b"></div><div class="c"></div></div>
<div class="content" style="">
<table >
<tbody><tr>
<td valign="top">
'.$html.'
</td>
</tr>
</tbody></table>
</div>
<div class="boxBottom"><div class="a"></div><div class="b"></div><div class="c"></div></div>
</div>';
} else {
$tests = array(
"",
"Test TNS" . " <strong>" . $_POST["tns"] . "</strong>"
);
}
print ("<div id='bnt_abort' style='display:block'><input type=button class='module_app_button___gray' onclick='jvascript:abortTestConnection()' value='ABORT'></div>");
print ("<div id='bnt_ok' style='display:none'><input type=button class='module_app_button___gray' onclick='jvascript:cancelTestConnection()' value='DONE'></div>");
$n = Array('','uno','dos','tres','cuatro','cinco');
for($i=1; $i<count($tests);$i++)
{
$html .= "
<div id='test_$i' style='display:none'>
<table width='100%' cellspacing='0' cellpadding='0' border='1' style='border:1px;'>
<tr>
<td width='10px' class='treeNode' style='border:0px;background-color:transparent;'>
<IMG src=\"/images/".$n[$i].".gif\" width=\"25\" height=\"25\" align=\"left\" border=\"0\">
</td>
<td width='410px' class='treeNode' style='border:0px;background-color:transparent;'>
<div id='action_$i'>$tests[$i]</div>
</td>
</tr>
<tr>
<td width='10px' class='treeNode' style='border:0px;background-color:transparent;'>
</td>
<td class='treeNode' style='border:0px;background-color:transparent;'>
<div id='status_$i'></div>
</td>
</tr>
</table>
</div>";
}
echo '<div class="grid" style="width:'.$width_content.'">
<div class="boxTop"><div class="a"></div><div class="b"></div><div class="c"></div></div>
<div class="content" style="">
<table >
<tbody><tr>
<td valign="top">
'.$html.'
</td>
</tr>
</tbody></table>
</div>
<div class="boxBottom"><div class="a"></div><div class="b"></div><div class="c"></div></div>
</div>';
print ("<div id='bnt_abort' style='display:block'><input type=button class='module_app_button___gray' onclick='jvascript:abortTestConnection()' value='ABORT'></div>");
print ("<div id='bnt_ok' style='display:none'><input type=button class='module_app_button___gray' onclick='jvascript:cancelTestConnection()' value='DONE'></div>");

View File

@@ -1,4 +1,4 @@
<form id="{$form_id}" name="{$form_name}" action="{$form_action}" class="{$form_className}" method="post" encType="multipart/form-data" style="margin:0px;" onsubmit='return validateForm("{$form_objectRequiredFields}".parseJSON());'>
<form id="{$form_id}" name="{$form_name}" action="{$form_action}" class="{$form_className}" method="post" encType="multipart/form-data" style="margin:0px;" onsubmit='return validateForm("{$form_objectRequiredFields}".parseJSON());'>
<div class="borderForm" style="padding-left: 0pt; padding-right: 0pt;">
<div class="boxTop"><div class="a"></div><div class="b"></div><div class="c"></div></div>
@@ -15,47 +15,58 @@
<tr>
<td class="FormLabel" width="{$form_labelWidth}">{$DBS_UID}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_UID} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_UID}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_UID}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}">{$DBS_TYPE}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_TYPE} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_TYPE}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_TYPE}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}">{$DBS_ENCODE}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_ENCODE} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_ENCODE}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_ENCODE}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}">{$DBS_CONNECTION_TYPE} </td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_CONNECTION_TYPE}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_TNS}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_TNS}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_SERVER}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_SERVER} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_SERVER}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_SERVER}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_DATABASE_NAME}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_DATABASE_NAME} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_DATABASE_NAME}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_DATABASE_NAME}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_USERNAME}</td>
<td class="FormLabel" width="{$form_labelWidth}"><span id="userName"><font color="red">* </font></span>{$DBS_USERNAME}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_USERNAME} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_USERNAME}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_USERNAME}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}">{$DBS_PASSWORD}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_PASSWORD} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_PASSWORD}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_PASSWORD}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_PORT}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_PORT} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_PORT}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_PORT}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}">{$DBS_DESCRIPTION}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_DESCRIPTION} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_DESCRIPTION}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_DESCRIPTION}</td>
</tr>
<tr>
<td class="FormButton" colspan="2" align="center"></td>
@@ -73,5 +84,5 @@
<script type="text/javascript">
{$form.JS}
</script>
</form>
</form>

View File

@@ -7,13 +7,24 @@
</DBS_UID>
<DBS_TYPE type="dropdown" sqlconnection="dbarray">
SELECT * FROM BDCONNECTIONS
SELECT * FROM BDCONNECTIONS
<en>Engine<option name="">...</option></en>
</DBS_TYPE>
<DBS_ENCODE type="dropdown">
<DBS_ENCODE type="dropdown">
<en>Encode<option name="">...</option></en>
</DBS_ENCODE>
</DBS_ENCODE>
<DBS_CONNECTION_TYPE type="dropdown" defaultvalue="NORMAL" required="0" readonly="0" optgroup="0" mode="edit">
<en>Select Connection Type
<option name="NORMAL">Normal</option>
<option name="TNS">TNS</option>
</en>
</DBS_CONNECTION_TYPE>
<DBS_TNS type="text" size="25" maxlength="100" defaultvalue="" required="true">
<en>TNS</en>
</DBS_TNS>
<DBS_SERVER type="text" size="25" maxlength="100" defaultvalue="" required="true">
<en>Server</en>
@@ -53,17 +64,21 @@
<JS type="javascript"><![CDATA[
hideRowById('DBS_ENCODE');
leimnud.event.add(getField('DBS_TYPE'), 'change', function() {
showEncodes('@#DBS_ENCODE');
onChangeType();
}.extend(getField('DBS_TYPE')));
showEncodes('@#DBS_ENCODE');
function cancel(){
oPanel.remove();
}
}
leimnud.event.add(getField("DBS_CONNECTION_TYPE"), "change", function() {
showEncodes();
});
]]></JS>
</dynaForm>
</dynaForm>

View File

@@ -1,4 +1,4 @@
<form id="{$form_id}" name="{$form_name}" action="{$form_action}" class="{$form_className}" method="post" encType="multipart/form-data" style="margin:0px;" onsubmit='return validateForm("{$form_objectRequiredFields}".parseJSON());'>
<form id="{$form_id}" name="{$form_name}" action="{$form_action}" class="{$form_className}" method="post" encType="multipart/form-data" style="margin:0px;" onsubmit='return validateForm("{$form_objectRequiredFields}".parseJSON());'>
<div class="borderForm" style="padding-left: 0pt; padding-right: 0pt;">
<div class="boxTop"><div class="a"></div><div class="b"></div><div class="c"></div></div>
@@ -18,42 +18,53 @@
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_TYPE}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_TYPE} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_TYPE}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_TYPE}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_ENCODE}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_ENCODE} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_ENCODE}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_ENCODE}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}">{$DBS_CONNECTION_TYPE} </td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_CONNECTION_TYPE}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_TNS}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_TNS}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_SERVER}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_SERVER} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_SERVER}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_SERVER}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_DATABASE_NAME}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_DATABASE_NAME} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_DATABASE_NAME}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_DATABASE_NAME}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_USERNAME}</td>
<td class="FormLabel" width="{$form_labelWidth}"><span id="userName"><font color="red">* </font></span>{$DBS_USERNAME}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_USERNAME} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_USERNAME}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_USERNAME}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}">{$DBS_PASSWORD}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_PASSWORD} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_PASSWORD}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_PASSWORD}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}"><font color="red">* </font>{$DBS_PORT}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_PORT} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_PORT}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_PORT}</td>
</tr>
<tr>
<td class="FormLabel" width="{$form_labelWidth}">{$DBS_DESCRIPTION}</td>
<!-- <td class='FormFieldContent' width="{$form_width}" >{$form.DBS_DESCRIPTION} </td> //-->
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_DESCRIPTION}</td>
<td class="FormFieldContent" width="{$form_fieldContentWidth}">{$form.DBS_DESCRIPTION}</td>
</tr>
<tr>
<td class="FormButton" colspan="2" align="center"></td>
@@ -71,5 +82,5 @@
<script type="text/javascript">
{$form.JS}
</script>
</form>

View File

@@ -6,14 +6,25 @@
<PRO_UID type="hidden"/>
<DBS_TYPE type="dropdown" sqlconnection="dbarray" required="true">
SELECT * FROM BDCONNECTIONS
SELECT * FROM BDCONNECTIONS
<en>Engine<option name="">Select...</option></en>
</DBS_TYPE>
<DBS_ENCODE type="dropdown" required="true">
<DBS_ENCODE type="dropdown" required="true">
<en>Encode<option name="">...</option></en>
</DBS_ENCODE>
<DBS_CONNECTION_TYPE type="dropdown" defaultvalue="NORMAL" required="0" readonly="0" optgroup="0" mode="edit">
<en>Select Connection Type
<option name="NORMAL">Normal</option>
<option name="TNS">TNS</option>
</en>
</DBS_CONNECTION_TYPE>
<DBS_TNS type="text" size="25" maxlength="100" defaultvalue="" required="true">
<en>TNS</en>
</DBS_TNS>
<DBS_SERVER type="text" size="25" maxlength="100" defaultvalue="" required="true">
<en>Server</en>
</DBS_SERVER>
@@ -57,10 +68,17 @@
showEncodes();
onChangeType();
}.extend(getField('DBS_TYPE')));
function cancel(){
oPanel.remove();
}
}
hideRowById("DBS_CONNECTION_TYPE");
hideRowById("DBS_TNS");
leimnud.event.add(getField("DBS_CONNECTION_TYPE"), "change", function() {
showEncodes();
});
]]></JS>
</dynaForm>