Merge pull request #806 from ralpheav/master

Code Style change  workflow/engine/methods/dbConnections
This commit is contained in:
ferOnti
2012-10-18 06:56:46 -07:00
4 changed files with 285 additions and 306 deletions

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* upgrade.php * upgrade.php
* *
@@ -12,15 +13,14 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
/* /*
global $RBAC; global $RBAC;
@@ -44,34 +44,35 @@ $G_ID_MENU_SELECTED = 'PROCESSES';
$G_ID_SUB_MENU_SELECTED = 'DB_CONNECTIONS'; $G_ID_SUB_MENU_SELECTED = 'DB_CONNECTIONS';
*/ */
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher();
G::LoadClass('processMap'); G::LoadClass( 'processMap' );
$oProcess = new processMap(); $oProcess = new processMap();
$oCriteria = $oProcess->getConditionProcessList(); $oCriteria = $oProcess->getConditionProcessList();
if (ProcessPeer::doCount($oCriteria) > 0) { if (ProcessPeer::doCount( $oCriteria ) > 0) {
$aProcesses = array(); $aProcesses = array ();
$aProcesses[] = array('PRO_UID' => 'char', 'PRO_TITLE' => 'char'); $aProcesses[] = array ('PRO_UID' => 'char','PRO_TITLE' => 'char' );
$oDataset = StepPeer::doSelectRS($oCriteria); $oDataset = StepPeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next(); $oDataset->next();
$sProcessUID = ''; $sProcessUID = '';
while ($aRow = $oDataset->getRow()) { while ($aRow = $oDataset->getRow()) {
if ($sProcessUID == '') { if ($sProcessUID == '') {
$sProcessUID = $aRow['PRO_UID']; $sProcessUID = $aRow['PRO_UID'];
} }
$aProcesses[] = array('PRO_UID' => $aRow['PRO_UID'], 'PRO_TITLE' => $aRow['PRO_TITLE']); $aProcesses[] = array ('PRO_UID' => $aRow['PRO_UID'],'PRO_TITLE' => $aRow['PRO_TITLE'] );
$oDataset->next(); $oDataset->next();
} }
global $_DBArray; global $_DBArray;
$_DBArray['PROCESSES'] = $aProcesses; $_DBArray['PROCESSES'] = $aProcesses;
$_SESSION['_DBArray'] = $_DBArray; $_SESSION['_DBArray'] = $_DBArray;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dbConnections/dbConnections_Events'); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'dbConnections/dbConnections_Events' );
require_once 'classes/model/DbSource.php'; require_once 'classes/model/DbSource.php';
$oDBSource = new DbSource(); $oDBSource = new DbSource();
$oCriteria = $oDBSource->getCriteriaDBSList($sProcessUID); $oCriteria = $oDBSource->getCriteriaDBSList( $sProcessUID );
$G_PUBLISH->AddContent('propeltable', 'paged-table', 'dbConnections/dbConnections', $oCriteria); $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'dbConnections/dbConnections', $oCriteria );
} else { } else {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'setup/noProcesses'); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/noProcesses' );
} }
G::RenderPage('publish'); G::RenderPage( 'publish' );

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* upgrade.php * upgrade.php
* *
@@ -12,15 +13,14 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/ */
/* /*
@@ -30,285 +30,260 @@
* @Param var action from POST request * @Param var action from POST request
*/ */
if( isset($_POST['action']) || isset($_POST['function']) ){ if (isset( $_POST['action'] ) || isset( $_POST['function'] )) {
$action = (isset($_POST['action']))?$_POST['action']:$_POST['function']; $action = (isset( $_POST['action'] )) ? $_POST['action'] : $_POST['function'];
} else { } else {
throw new Exception('dbconnections Fatal error, No action defined!...'); throw new Exception( 'dbconnections Fatal error, No action defined!...' );
} }
if(isset($_POST['PROCESS'])) if (isset( $_POST['PROCESS'] )) {
$_SESSION['PROCESS'] = $_POST['PROCESS']; $_SESSION['PROCESS'] = $_POST['PROCESS'];
}
#Global Definitions #Global Definitions
require_once 'classes/model/DbSource.php'; require_once 'classes/model/DbSource.php';
require_once 'classes/model/Content.php'; require_once 'classes/model/Content.php';
$G_PUBLISH = new Publisher; $G_PUBLISH = new Publisher();
G::LoadClass('processMap'); G::LoadClass( 'processMap' );
G::LoadClass('ArrayPeer'); G::LoadClass( 'ArrayPeer' );
G::LoadClass ('dbConnections'); G::LoadClass( 'dbConnections' );
global $_DBArray; global $_DBArray;
switch ( $action ){ switch ($action) {
case 'loadInfoAssigConnecctionDB':
case 'loadInfoAssigConnecctionDB': $oStep = new Step();
$oStep = new Step(); return print ($oStep->loadInfoAssigConnecctionDB( $_POST['PRO_UID'], $_POST['DBS_UID'] )) ;
return print ($oStep->loadInfoAssigConnecctionDB($_POST['PRO_UID'],$_POST['DBS_UID'])); break;
break; case 'showDbConnectionsList':
$oProcess = new processMap();
case 'showDbConnectionsList': $oCriteria = $oProcess->getConditionProcessList();
if (ProcessPeer::doCount( $oCriteria ) > 0) {
$aProcesses = array ();
$aProcesses[] = array ('PRO_UID' => 'char','PRO_TITLE' => 'char'
);
$oDataset = ArrayBasePeer::doSelectRS( $oCriteria );
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oDataset->next();
$sProcessUID = '';
while ($aRow = $oDataset->getRow()) {
if ($sProcessUID == '') {
$sProcessUID = $aRow['PRO_UID'];
}
$aProcesses[] = array ('PRO_UID' => (isset( $aRow['PRO_UID'] ) ? $aRow['PRO_UID'] : ''),'PRO_TITLE' => (isset( $aRow['PRO_TITLE'] ) ? $aRow['PRO_TITLE'] : '')
);
$oDataset->next();
}
$oProcess = new processMap(); $_DBArray['PROCESSES'] = $aProcesses;
$oCriteria = $oProcess->getConditionProcessList(); $_SESSION['_DBArray'] = $_DBArray;
if( ProcessPeer::doCount($oCriteria) > 0 ){ $_SESSION['PROCESS'] = (isset( $_POST['PRO_UID'] ) ? $_POST['PRO_UID'] : '');
$aProcesses = array();
$aProcesses[] = array('PRO_UID' => 'char', 'PRO_TITLE' => 'char');
$oDataset = ArrayBasePeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$sProcessUID = '';
while( $aRow = $oDataset->getRow() ){
if( $sProcessUID == '' ){
$sProcessUID = $aRow['PRO_UID'];
}
$aProcesses[] = array('PRO_UID' => (isset($aRow['PRO_UID']) ? $aRow['PRO_UID'] : ''), 'PRO_TITLE' => (isset($aRow['PRO_TITLE']) ? $aRow['PRO_TITLE'] : ''));
$oDataset->next();
}
$_DBArray['PROCESSES'] = $aProcesses;
$_SESSION['_DBArray'] = $_DBArray;
$_SESSION['PROCESS'] = (isset($_POST['PRO_UID']) ? $_POST['PRO_UID'] : '');
$oDBSource = new DbSource();
$oCriteria = $oDBSource->getCriteriaDBSList($_SESSION['PROCESS']);
$G_PUBLISH->AddContent('propeltable', 'paged-table', 'dbConnections/dbConnections', $oCriteria);
}
G::RenderPage('publish', 'raw');
break;
case 'showConnections': $oDBSource = new DbSource();
$oCriteria = $oDBSource->getCriteriaDBSList( $_SESSION['PROCESS'] );
$oDBSource = new DbSource(); $G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'dbConnections/dbConnections', $oCriteria );
$oCriteria = $oDBSource->getCriteriaDBSList($_SESSION['PROCESS']); }
$G_PUBLISH = new Publisher(); G::RenderPage( 'publish', 'raw' );
$G_PUBLISH->AddContent('propeltable', 'paged-table', 'dbConnections/dbConnections', $oCriteria); break;
G::RenderPage('publish', 'raw'); case 'showConnections':
break; $oDBSource = new DbSource();
$oCriteria = $oDBSource->getCriteriaDBSList( $_SESSION['PROCESS'] );
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'dbConnections/dbConnections', $oCriteria );
G::RenderPage( 'publish', 'raw' );
break;
case 'newDdConnection':
$dbs = new dbConnections( $_SESSION['PROCESS'] );
$dbServices = $dbs->getDbServicesAvailables();
$dbService = $dbs->getEncondeList();
case 'newDdConnection': //we are updating the passwords with encrupt info
$dbs->encryptThepassw( $_SESSION['PROCESS'] );
//end updating
$rows[] = array ('uid' => 'char','name' => 'char'
$dbs = new dbConnections($_SESSION['PROCESS']); );
$dbServices = $dbs->getDbServicesAvailables();
$dbService = $dbs->getEncondeList();
//we are updating the passwords with encrupt info
$dbs->encryptThepassw($_SESSION['PROCESS']);
//end updating
$rows[] = array('uid' => 'char', 'name' => 'char');
foreach($dbServices as $srv) { foreach ($dbServices as $srv) {
$rows[] = array('uid' => $srv['id'], 'name' => $srv['name']); $rows[] = array ('uid' => $srv['id'],'name' => $srv['name']
} );
}
$_DBArray['BDCONNECTIONS'] = $rows; $_DBArray['BDCONNECTIONS'] = $rows;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dbConnections/dbConnections_New', '', ''); $G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'dbConnections/dbConnections_New', '', '' );
G::RenderPage('publish', 'raw'); G::RenderPage( 'publish', 'raw' );
break; break;
case 'editDdConnection':
$dbs = new dbConnections( $_SESSION['PROCESS'] );
$dbServices = $dbs->getDbServicesAvailables();
case 'editDdConnection': $rows[] = array ('uid' => 'char','name' => 'char'
);
$dbs = new dbConnections($_SESSION['PROCESS']); foreach ($dbServices as $srv) {
$dbServices = $dbs->getDbServicesAvailables(); $rows[] = array ('uid' => $srv['id'],'name' => $srv['name']
);
}
$rows[] = array('uid' => 'char', 'name' => 'char'); $_DBArray['BDCONNECTIONS'] = $rows;
foreach($dbServices as $srv) { $_SESSION['_DBArray'] = $_DBArray;
$rows[] = array('uid' => $srv['id'], 'name' => $srv['name']);
}
$_DBArray['BDCONNECTIONS'] = $rows; $o = new DbSource();
$_SESSION['_DBArray'] = $_DBArray; $aFields = $o->load( $_POST['DBS_UID'], $_SESSION['PROCESS'] );
if ($aFields['DBS_PORT'] == '0') {
$aFields['DBS_PORT'] = '';
}
$aFields['DBS_PASSWORD'] = $dbs->getPassWithoutEncrypt( $aFields );
$aFields['DBS_PASSWORD'] = ($aFields['DBS_PASSWORD'] == 'none') ? "" : $aFields['DBS_PASSWORD'];
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'dbConnections/dbConnections_Edit', '', $aFields );
G::RenderPage( 'publish', 'raw' );
break;
case 'saveEditConnection':
$oDBSource = new DbSource();
$oContent = new Content();
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']
);
$o = new DbSource(); $oDBSource->update( $aData );
$aFields = $o->load($_POST['DBS_UID'], $_SESSION['PROCESS']); $oContent->addContent( 'DBS_DESCRIPTION', '', $_POST['dbs_uid'], SYS_LANG, $_POST['desc'] );
if ($aFields['DBS_PORT'] == '0') { break;
$aFields['DBS_PORT'] = ''; case 'saveConnection':
} $oDBSource = new DbSource();
$aFields['DBS_PASSWORD']=$dbs->getPassWithoutEncrypt($aFields); $oContent = new Content();
$aFields['DBS_PASSWORD']=($aFields['DBS_PASSWORD'] == 'none') ? "": $aFields['DBS_PASSWORD']; if (strpos( $_POST['server'], "\\" )) {
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'dbConnections/dbConnections_Edit', '', $aFields); $_POST['port'] = 'none';
G::RenderPage('publish', 'raw'); }
break; $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']
);
$newid = $oDBSource->create( $aData );
$sDelimiter = DBAdapter::getStringDelimiter();
$oContent->addContent( 'DBS_DESCRIPTION', '', $newid, SYS_LANG, $_POST['desc'] );
break;
case 'deleteDbConnection':
try {
$oDBSource = new DbSource();
$oContent = new Content();
case 'saveEditConnection': $DBS_UID = $_POST['dbs_uid'];
$PRO_UID = $_SESSION['PROCESS'];
$oDBSource->remove( $DBS_UID, $PRO_UID );
$oContent->removeContent( 'DBS_DESCRIPTION', "", $DBS_UID );
$result->success = true;
$result->msg = G::LoadTranslation( 'ID_DBCONNECTION_REMOVED' );
} catch (Exception $e) {
$result->success = false;
$result->msg = $e->getMessage();
}
print G::json_encode( $result );
break;
case 'showTestConnection':
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent( 'view', 'dbConnections/dbConnections' );
G::RenderPage( 'publish', 'raw' );
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'];
$oDBSource = new DbSource(); if (($port == 'none') || ($port == 0)) {
$oContent = new Content(); //setting defaults ports
if(strpos($_POST['server'], "\\")) switch ($type) {
$_POST['port'] = 'none'; case 'mysql':
$aData = Array( $port = 3306;
'DBS_UID' => $_POST['dbs_uid'], break;
'PRO_UID' => $_SESSION['PROCESS'], case 'pgsql':
'DBS_TYPE' => $_POST['type'], $port = 5432;
'DBS_SERVER' => $_POST['server'], break;
'DBS_DATABASE_NAME' => $_POST['db_name'], case 'mssql':
'DBS_USERNAME' => $_POST['user'], $port = 1433;
'DBS_PASSWORD' => (($_POST['passwd'] == 'none') ? "": G::encrypt($_POST['passwd'], $_POST['db_name']))."_2NnV3ujj3w", break;
'DBS_PORT' => (($_POST['port'] == 'none') ? "": $_POST['port']), case 'oracle':
'DBS_ENCODE' => $_POST['enc'] $port = 1521;
); break;
}
}
$oDBSource->update($aData); G::LoadClass( 'net' );
$oContent->addContent('DBS_DESCRIPTION', '', $_POST['dbs_uid'], SYS_LANG, $_POST['desc']); $Server = new NET( $server );
break; define( "SUCCESSFULL", 'SUCCESSFULL' );
define( "FAILED", 'FAILED' );
case 'saveConnection': 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 );
$oDBSource = new DbSource(); if ($Server->errno == 0) {
$oContent = new Content(); $response = $Server->tryConnectServer( $type );
if(strpos($_POST['server'], "\\")) if ($response->status == 'SUCCESS') {
$_POST['port'] = 'none'; print (SUCCESSFULL . ',') ;
$aData = Array( } else {
'PRO_UID' => $_SESSION['PROCESS'], print (FAILED . ',' . $Server->error) ;
'DBS_TYPE' => $_POST['type'], }
'DBS_SERVER' => $_POST['server'], } else {
'DBS_DATABASE_NAME' => $_POST['db_name'], print (FAILED . ',' . $Server->error) ;
'DBS_USERNAME' => $_POST['user'], }
'DBS_PASSWORD' => (($_POST['passwd'] == 'none') ? "": G::encrypt($_POST['passwd'], $_POST['db_name']))."_2NnV3ujj3w", break;
'DBS_PORT' => (($_POST['port'] == 'none') ? "": $_POST['port']), case 4:
'DBS_ENCODE' => $_POST['enc'] $Server->loginDbServer( $user, $passwd );
); $Server->setDataBase( $db_name, $port );
$newid = $oDBSource->create($aData); if ($Server->errno == 0) {
$sDelimiter = DBAdapter::getStringDelimiter(); $response = $Server->tryConnectServer( $type );
$oContent->addContent('DBS_DESCRIPTION', '', $newid, SYS_LANG, $_POST['desc']); if ($response->status == 'SUCCESS') {
$response = $Server->tryOpenDataBase( $type );
if ($response->status == 'SUCCESS') {
print (SUCCESSFULL . ',' . $Server->error) ;
} else {
print (FAILED . ',' . $Server->error) ;
}
} else {
print (FAILED . ',' . $Server->error) ;
}
} else {
print (FAILED . ',' . $Server->error) ;
}
break;
default:
print ('finished') ;
}
break;
case 'showEncodes':
G::LoadThirdParty( 'pear/json', 'class.json' );
$oJSON = new Services_JSON();
$engine = $_POST['engine'];
break; if ($engine != "0") {
$dbs = new dbConnections();
echo $oJSON->encode( $dbs->getEncondeList( $engine ) );
case 'deleteDbConnection': } else {
try{ echo '[["0","..."]]';
$oDBSource = new DbSource(); }
$oContent = new Content(); break;
$DBS_UID = $_POST['dbs_uid'];
$PRO_UID = $_SESSION['PROCESS'];
$oDBSource->remove($DBS_UID, $PRO_UID);
$oContent->removeContent('DBS_DESCRIPTION', "", $DBS_UID);
$result->success = true;
$result->msg = G::LoadTranslation('ID_DBCONNECTION_REMOVED');
}catch (Exception $e) {
$result->success = false;
$result->msg = $e->getMessage();
}
print G::json_encode($result);
break;
case 'showTestConnection':
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('view', 'dbConnections/dbConnections');
G::RenderPage('publish', 'raw');
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');
$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.',');
} else {
print (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);
} else {
print (FAILED.','.$Server->error);
}
} else {
print (FAILED.','.$Server->error);
}
} else {
print (FAILED.','.$Server->error);
}
break;
default:
print('finished');
}
break;
case 'showEncodes':
G::LoadThirdParty('pear/json','class.json');
$oJSON = new Services_JSON();
$engine = $_POST['engine'];
if($engine != "0"){
$dbs = new dbConnections();
echo $oJSON->encode($dbs->getEncondeList($engine));
} else {
echo '[["0","..."]]';
}
break;
} }

