/**
  * will update the Relational DB table; if trying to update the table containing the key, give both $tableName1 and $keyTable as the
  * 			same value.
  * @param: $tableName1: the table you wish to update
  * @param: $keyTable: the table containing the cross-table Key
  * @param: $foreignkey: the foreignKey you're using to check;
  * @param: $valueForKey: the value for the foreignKey;
  * @param: $primaryKey: the primaryKey of the database (the cross-table Key);
  * @param: $arrayOfValues: the values being updated;
  * Postcondition: updates the table if entry already exists;
  * Postcondition: creates a new entry if entry does not exist;
  */
 public function updateTable($tableName1, $keyTable, $foreignKey, $valueForKey, $primaryKey, $arrayOfValues, $condition)
 {
     $result = $this->selectFromTable($keyTable, $foreignKey, $valueForKey);
     $num = mysql_num_rows($result);
     if ($num == 0) {
         $this->insertIntoTable($tableName1, $keyTable, $foreignKey, $valueForKey, $primaryKey, $arrayOfValues);
         return true;
     } else {
         parent::updateTable($tableName1, $arrayOfValues, $condition);
         return true;
     }
 }
Ejemplo n.º 2
0
                    $sStepName = $val->sStepName;
                }
            }
            if (class_exists($sNamespace . "plugin")) {
                if (!$aPreviousStep) {
                    $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = '';
                } else {
                    $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP'] = $aPreviousStep['PAGE'];
                    $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['PREVIOUS_STEP_LABEL'] = G::loadTranslation("ID_PREVIOUS_STEP");
                }
                $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP'] = $aNextStep['PAGE'];
                $Fields['APP_DATA']['__DYNAFORM_OPTIONS']['NEXT_STEP_LABEL'] = G::loadTranslation("ID_NEXT_STEP");
                /** Added By erik date: 16-05-08
                 * Description: this was added for the additional database connections */
                G::LoadClass('dbConnections');
                $oDbConnections = new dbConnections($_SESSION['PROCESS']);
                $oDbConnections->loadAdditionalConnections();
                $stepFilename = "{$sNamespace}/{$sStepName}";
                G::evalJScript("\n        if (parent.setCurrent) {\n          parent.setCurrent('" . $_GET['UID'] . "');\n        }");
                $G_PUBLISH->AddContent('content', $stepFilename);
            } else {
                $aMessage['MESSAGE'] = G::loadTranslation('ID_EXTERNAL_STEP_MISSING', SYS_LANG, array("plugin" => $sNamespace));
                $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage);
            }
            break;
    }
    //Add content content step - End
} catch (Exception $e) {
    G::SendTemporalMessage(G::LoadTranslation('ID_PROCESS_DEF_PROBLEM'), 'error', 'string', 3, 100);
    $aMessage = array();
    $aMessage['MESSAGE'] = $e->getMessage();
Ejemplo n.º 3
0
 /**
  *
  * @param      string $name The database name.
  * @return     Connection A database connection
  * @throws     PropelException - if no conneciton params, or SQLException caught when trying to connect.
  */
 public static function getConnection($name = null)
 {
     if ($name === null) {
         $name = self::getDefaultDB();
     }
     $con = isset(self::$connectionMap[$name]) ? self::$connectionMap[$name] : null;
     if ($con === null || $name === 'dbarray') {
         $dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
         if ($dsn === null) {
             if (isset($_SESSION['PROCESS'])) {
                 /** Added By Erik Amaru <erik@colosa.com *******************************
                  * @date: 27-05-08 11:48                                                *
                  * @Description: this was added for the additional database connections *
                  ***********************************************************************/
                 G::LoadClass('dbConnections');
                 $oDbConnections = new dbConnections($_SESSION['PROCESS']);
                 $oDbConnections->loadAdditionalConnections();
                 $dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
             } else {
                 throw new PropelException("No connection params set for " . $name);
             }
         }
         include_once 'creole/Creole.php';
         // if specified, use custom driver
         if (isset(self::$configuration['datasources'][$name]['driver'])) {
             Creole::registerDriver($dsn['phptype'], self::$configuration['datasources'][$name]['driver']);
         }
         try {
             $con = Creole::getConnection($dsn);
         } catch (SQLException $e) {
             throw new PropelException($e);
         }
         self::$connectionMap[$name] = $con;
     }
     return $con;
 }
Ejemplo n.º 4
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 Bootstrap::json_encode($dbs->getEncondeList($engine));
        } else {
            echo '[["0","..."]]';
        }
        break;
}
<?php

