当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Config::setValues方法代码示例

本文整理汇总了PHP中OC_Config::setValues方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Config::setValues方法的具体用法?PHP OC_Config::setValues怎么用?PHP OC_Config::setValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC_Config的用法示例。


在下文中一共展示了OC_Config::setValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setupDatabase

	public function setupDatabase($username) {
		//check if the database user has admin right
		$masterConnectionInfo = array( "Database" => "master", "UID" => $this->dbuser, "PWD" => $this->dbpassword);

		$masterConnection = @sqlsrv_connect($this->dbhost, $masterConnectionInfo);
		if(!$masterConnection) {
			$entry = '';
			if( ($errors = sqlsrv_errors() ) != null) {
				$entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
			}
			throw new \OC\DatabaseSetupException($this->trans->t('MS SQL username and/or password not valid: %s', array($entry)),
					$this->trans->t('You need to enter either an existing account or the administrator.'));
		}

		\OC_Config::setValues([
			'dbuser'		=> $this->dbuser,
			'dbpassword'	=> $this->dbpassword,
		]);

		$this->createDBLogin($masterConnection);

		$this->createDatabase($masterConnection);

		$this->createDBUser($masterConnection);

		sqlsrv_close($masterConnection);

		$this->createDatabaseStructure();
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:29,代码来源:mssql.php

示例2: setupDatabase

 public function setupDatabase($username)
 {
     //check if the database user has admin right
     $connection = @mysql_connect($this->dbhost, $this->dbuser, $this->dbpassword);
     if (!$connection) {
         throw new \OC\DatabaseSetupException($this->trans->t('MySQL/MariaDB username and/or password not valid'), $this->trans->t('You need to enter either an existing account or the administrator.'));
     }
     //user already specified in config
     $oldUser = \OC_Config::getValue('dbuser', false);
     //we don't have a dbuser specified in config
     if ($this->dbuser != $oldUser) {
         //add prefix to the admin username to prevent collisions
         $adminUser = substr('oc_' . $username, 0, 16);
         $i = 1;
         while (true) {
             //this should be enough to check for admin rights in mysql
             $query = "SELECT user FROM mysql.user WHERE user='{$adminUser}'";
             $result = mysql_query($query, $connection);
             //current dbuser has admin rights
             if ($result) {
                 //new dbuser does not exist
                 if (mysql_num_rows($result) === 0) {
                     //use the admin login data for the new database user
                     $this->dbuser = $adminUser;
                     //create a random password so we don't need to store the admin password in the config file
                     $this->dbpassword = \OC_Util::generateRandomBytes(30);
                     $this->createDBUser($connection);
                     break;
                 } else {
                     //repeat with different username
                     $length = strlen((string) $i);
                     $adminUser = substr('oc_' . $username, 0, 16 - $length) . $i;
                     $i++;
                 }
             } else {
                 break;
             }
         }
         \OC_Config::setValues(['dbuser' => $this->dbuser, 'dbpassword' => $this->dbpassword]);
     }
     //create the database
     $this->createDatabase($connection);
     //fill the database if needed
     $query = 'select count(*) from information_schema.tables' . " where table_schema='" . $this->dbname . "' AND table_name = '" . $this->tableprefix . "users';";
     $result = mysql_query($query, $connection);
     if ($result) {
         $row = mysql_fetch_row($result);
     }
     if (!$result or $row[0] == 0) {
         \OC_DB::createDbFromStructure($this->dbDefinitionFile);
     }
     mysql_close($connection);
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:53,代码来源:mysql.php

示例3: initialize

 public function initialize($config)
 {
     $dbUser = $config['dbuser'];
     $dbPass = $config['dbpass'];
     $dbName = $config['dbname'];
     $dbHost = !empty($config['dbhost']) ? $config['dbhost'] : 'localhost';
     $dbTablePrefix = isset($config['dbtableprefix']) ? $config['dbtableprefix'] : 'oc_';
     \OC_Config::setValues(['dbname' => $dbName, 'dbhost' => $dbHost, 'dbtableprefix' => $dbTablePrefix]);
     $this->dbuser = $dbUser;
     $this->dbpassword = $dbPass;
     $this->dbname = $dbName;
     $this->dbhost = $dbHost;
     $this->tableprefix = $dbTablePrefix;
 }
开发者ID:brunomilet,项目名称:owncloud-core,代码行数:14,代码来源:abstractdatabase.php

示例4: setValues

 /**
  * Sets and deletes values and writes the config.php
  *
  * @param array $configs Associative array with `key => value` pairs
  *                       If value is null, the config key will be deleted
  */
 public function setValues(array $configs)
 {
     \OC_Config::setValues($configs);
 }
开发者ID:evanjt,项目名称:core,代码行数:10,代码来源:systemconfig.php

示例5: setupDatabase

 public function setupDatabase($username)
 {
     $e_host = addslashes($this->dbhost);
     $e_dbname = addslashes($this->dbname);
     //check if the database user has admin right
     if ($e_host == '') {
         $easy_connect_string = $e_dbname;
         // use dbname as easy connect name
     } else {
         $easy_connect_string = '//' . $e_host . '/' . $e_dbname;
     }
     \OC_Log::write('setup oracle', 'connect string: ' . $easy_connect_string, \OC_Log::DEBUG);
     $connection = @oci_connect($this->dbuser, $this->dbpassword, $easy_connect_string);
     if (!$connection) {
         $errorMessage = $this->getLastError();
         if ($errorMessage) {
             throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'), $errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME') . ' ORACLE_SID=' . getenv('ORACLE_SID') . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH') . ' NLS_LANG=' . getenv('NLS_LANG') . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
         }
         throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'), 'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME') . ' ORACLE_SID=' . getenv('ORACLE_SID') . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH') . ' NLS_LANG=' . getenv('NLS_LANG') . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
     }
     //check for roles creation rights in oracle
     $query = 'SELECT count(*) FROM user_role_privs, role_sys_privs' . " WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
     $stmt = oci_parse($connection, $query);
     if (!$stmt) {
         $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
         $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
         \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
     }
     $result = oci_execute($stmt);
     if ($result) {
         $row = oci_fetch_row($stmt);
         if ($row[0] > 0) {
             //use the admin login data for the new database user
             //add prefix to the oracle user name to prevent collisions
             $this->dbuser = 'oc_' . $username;
             //create a new password so we don't need to store the admin config in the config file
             $this->dbpassword = \OC_Util::generateRandomBytes(30);
             //oracle passwords are treated as identifiers:
             //  must start with alphanumeric char
             //  needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length.
             $this->dbpassword = substr($this->dbpassword, 0, 30);
             $this->createDBUser($connection);
         }
     }
     \OC_Config::setValues(['dbuser' => $this->dbuser, 'dbname' => $this->dbname, 'dbpassword' => $this->dbpassword]);
     //create the database not necessary, oracle implies user = schema
     //$this->createDatabase($this->dbname, $this->dbuser, $connection);
     //FIXME check tablespace exists: select * from user_tablespaces
     // the connection to dbname=oracle is not needed anymore
     oci_close($connection);
     // connect to the oracle database (schema=$this->dbuser) an check if the schema needs to be filled
     $this->dbuser = \OC_Config::getValue('dbuser');
     //$this->dbname = \OC_Config::getValue('dbname');
     $this->dbpassword = \OC_Config::getValue('dbpassword');
     $e_host = addslashes($this->dbhost);
     $e_dbname = addslashes($this->dbname);
     if ($e_host == '') {
         $easy_connect_string = $e_dbname;
         // use dbname as easy connect name
     } else {
         $easy_connect_string = '//' . $e_host . '/' . $e_dbname;
     }
     $connection = @oci_connect($this->dbuser, $this->dbpassword, $easy_connect_string);
     if (!$connection) {
         throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'), $this->trans->t('You need to enter either an existing account or the administrator.'));
     }
     $query = "SELECT count(*) FROM user_tables WHERE table_name = :un";
     $stmt = oci_parse($connection, $query);
     $un = $this->tableprefix . 'users';
     oci_bind_by_name($stmt, ':un', $un);
     if (!$stmt) {
         $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
         $entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
         \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
     }
     $result = oci_execute($stmt);
     if ($result) {
         $row = oci_fetch_row($stmt);
     }
     if (!$result or $row[0] == 0) {
         \OC_DB::createDbFromStructure($this->dbDefinitionFile);
     }
 }
