Opens the KphpDB file of id $dbid with the password $kphpdbPwd.
@param $dbid A database ID.
@param $kphpdbPwd The password of the KphpDB file.
@return A non-null KpbpDB instance.
@throws KeePassPHPException
559500
private static function openKphpDB($dbid, $kphpdbPwd)
	{
		$kphpdbFile = self::$_kphpdbManager->getContentFromKey($dbid);
		if($kphpdbFile == null)
			throw new KeePassPHPException(
				"KphpDB file not found or void (ID = " . $dbid . ").");
		$error = null;
		$reader = new StringReader($kphpdbFile);
		$kphpdb = KphpDB::loadFromKdbx($reader,
			new KeyFromPassword($kphpdbPwd, KdbxFile::HASH), $error);
		$reader->close();
		if($kphpdb == null)
			throw new KeePassPHPException($error);
		return $kphpdb;
	}
174949
public function setBlameGuids($guids = [], $checkValid = true)
    {
        if (!is_array($guids) || $this->multiBlamesAttribute === false) {
            return null;
        }
        if ($checkValid) {
            $guids = $this->unsetInvalidBlames($guids);
        }
        $multiBlamesAttribute = $this->multiBlamesAttribute;
        $this->$multiBlamesAttribute = Number::composite_guid($guids);
        return $guids;
    }
1243499
public static function existsKphpDB($dbid)
	{
		if(!self::$_started)
		{
			self::addDebug("KeepassPHP is not started!");
			return false;
		}
		return self::$_kphpdbManager->existsKey($dbid);
	}
629739
public function guid($guid, $isPermalink = false)
    {
        $this->guid = $guid;
        $this->isPermalink = $isPermalink;

        return $this;
    }
777320
public static function addPassword(CompositeKey $mkey, $pwd)
	{
		$mkey->addKey(self::keyFromPassword($pwd));
		return true;
	}
870321
public function gpgSign($keyId = null)
    {
        $this->gpgSignIsset = true;
        $this->arguments[]  = '--gpg-sign' . ($keyId ? '=' . $keyId : '');
        return $this;
    }
515251
public function store($dirId)
    {

        $parentDir = $this->getDirOrFail($dirId);

        if (!$dirName = Input::get('folderName')) {
            $this->flashMessage('dirname-missing');
            return $this->redirectTo('index', $dirId);
        }

        $dir = $this->fileDB->create();
        $dir->setMimeType('inode/directory');

        $dir->setDir($parentDir);
        $dir->setName($dirName);
        $this->fileDB->save($dir);

        return $this->redirectTo('index', [$dir->getId()]);

    }
757439
protected function initConnection($username = null, $passwd = null) {
		if (is_null(self::$_parsedDsn['charset'])) {
			self::$_parsedDsn['charset'] = 'UTF8';
		}

		$session_mode = OCI_DEFAULT;
		if ($username === '/' && empty($passwd)) {
			$session_mode = OCI_CRED_EXT;
		}

		if ($this->getAttribute(PDO::ATTR_PERSISTENT)) {
			$this->_dbh = @oci_pconnect($username, $passwd, self::$_parsedDsn['dbname'], self::$_parsedDsn['charset'], $session_mode);
		}
		else {
			$this->_dbh = @oci_new_connect ($username, $passwd, self::$_parsedDsn['dbname'], self::$_parsedDsn['charset'], $session_mode);
		}

		if (YII_DEBUG) {
			$this->checkError($this->_dbh);
		}
		else {
			if ($this->_dbh === false) {
				throw new CDbNoConnectionException('No DB');
			}
		}
	}
650181
public function write($sessionID, $sessionData): bool
    {
        $dbData = ['session_id' => $sessionID, 'session_access_ts' => time(), 'session_data' => $sessionData];
        $query = $this->dbClass->prepare()->replaceInto($this->dbTable)->set($dbData);
        $result = $this->dbClass->execute($query) == 1 ? true : false;

        return $result;
    }