/**
 * Description: This is a additional configuration for load all connections; if exist in a particular proccess
 * @Date: 15-05-2008
 *
 * @author : Erik Amaru Ortiz <erik@colosa.com>
 */
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);
        $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_TNS"];
        }
        $pro['datasources'][$db['DBS_UID']]['adapter'] = $db['DBS_TYPE'];
    }
    return $pro;
}
Ejemplo n.º 6
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;
}
 function getDBVersion()
 {
     $sMySQLVersion = '?????';
     if (defined("DB_HOST")) {
         G::LoadClass('net');
         G::LoadClass('dbConnections');
         $dbNetView = new NET(DB_HOST);
         $dbNetView->loginDbServer(DB_USER, DB_PASS);
         $dbConns = new dbConnections('');
         $availdb = '';
         foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
             if ($availdb != '') {
                 $availdb .= ', ';
             }
             $availdb .= $val['name'];
         }
         try {
             $sMySQLVersion = $dbNetView->getDbServerVersion('mysql');
         } catch (Exception $oException) {
             $sMySQLVersion = '?????';
         }
     }
     return $sMySQLVersion;
 }
Ejemplo n.º 8
0
 private function _getSystemInfo()
 {
     G::LoadClass("system");
     if (getenv('HTTP_CLIENT_IP')) {
         $ip = getenv('HTTP_CLIENT_IP');
     } else {
         if (getenv('HTTP_X_FORWARDED_FOR')) {
             $ip = getenv('HTTP_X_FORWARDED_FOR');
         } else {
             $ip = getenv('REMOTE_ADDR');
         }
     }
     $redhat = '';
     if (file_exists('/etc/redhat-release')) {
         $fnewsize = filesize('/etc/redhat-release');
         $fp = fopen('/etc/redhat-release', 'r');
         $redhat = trim(fread($fp, $fnewsize));
         fclose($fp);
     }
     $redhat .= " (" . PHP_OS . ")";
     if (defined("DB_HOST")) {
         G::LoadClass('net');
         G::LoadClass('dbConnections');
         $dbNetView = new NET(DB_HOST);
         $dbNetView->loginDbServer(DB_USER, DB_PASS);
         $dbConns = new dbConnections('');
         $availdb = '';
         foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
             if ($availdb != '') {
                 $availdb .= ', ';
             }
             $availdb .= $val['name'];
         }
         try {
             $sMySQLVersion = $dbNetView->getDbServerVersion(DB_ADAPTER);
         } catch (Exception $oException) {
             $sMySQLVersion = '?????';
         }
     }
     if (file_exists(PATH_HTML . "lib/versions")) {
         $versions = json_decode(file_get_contents(PATH_HTML . "lib/versions"), true);
         $pmuiVer = $versions["pmui_ver"];
         $mafeVer = $versions["mafe_ver"];
         $pmdynaformVer = $versions["pmdynaform_ver"];
     } else {
         $pmuiVer = $mafeVer = $pmdynaformVer = "(unknown)";
     }
     $sysSection = G::loadTranslation('ID_SYSTEM_INFO');
     $pmSection = G::LoadTranslation('ID_PROCESS_INFORMATION');
     $properties = array();
     $ee = class_exists('pmLicenseManager') ? " - Enterprise Edition" : '';
     $systemName = 'ProcessMaker';
     if (defined('SYSTEM_NAME')) {
         $systemName = SYSTEM_NAME;
     }
     $properties[] = array($systemName . ' Ver.', System::getVersion() . $ee, $pmSection);
     $properties[] = array("PMUI JS Lib. Ver.", $pmuiVer, $pmSection);
     $properties[] = array("MAFE JS Lib. Ver.", $mafeVer, $pmSection);
     $properties[] = array("PM Dynaform JS Lib. Ver.", $pmdynaformVer, $pmSection);
     if (file_exists(PATH_DATA . 'log/upgrades.log')) {
         $properties[] = array(G::LoadTranslation('ID_UPGRADES_PATCHES'), '<a href="#" onclick="showUpgradedLogs(); return false;">' . G::LoadTranslation('ID_UPGRADE_VIEW_LOG') . '</a>', $pmSection);
     } else {
         $properties[] = array(G::LoadTranslation('ID_UPGRADES_PATCHES'), G::LoadTranslation('ID_UPGRADE_NEVER_UPGRADE'), $pmSection);
     }
     $properties[] = array(G::LoadTranslation('ID_OPERATING_SYSTEM'), $redhat, $sysSection);
     $properties[] = array(G::LoadTranslation('ID_TIME_ZONE'), defined('TIME_ZONE') ? TIME_ZONE : "Unknown", $sysSection);
     $properties[] = array(G::LoadTranslation('ID_WEB_SERVER'), getenv('SERVER_SOFTWARE'), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_NAME'), getenv('SERVER_NAME'), $pmSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_IP'), $this->lookup($ip), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_PHP_VERSION'), phpversion(), $sysSection);
     if (defined("DB_HOST")) {
         $properties[] = array(G::LoadTranslation('ID_DATABASE'), $dbNetView->dbName(DB_ADAPTER) . ' (Version ' . $sMySQLVersion . ')', $pmSection);
         $properties[] = array(G::LoadTranslation('ID_DATABASE_SERVER'), DB_HOST, $pmSection);
         $properties[] = array(G::LoadTranslation('ID_DATABASE_NAME'), DB_NAME, $pmSection);
         $properties[] = array(G::LoadTranslation('ID_AVAILABLE_DB'), $availdb, $sysSection);
     } else {
         $properties[] = array(G::LoadTranslation('ID_DATABASE'), "Not defined", $pmSection);
         $properties[] = array(G::LoadTranslation('ID_DATABASE_SERVER'), "Not defined", $pmSection);
         $properties[] = array(G::LoadTranslation('ID_DATABASE_NAME'), "Not defined", $pmSection);
         $properties[] = array(G::LoadTranslation('ID_AVAILABLE_DB'), "Not defined", $sysSection);
     }
     $properties[] = array(G::LoadTranslation('ID_WORKSPACE'), defined("SYS_SYS") ? SYS_SYS : "Not defined", $pmSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_PROTOCOL'), getenv('SERVER_PROTOCOL'), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_PORT'), getenv('SERVER_PORT'), $sysSection);
     //$sysSection[] = array('Remote Host', getenv ('REMOTE_HOST'), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_SERVER_NAME'), getenv('SERVER_ADDR'), $sysSection);
     $properties[] = array(G::LoadTranslation('ID_USER_BROWSER'), getenv('HTTP_USER_AGENT'), $sysSection);
     return $properties;
 }