开发者ID:brunomilet,项目名称:owncloud-core,代码行数:83,代码来源:oci.php

示例6: setupDatabase

 public function setupDatabase($username)
 {
     $e_host = addslashes($this->dbHost);
     $e_user = addslashes($this->dbUser);
     $e_password = addslashes($this->dbPassword);
     // Fix database with port connection
     if (strpos($e_host, ':')) {
         list($e_host, $port) = explode(':', $e_host, 2);
     } else {
         $port = false;
     }
     //check if the database user has admin rights
     $connection_string = "host='{$e_host}' dbname=postgres user='{$e_user}' port='{$port}' password='{$e_password}'";
     $connection = @pg_connect($connection_string);
     if (!$connection) {
         // Try if we can connect to the DB with the specified name
         $e_dbname = addslashes($this->dbName);
         $connection_string = "host='{$e_host}' dbname='{$e_dbname}' user='{$e_user}' port='{$port}' password='{$e_password}'";
         $connection = @pg_connect($connection_string);
         if (!$connection) {
             throw new \OC\DatabaseSetupException($this->trans->t('PostgreSQL username and/or password not valid'), $this->trans->t('You need to enter either an existing account or the administrator.'));
         }
     }
     $e_user = pg_escape_string($this->dbUser);
     //check for roles creation rights in postgresql
     $query = "SELECT 1 FROM pg_roles WHERE rolcreaterole=TRUE AND rolname='{$e_user}'";
     $result = pg_query($connection, $query);
     if ($result and pg_num_rows($result) > 0) {
         //use the admin login data for the new database user
         //add prefix to the postgresql user name to prevent collisions
         $this->dbUser = 'oc_' . $username;
         //create a new password so we don't need to store the admin config in the config file
         $this->dbPassword = \OC_Util::generateRandomBytes(30);
         $this->createDBUser($connection);
     }
     \OC_Config::setValues(['dbuser' => $this->dbUser, 'dbpassword' => $this->dbPassword]);
     //create the database
     $this->createDatabase($connection);
     // the connection to dbname=postgres is not needed anymore
     pg_close($connection);
     // connect to the ownCloud database (dbname=$this->dbname) and check if it needs to be filled
     $this->dbUser = \OC_Config::getValue('dbuser');
     $this->dbPassword = \OC_Config::getValue('dbpassword');
     $e_host = addslashes($this->dbHost);
     $e_dbname = addslashes($this->dbName);
     $e_user = addslashes($this->dbUser);
     $e_password = addslashes($this->dbPassword);
     // Fix database with port connection
     if (strpos($e_host, ':')) {
         list($e_host, $port) = explode(':', $e_host, 2);
     } else {
         $port = false;
     }
     $connection_string = "host='{$e_host}' dbname='{$e_dbname}' user='{$e_user}' port='{$port}' password='{$e_password}'";
     $connection = @pg_connect($connection_string);
     if (!$connection) {
         throw new \OC\DatabaseSetupException($this->trans->t('PostgreSQL username and/or password not valid'), $this->trans->t('You need to enter either an existing account or the administrator.'));
     }
     $query = "select count(*) FROM pg_class WHERE relname='" . $this->tablePrefix . "users' limit 1";
     $result = pg_query($connection, $query);
     if ($result) {
         $row = pg_fetch_row($result);
     }
     if (!$result or $row[0] == 0) {
         \OC_DB::createDbFromStructure($this->dbDefinitionFile);
     }
 }
开发者ID:evanjt,项目名称:core,代码行数:67,代码来源:postgresql.php


注:本文中的OC_Config::setValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。