View File

@@ -1,26 +1,27 @@
<?php <?php
/**
* @Author: Erik Amaru Ortiz <erik@colosa.com>
* @Description:This is a additional configuration for load all connections; if exist in a particular proccess
* @Date: 15-05-2008
*/
if( isset($_SESSION['PROCESS']) ){
$pro = include (PATH_CORE . "config/databases.php");
G::LoadClass('dbConnections');
$oDbConnections = new dbConnections($_SESSION['PROCESS']); /**
foreach( $oDbConnections->connections as $db ) { * Description: This is a additional configuration for load all connections; if exist in a particular proccess
$db['DBS_PASSWORD'] = $oDbConnections->getPassWithoutEncrypt($db); * @Date: 15-05-2008
$dbsPort = ($db['DBS_PORT'] == '') ? ('') : (':'.$db['DBS_PORT']); *
$ENCODE = (trim($db['DBS_ENCODE']) == '')? '': '?encoding=' . $db['DBS_ENCODE']; * @author : Erik Amaru Ortiz <erik@colosa.com>
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; if (isset( $_SESSION['PROCESS'] )) {
$pro = include (PATH_CORE . "config/databases.php");
G::LoadClass( 'dbConnections' );
$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;
} else { } 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_SERVER'] . $dbsPort . '/' . $db['DBS_DATABASE_NAME'] . $ENCODE;
} }
$pro['datasources'][$db['DBS_UID']]['adapter'] = $db['DBS_TYPE']; $pro['datasources'][$db['DBS_UID']]['adapter'] = $db['DBS_TYPE'];
} }
return $pro; return $pro;
} }
?>

View File

@@ -1,21 +1,23 @@
<?php <?php
/** /**
* @Author: Erik Amaru Ortiz <erik@colosa.com> * ription:This is a additional configuration for load all connections; if exist in a particular proccess
* @Description:This is a additional configuration for load all connections; if exist in a particular proccess * @Date: 15-05-2008
* @Date: 15-05-2008 *
* @author : Erik Amaru Ortiz <erik@colosa.com>
*/ */
$dbHash = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH)); $dbHash = @explode( SYSTEM_HASH, G::decrypt( HASH_INSTALLATION, SYSTEM_HASH ) );
$host = $dbHash[0]; $host = $dbHash[0];
$user = $dbHash[1]; $user = $dbHash[1];
$pass = $dbHash[2]; $pass = $dbHash[2];
$dbName = DB_NAME; $dbName = DB_NAME;
$pro = include (PATH_CORE . "config/databases.php"); $pro = include (PATH_CORE . "config/databases.php");
$pro['datasources']['root'] = Array (); $pro['datasources']['root'] = Array ();
$pro['datasources']['root']['connection'] = "mysql://$user:$pass@$host/$dbName?encoding=utf8"; $pro['datasources']['root']['connection'] = "mysql://$user:$pass@$host/$dbName?encoding=utf8";
$pro['datasources']['root']['adapter'] = "mysql"; $pro['datasources']['root']['adapter'] = "mysql";
return $pro; return $pro;