Ejemplo n.º 9
0
 private function _getSystemInfo()
 {
     G::LoadClass("system");
     if (getenv('HTTP_CLIENT_IP')) {
         $ip = getenv('HTTP_CLIENT_IP');
     } else {
         if (getenv('HTTP_X_FORWARDED_FOR')) {
             $ip = getenv('HTTP_X_FORWARDED_FOR');
         } else {
             $ip = getenv('REMOTE_ADDR');
         }
     }
     $redhat = '';
     if (file_exists('/etc/redhat-release')) {
         $fnewsize = filesize('/etc/redhat-release');
         $fp = fopen('/etc/redhat-release', 'r');
         $redhat = trim(fread($fp, $fnewsize));
         fclose($fp);
     }
     $redhat .= " (" . PHP_OS . ")";
     if (defined("DB_HOST")) {
         G::LoadClass('net');
         G::LoadClass('dbConnections');
         $dbNetView = new NET(DB_HOST);
         $dbNetView->loginDbServer(DB_USER, DB_PASS);
         $dbConns = new dbConnections('');
         $availdb = '';
         foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
             if ($availdb != '') {
                 $availdb .= ', ';
             }
             $availdb .= $val['name'];
         }
         try {
             $sMySQLVersion = $dbNetView->getDbServerVersion(DB_ADAPTER);
         } catch (Exception $oException) {
             $sMySQLVersion = '?????';
         }
     }
     $sysSection = G::loadTranslation('ID_SYSTEM_INFO');
     $pmSection = 'ProcessMaker Information';
     $properties = array();
     $ee = class_exists('pmLicenseManager') ? " - Enterprise Edition" : '';
     $properties[] = array('ProcessMaker Ver.', System::getVersion() . $ee, $pmSection);
     $properties[] = array('Operating System', $redhat, $sysSection);
     $properties[] = array('Time Zone', defined('TIME_ZONE') ? TIME_ZONE : "Unknown", $sysSection);
     $properties[] = array('Web Server', getenv('SERVER_SOFTWARE'), $sysSection);
     $properties[] = array('Server Name', getenv('SERVER_NAME'), $pmSection);
     $properties[] = array('Server IP Address', $this->lookup($ip), $sysSection);
     $properties[] = array('PHP Version', phpversion(), $sysSection);
     if (defined("DB_HOST")) {
         $properties[] = array('Data Base', $dbNetView->dbName(DB_ADAPTER) . ' (Version ' . $sMySQLVersion . ')', $pmSection);
         $properties[] = array('Data Base Server', DB_HOST, $pmSection);
         $properties[] = array('Data Base Name', DB_NAME, $pmSection);
         $properties[] = array('Available DB Engines', $availdb, $sysSection);
     } else {
         $properties[] = array('Data Base', "Not defined", $pmSection);
         $properties[] = array('Data Base Server', "Not defined", $pmSection);
         $properties[] = array('Data Base Name', "Not defined", $pmSection);
         $properties[] = array('Available DB Engines', "Not defined", $sysSection);
     }
     $properties[] = array('Workspace', defined("SYS_SYS") ? SYS_SYS : "Not defined", $pmSection);
     $properties[] = array('Server Protocol', getenv('SERVER_PROTOCOL'), $sysSection);
     $properties[] = array('Server Port', getenv('SERVER_PORT'), $sysSection);
     //$properties[] = array('Remote Host', getenv ('REMOTE_HOST'), $sysSection);
     $properties[] = array('Server Addr.', getenv('SERVER_ADDR'), $sysSection);
     $properties[] = array('User\'s Browser', getenv('HTTP_USER_AGENT'), $sysSection);
     return $properties;
 }
 public function __construct($dbname, $dbhost, $dbuser, $dbpass = null)
 {
     parent::__construct($dbname, $dbhost, $dbuser, $dbpass);
     $this->open_db_connection();
 }
