Exemplo n.º 1
0
function addDBConnection($name, $desc, $server, $login = '', $password = '', $type = -1, $schema = '')
{
    global $config_db, $user;
    // Create Connection Class
    $conn = new DB_Connection();
    $conn->setName($name);
    $conn->setDesc($desc);
    $conn->setServer($server);
    $conn->setUser($login);
    $conn->setPassword($password);
    $conn->setType($type);
    $conn->setSchema($schema);
    // Validate Key
    if ($conn->validateKey()) {
        if (checkDBConnectionTable()) {
            // Save to Database
            $sql = "INSERT INTO db_connections (" . "Name, " . "Desc, " . "Server, " . "User, " . "Password, " . "Type, " . "Schema, " . "IV, " . "createDate, " . "createdBy, " . "updateDate, " . "updatedBy" . ") VALUES (" . $conn->getDBInsertValues() . ", '" . date("Y-m-d") . "', " . "'" . $user->getEmail() . "', " . "'" . date("Y-m-d") . "', " . "'" . $user->getEmail() . "')";
            // showMessage($sql);
            $config_db->exec($sql);
            // Reload Database Connections
            loadDBConnections();
        }
    } else {
        die('Invalid Encryption Key....');
    }
}