1153618
public function connect($sDbHost = '', $sDbUser = '', $sDbPass = '', $sDbName = '')
    {
        //  Close the connection if one is open
        if (!is_null($this->oDb)) {
            $this->oDb = null;
        }

        $sDbHost = !empty($sDbHost) ? $sDbHost : (defined('DEPLOY_DB_HOST') ? DEPLOY_DB_HOST : '');
        $sDbUser = !empty($sDbUser) ? $sDbUser : (defined('DEPLOY_DB_USERNAME') ? DEPLOY_DB_USERNAME : '');
        $sDbPass = !empty($sDbPass) ? $sDbPass : (defined('DEPLOY_DB_PASSWORD') ? DEPLOY_DB_PASSWORD : '');
        $sDbName = !empty($sDbName) ? $sDbName : (defined('DEPLOY_DB_DATABASE') ? DEPLOY_DB_DATABASE : '');

        try {

            $this->oDb = new \PDO(
                'mysql:host=' . $sDbHost . ';dbname=' . $sDbName . ';charset=utf8', $sDbUser, $sDbPass
            );

            $this->oDb->exec('set names utf8');
            $this->oDb->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

        } catch (\Exception $e) {
            throw new ConnectionException(
                sprintf(self::ERR_MSG_CONNECTION_FAILED, $e->getCode(), $e->getMessage()),
                self::ERR_NUM_CONNECTION_FAILED
            );
        }
    }
1301509
protected function opendb() {
    // Only do one open
    
    if($this->db) {
      return $this->db;
    }
    //echo "$this->host, $this->user, $this->password";
    try {
      $db = @new PDO($this->host, $this->user, $this->password);
    } catch(PDOException $e) {
      $this->errno = $e->getCode();
      $this->error = $e->getMessage();
      throw new SqlException(__METHOD__.  " Connection failed: $this->host", $this);
    }

    $this->db = $db; // set this right away so if we get an error below $this->db is valid

    return $db;
  }
326738
public static function view_database($databaseid) {

        $params = self::validate_parameters(self::view_database_parameters(), array('databaseid' => $databaseid));
        $warnings = array();

        list($database, $course, $cm, $context) = self::validate_database($params['databaseid']);

        // Call the data/lib API.
        data_view($database, $course, $cm, $context);

        $result = array();
        $result['status'] = true;
        $result['warnings'] = $warnings;
        return $result;
    }
125513
def _get_db_password(dbSystem,db,user):
    
    import string, getpass, os
    dbrc = os.environ['HOME']+"/.dbrc"
    password={}
    if os.access(dbrc,os.R_OK):
        fd=open(dbrc)
        lines=fd.readlines()
        for line in lines:
            entry=line.split()
            if entry[0]==dbSystem and entry[1]==db and entry[2]==user:
                return entry[3]

    return getpass.getpass()
317709
public function setPasswordDb ($passwordDb)
		{
			$this->_password = Yii::$app->settings->get($passwordDb);
			$this->setTransportDb();
		}
1272066
public static function get_fields($databaseid) {
        global $PAGE;

        $params = array('databaseid' => $databaseid);
        $params = self::validate_parameters(self::get_fields_parameters(), $params);
        $fields = $warnings = array();

        list($database, $course, $cm, $context) = self::validate_database($params['databaseid']);

        // Check database is open in time.
        $canmanageentries = has_capability('mod/data:manageentries', $context);
        data_require_time_available($database, $canmanageentries);

        $fieldinstances = data_get_field_instances($database);

        foreach ($fieldinstances as $fieldinstance) {
            $record = $fieldinstance->field;
            // Now get the configs the user can see with his current permissions.
            $configs = $fieldinstance->get_config_for_external();
            foreach ($configs as $name => $value) {
                // Overwrite.
                $record->{$name} = $value;
            }

            $exporter = new field_exporter($record, array('context' => $context));
            $fields[] = $exporter->export($PAGE->get_renderer('core'));
        }

        $result = array(
            'fields' => $fields,
            'warnings' => $warnings
        );
        return $result;
    }
1182398
protected function databaseSetupPassword()
    {
        $pass        = $this->secret('Please enter the database password');
        $passConfirm = $this->secret('Please confirm the database password');

        if ($pass != $passConfirm) {
            $this->error('[ERROR] Database passwords do not match. Please retry.');
            $this->databaseSetupPassword();
        }

        return $pass;
    }
10296
public function setDbConn($dbconfig = [])
    {
        if (empty($dbconfig)) {
            $this->dbconfig = config('database');
            //$this->dbconfig = Config::get('database');
        } else {
            $this->dbconfig = $dbconfig;
        }
        return $this;
    }