Ejemplo n.º 11
0
function get_infoOnPM($workspace)
{
    $infoPM = array();
    $Fields = getSysInfo();
    $Fields['WORKSPACE_NAME'] = $workspace;
    if (defined("DB_HOST")) {
        G::LoadClass('net');
        G::LoadClass('dbConnections');
        $dbNetView = new NET(DB_HOST);
        $dbNetView->loginDbServer(DB_USER, DB_PASS);
        $dbConns = new dbConnections('');
        $availdb = '';
        foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
            if ($availdb != '') {
                $availdb .= ', ';
            }
            $availdb .= $val['name'];
        }
        try {
            $sMySQLVersion = $dbNetView->getDbServerVersion('mysql');
        } catch (Exception $oException) {
            $sMySQLVersion = 'Unknown';
        }
        $Fields['DATABASE'] = $dbNetView->dbName(DB_ADAPTER) . ' (Version ' . $sMySQLVersion . ')';
        $Fields['DATABASE_SERVER'] = DB_HOST;
        $Fields['DATABASE_NAME'] = DB_NAME;
        $Fields['AVAILABLE_DB'] = $availdb;
    } else {
        $Fields['DATABASE'] = "Not defined";
        $Fields['DATABASE_SERVER'] = $info_db['adap'];
        $Fields['DATABASE_NAME'] = "Not defined";
        $Fields['AVAILABLE_DB'] = "Not defined";
    }
    $info_db = get_DirDB($workspace);
    $Fields['MYSQL_DATA_DIR'] = $info_db['datadir'];
    $Fields['PLUGINS_LIST'] = get_plugins();
    $Fields['DB_ADAPTER'] = $info_db['DB_ADAPTER'];
    $Fields['DB_HOST'] = $info_db['DB_HOST'];
    $Fields['DB_NAME'] = $info_db['DB_NAME'];
    $Fields['DB_USER'] = $info_db['DB_USER'];
    $Fields['DB_PASS'] = $info_db['DB_PASS'];
    $Fields['DB_RBAC_HOST'] = $info_db['DB_RBAC_HOST'];
    $Fields['DB_RBAC_NAME'] = $info_db['DB_RBAC_NAME'];
    $Fields['DB_RBAC_USER'] = $info_db['DB_RBAC_USER'];
    $Fields['DB_RBAC_PASS'] = $info_db['DB_RBAC_PASS'];
    $Fields['DB_REPORT_HOST'] = $info_db['DB_REPORT_HOST'];
    $Fields['DB_REPORT_NAME'] = $info_db['DB_REPORT_NAME'];
    $Fields['DB_REPORT_USER'] = $info_db['DB_REPORT_USER'];
    $Fields['DB_REPORT_PASS'] = $info_db['DB_REPORT_PASS'];
    $infoPM = $Fields;
    return $infoPM;
}
Ejemplo n.º 12
0
    }
}
$redhat = '';
if (file_exists('/etc/redhat-release')) {
    $fnewsize = filesize('/etc/redhat-release');
    $fp = fopen('/etc/redhat-release', 'r');
    $redhat = trim(fread($fp, $fnewsize));
    fclose($fp);
}
$redhat .= " (" . PHP_OS . ")";
if (defined("DB_HOST")) {
    G::LoadClass('net');
    G::LoadClass('dbConnections');
    $dbNetView = new NET(DB_HOST);
    $dbNetView->loginDbServer(DB_USER, DB_PASS);
    $dbConns = new dbConnections('');
    $availdb = '';
    foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
        if ($availdb != '') {
            $availdb .= ', ';
        }
        $availdb .= $val['name'];
    }
    try {
        $sMySQLVersion = $dbNetView->getDbServerVersion(DB_ADAPTER);
    } catch (Exception $oException) {
        $sMySQLVersion = '?????';
    }
}
$Fields['SYSTEM'] = $redhat;
if (defined("DB_HOST")) {
Ejemplo n.º 13
0
}
function getRanking($con, $type, $status, $range, $limit, $start)
{
    $resArray = $con->getRanking($type, $status, $range, $limit, $start);
    if ($resArray["Status"] < 0) {
        show_error($resArray["Status"], $resArray["Content"]);
    } else {
        if ($resArray["Status"] == 0) {
            sentJSON(0, "無資料", null);
        } else {
            sentJSON($resArray["Status"], "成功取得清單", $resArray["Content"]);
        }
    }
}
//連線至資料庫,並開始準備查詢
$con = new dbConnections();
if ($con->status()) {
    //先把URI全部轉大寫省麻煩
    $API = strtoupper($_SERVER["REQUEST_URI"]);
    //確認資料放在GET還是POST
    //另一種方法是$_SERVER["REQUEST_METHOD"]
    if (isset($_GET["UID"])) {
        $dataForm = $_GET;
        $API = substr($API, 0, strrpos($_SERVER["REQUEST_URI"], "?"));
    } else {
        if (isset($_POST["UID"])) {
            $dataForm = $_POST;
        } else {
            show_error(-1, "請輸入UID");
        }
    }