Example #1
0
 /**
  * if the parent of the mount point is gone then the mount point should move up
  *
  * @medium
  */
 function testParentOfMountPointIsGone()
 {
     // share to user
     $fileinfo = $this->view->getFileInfo($this->folder);
     $result = \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     $this->assertTrue($user2View->file_exists($this->folder));
     // create a local folder
     $result = $user2View->mkdir('localfolder');
     $this->assertTrue($result);
     // move mount point to local folder
     $result = $user2View->rename($this->folder, '/localfolder/' . $this->folder);
     $this->assertTrue($result);
     // mount point in the root folder should no longer exist
     $this->assertFalse($user2View->is_dir($this->folder));
     // delete the local folder
     $fullPath = \OC_Config::getValue('datadirectory') . '/' . self::TEST_FILES_SHARING_API_USER2 . '/files/localfolder';
     rmdir($fullPath);
     //enforce reload of the mount points
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     //mount point should be back at the root
     $this->assertTrue($user2View->is_dir($this->folder));
     //cleanup
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->view->unlink($this->folder);
 }
Example #2
0
 /**
  * @brief Constructor
  * @param string $app app providing the template
  * @param string $name of the template file (without suffix)
  * @param string $renderas = ""; produce a full page
  * @return OC_Template object
  *
  * This function creates an OC_Template object.
  *
  * If $renderas is set, OC_Template will try to produce a full page in the
  * according layout. For now, renderas can be set to "guest", "user" or
  * "admin".
  */
 public function __construct($app, $name, $renderas = "")
 {
     // Read the selected theme from the config file
     $theme = OC_Util::getTheme();
     // Read the detected formfactor and use the right file name.
     $fext = self::getFormFactorExtension();
     $requesttoken = OC::$session ? OC_Util::callRegister() : '';
     $parts = explode('/', $app);
     // fix translation when app is something like core/lostpassword
     $l10n = OC_L10N::get($parts[0]);
     $themeDefaults = new OC_Defaults();
     list($path, $template) = $this->findTemplate($theme, $app, $name, $fext);
     // Set the private data
     $this->renderas = $renderas;
     $this->path = $path;
     parent::__construct($template, $requesttoken, $l10n, $themeDefaults);
     // Some headers to enhance security
     header('X-XSS-Protection: 1; mode=block');
     // Enforce browser based XSS filters
     header('X-Content-Type-Options: nosniff');
     // Disable sniffing the content type for IE
     // iFrame Restriction Policy
     $xFramePolicy = OC_Config::getValue('xframe_restriction', true);
     if ($xFramePolicy) {
         header('X-Frame-Options: Sameorigin');
         // Disallow iFraming from other domains
     }
     // Content Security Policy
     // If you change the standard policy, please also change it in config.sample.php
     $policy = OC_Config::getValue('custom_csp_policy', 'default-src \'self\'; ' . 'script-src \'self\' \'unsafe-eval\'; ' . 'style-src \'self\' \'unsafe-inline\'; ' . 'frame-src *; ' . 'img-src *; ' . 'font-src \'self\' data:; ' . 'media-src *');
     header('Content-Security-Policy:' . $policy);
     // Standard
 }
Example #3
0
 /**
  * Prepares an SQL statement.
  *
  * @param string $statement The SQL statement to prepare.
  * @param int $limit
  * @param int $offset
  * @return \Doctrine\DBAL\Driver\Statement The prepared statement.
  */
 public function prepare($statement, $limit = null, $offset = null)
 {
     if ($limit === -1) {
         $limit = null;
     }
     if (!is_null($limit)) {
         $platform = $this->getDatabasePlatform();
         $statement = $platform->modifyLimitQuery($statement, $limit, $offset);
     } else {
         if (isset($this->preparedQueries[$statement]) && $this->cachingQueryStatementEnabled) {
             return $this->preparedQueries[$statement];
         }
         $origStatement = $statement;
     }
     $statement = $this->replaceTablePrefix($statement);
     $statement = $this->adapter->fixupStatement($statement);
     if (\OC_Config::getValue('log_query', false)) {
         \OC_Log::write('core', 'DB prepare : ' . $statement, \OC_Log::DEBUG);
     }
     $result = parent::prepare($statement);
     if (is_null($limit) && $this->cachingQueryStatementEnabled) {
         $this->preparedQueries[$origStatement] = $result;
     }
     return $result;
 }
Example #4
0
	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();
	}
Example #5
0
 public static function sendEmail($args)
 {
     $isEncrypted = OC_App::isEnabled('files_encryption');
     if (!$isEncrypted || isset($_POST['continue'])) {
         $continue = true;
     } else {
         $continue = false;
     }
     if (OC_User::userExists($_POST['user']) && $continue) {
         $token = hash('sha256', OC_Util::generate_random_bytes(30) . OC_Config::getValue('passwordsalt', ''));
         OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token));
         // Hash the token again to prevent timing attacks
         $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
         if (!empty($email)) {
             $link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token));
             $link = OC_Helper::makeURLAbsolute($link);
             $tmpl = new OC_Template('core/lostpassword', 'email');
             $tmpl->assign('link', $link, false);
             $msg = $tmpl->fetchPage();
             $l = OC_L10N::get('core');
             $from = OCP\Util::getDefaultEmailAddress('lostpassword-noreply');
             try {
                 OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
             } catch (Exception $e) {
                 OC_Template::printErrorPage('A problem occurs during sending the e-mail please contact your administrator.');
             }
             self::displayLostPasswordPage(false, true);
         } else {
             self::displayLostPasswordPage(true, false);
         }
     } else {
         self::displayLostPasswordPage(true, false);
     }
 }
Example #6
0
 public static function sendEmail($args)
 {
     if (OC_User::userExists($_POST['user'])) {
         $token = hash('sha256', OC_Util::generate_random_bytes(30) . OC_Config::getValue('passwordsalt', ''));
         OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token));
         // Hash the token again to prevent timing attacks
         $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
         if (!empty($email)) {
             $link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token));
             $link = OC_Helper::makeURLAbsolute($link);
             $tmpl = new OC_Template('core/lostpassword', 'email');
             $tmpl->assign('link', $link, false);
             $msg = $tmpl->fetchPage();
             $l = OC_L10N::get('core');
             $from = 'lostpassword-noreply@' . OCP\Util::getServerHost();
             OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
             echo 'Mailsent';
             self::displayLostPasswordPage(false, true);
         } else {
             self::displayLostPasswordPage(true, false);
         }
     } else {
         self::displayLostPasswordPage(true, false);
     }
 }
 /**
  * get entries from the log in reverse chronological order
  * @param int limit
  * @param int offset
  * @return array
  */
 public static function getEntries($limit = 50, $offset = 0)
 {
     self::init();
     $minLevel = OC_Config::getValue("loglevel", OC_Log::WARN);
     $entries = array();
     $handle = @fopen(self::$logFile, 'r');
     if ($handle) {
         // Just a guess to set the file pointer to the right spot
         $maxLineLength = 150;
         fseek($handle, -($limit * $maxLineLength + $offset * $maxLineLength), SEEK_END);
         // Skip first line, because it is most likely a partial line
         fgets($handle);
         while (!feof($handle)) {
             $line = fgets($handle);
             if (!empty($line)) {
                 $entry = json_decode($line);
                 if ($entry->level >= $minLevel) {
                     $entries[] = $entry;
                 }
             }
         }
         fclose($handle);
         // Extract the needed entries and reverse the order
         $entries = array_reverse(array_slice($entries, -($limit + $offset), $limit));
     }
     return $entries;
 }
 /**
  * create a new database
  *
  * @param string $name    name of the database that should be created
  * @param array  $options array with charset info
  *
  * @return mixed MDB2_OK on success, a MDB2 error on failure
  * @access public
  */
 function createDatabase($name, $options = array())
 {
     $datadir = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     $db = $this->getDBInstance();
     if (PEAR::isError($db)) {
         return $db;
     }
     $database_file = $db->_getDatabaseFile($name);
     if (file_exists($database_file)) {
         return $db->raiseError(MDB2_ERROR_ALREADY_EXISTS, null, null, 'database already exists', __FUNCTION__);
     }
     $php_errormsg = '';
     $database_file = "{$datadir}/{$database_file}.db";
     $handle = new SQLite3($database_file);
     if (!$handle) {
         return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null, isset($php_errormsg) ? $php_errormsg : 'could not create the database file', __FUNCTION__);
     }
     //sqlite doesn't support the latin1 we use
     //         if (!empty($options['charset'])) {
     //             $query = 'PRAGMA encoding = ' . $db->quote($options['charset'], 'text');
     //             $handle->exec($query);
     //         }
     $handle->close();
     return MDB2_OK;
 }
Example #9
0
 /**
  * Start a editing session or return an existing one
  * @param string $uid of the user starting a session
  * @param \OCA\Documents\File $file - file object
  * @return array
  * @throws \Exception
  */
 public static function start($uid, $file)
 {
     // Create a directory to store genesis
     $genesis = new Genesis($file);
     list($ownerView, $path) = $file->getOwnerViewAndPath();
     $oldSession = new Db_Session();
     $oldSession->loadBy('file_id', $file->getFileId());
     //If there is no existing session we need to start a new one
     if (!$oldSession->hasData()) {
         $newSession = new Db_Session(array($genesis->getPath(), $genesis->getHash(), $file->getOwner(), $file->getFileId()));
         if (!$newSession->insert()) {
             throw new \Exception('Failed to add session into database');
         }
     }
     $sessionData = $oldSession->loadBy('file_id', $file->getFileId())->getData();
     $memberColor = Helper::getMemberColor($uid);
     $member = new Db_Member(array($sessionData['es_id'], $uid, $memberColor, time(), intval($file->isPublicShare()), $file->getToken()));
     if ($member->insert()) {
         // Do we have OC_Avatar in out disposal?
         if (!class_exists('\\OC_Avatar') || \OC_Config::getValue('enable_avatars', true) !== true) {
             $imageUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==';
         } else {
             $imageUrl = $uid;
         }
         $displayName = $file->isPublicShare() ? $uid . ' ' . Db_Member::getGuestPostfix() : \OCP\User::getDisplayName($uid);
         $sessionData['member_id'] = (string) $member->getLastInsertId();
         $op = new Db_Op();
         $op->addMember($sessionData['es_id'], $sessionData['member_id'], $displayName, $memberColor, $imageUrl);
     } else {
         throw new \Exception('Failed to add member into database');
     }
     $sessionData['title'] = basename($path);
     $sessionData['permissions'] = $ownerView->getFilePermissions($path);
     return $sessionData;
 }
Example #10
0
 /**
  * Send an email to {$limit} users
  *
  * @param int $limit Number of users we want to send an email to
  * @return int Number of users we sent an email to
  */
 protected function runStep($limit)
 {
     // Get all users which should receive an email
     $affectedUsers = $this->mqHandler->getAffectedUsers($limit);
     if (empty($affectedUsers)) {
         // No users found to notify, mission abort
         return 0;
     }
     $preferences = new \OC\Preferences(\OC_DB::getConnection());
     $userLanguages = $preferences->getValueForUsers('core', 'lang', $affectedUsers);
     $userEmails = $preferences->getValueForUsers('settings', 'email', $affectedUsers);
     // Get all items for these users
     // We don't use time() but "time() - 1" here, so we don't run into
     // runtime issues and delete emails later, which were created in the
     // same second, but were not collected for the emails.
     $sendTime = time() - 1;
     $mailData = $this->mqHandler->getItemsForUsers($affectedUsers, $sendTime);
     // Send Email
     $default_lang = \OC_Config::getValue('default_language', 'en');
     foreach ($mailData as $user => $data) {
         if (!isset($userEmails[$user])) {
             // The user did not setup an email address
             // So we will not send an email :(
             continue;
         }
         $language = isset($userLanguages[$user]) ? $userLanguages[$user] : $default_lang;
         $this->mqHandler->sendEmailToUser($user, $userEmails[$user], $language, $data);
     }
     // Delete all entries we dealt with
     $this->mqHandler->deleteSentItems($affectedUsers, $sendTime);
     return sizeof($affectedUsers);
 }
Example #11
0
 public function setUp()
 {
     //clear all proxies and hooks so we can do clean testing
     \OC_FileProxy::clearProxies();
     \OC_Hook::clear('OC_Filesystem');
     //disabled atm
     //enable only the encryption hook if needed
     //if(OC_App::isEnabled('files_encryption')) {
     //	OC_FileProxy::register(new OC_FileProxy_Encryption());
     //}
     //set up temporary storage
     \OC\Files\Filesystem::clearMounts();
     $storage = new \OC\Files\Storage\Temporary(array());
     \OC\Files\Filesystem::mount($storage, array(), '/');
     $datadir = str_replace('local::', '', $storage->getId());
     $this->datadir = \OC_Config::getValue('cachedirectory', \OC::$SERVERROOT . '/data/cache');
     \OC_Config::setValue('cachedirectory', $datadir);
     \OC_User::clearBackends();
     \OC_User::useBackend(new \OC_User_Dummy());
     //login
     \OC_User::createUser('test', 'test');
     $this->user = \OC_User::getUser();
     \OC_User::setUserId('test');
     //set up the users dir
     $rootView = new \OC\Files\View('');
     $rootView->mkdir('/test');
     $this->instance = new \OC\Cache\UserCache();
 }
Example #12
0
 /**
  * write a message in the log
  * @param string $app
  * @param string $message
  * @param int $level
  */
 public static function write($app, $message, $level)
 {
     $minLevel = min(OC_Config::getValue("loglevel", OC_Log::WARN), OC_Log::ERROR);
     if ($level >= $minLevel) {
         error_log('[owncloud][' . $app . '] ' . $message);
     }
 }
Example #13
0
    /**
     * returns prefixes for each saved LDAP/AD server configuration.
     * @param bool $activeConfigurations optional, whether only active configuration shall be
     * retrieved, defaults to false
     * @return array with a list of the available prefixes
     *
     * Configuration prefixes are used to set up configurations for n LDAP or
     * AD servers. Since configuration is stored in the database, table
     * appconfig under appid user_ldap, the common identifiers in column
     * 'configkey' have a prefix. The prefix for the very first server
     * configuration is empty.
     * Configkey Examples:
     * Server 1: ldap_login_filter
     * Server 2: s1_ldap_login_filter
     * Server 3: s2_ldap_login_filter
     *
     * The prefix needs to be passed to the constructor of Connection class,
     * except the default (first) server shall be connected to.
     *
     */
    public function getServerConfigurationPrefixes($activeConfigurations = false)
    {
        $referenceConfigkey = 'ldap_configuration_active';
        $sql = '
			SELECT DISTINCT `configkey`
			FROM `*PREFIX*appconfig`
			WHERE `appid` = \'user_ldap\'
				AND `configkey` LIKE ?
		';
        if ($activeConfigurations) {
            if (\OC_Config::getValue('dbtype', 'sqlite') === 'oci') {
                //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
                $sql .= ' AND to_char(`configvalue`)=\'1\'';
            } else {
                $sql .= ' AND `configvalue` = \'1\'';
            }
        }
        $stmt = \OCP\DB::prepare($sql);
        $serverConfigs = $stmt->execute(array('%' . $referenceConfigkey))->fetchAll();
        $prefixes = array();
        foreach ($serverConfigs as $serverConfig) {
            $len = strlen($serverConfig['configkey']) - strlen($referenceConfigkey);
            $prefixes[] = substr($serverConfig['configkey'], 0, $len);
        }
        return $prefixes;
    }
Example #14
0
 /**
  * send an email
  *
  * @param string $toaddress
  * @param string $toname
  * @param string $subject
  * @param string $mailtext
  * @param string $fromaddress
  * @param string $fromname
  * @param bool $html
  */
 public static function send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '')
 {
     $SMTPMODE = OC_Config::getValue('mail_smtpmode', 'sendmail');
     $SMTPHOST = OC_Config::getValue('mail_smtphost', '127.0.0.1');
     $SMTPAUTH = OC_Config::getValue('mail_smtpauth', false);
     $SMTPUSERNAME = OC_Config::getValue('mail_smtpname', '');
     $SMTPPASSWORD = OC_Config::getValue('mail_smtppassword', '');
     $mailo = new PHPMailer(true);
     if ($SMTPMODE == 'sendmail') {
         $mailo->IsSendmail();
     } elseif ($SMTPMODE == 'smtp') {
         $mailo->IsSMTP();
     } elseif ($SMTPMODE == 'qmail') {
         $mailo->IsQmail();
     } else {
         $mailo->IsMail();
     }
     $mailo->Host = $SMTPHOST;
     $mailo->SMTPAuth = $SMTPAUTH;
     $mailo->Username = $SMTPUSERNAME;
     $mailo->Password = $SMTPPASSWORD;
     $mailo->From = $fromaddress;
     $mailo->FromName = $fromname;
     $mailo->Sender = $fromaddress;
     $a = explode(' ', $toaddress);
     try {
         foreach ($a as $ad) {
             $mailo->AddAddress($ad, $toname);
         }
         if ($ccaddress != '') {
             $mailo->AddCC($ccaddress, $ccname);
         }
         if ($bcc != '') {
             $mailo->AddBCC($bcc);
         }
         $mailo->AddReplyTo($fromaddress, $fromname);
         $mailo->WordWrap = 50;
         if ($html == 1) {
             $mailo->IsHTML(true);
         } else {
             $mailo->IsHTML(false);
         }
         $mailo->Subject = $subject;
         if ($altbody == '') {
             $mailo->Body = $mailtext . OC_MAIL::getfooter();
             $mailo->AltBody = '';
         } else {
             $mailo->Body = $mailtext;
             $mailo->AltBody = $altbody;
         }
         $mailo->CharSet = 'UTF-8';
         $mailo->Send();
         unset($mailo);
         OC_Log::write('mail', 'Mail from ' . $fromname . ' (' . $fromaddress . ')' . ' to: ' . $toname . '(' . $toaddress . ')' . ' subject: ' . $subject, OC_Log::DEBUG);
     } catch (Exception $exception) {
         OC_Log::write('mail', $exception->getMessage(), OC_Log::ERROR);
         throw $exception;
     }
 }
Example #15
0
 /**
  * write a message in the log
  * @param string $app
  * @param string $message
  * @param int $level
  */
 public static function write($app, $message, $level)
 {
     $minLevel = min(OC_Config::getValue("loglevel", OC_Log::WARN), OC_Log::ERROR);
     if ($level >= $minLevel) {
         $syslog_level = self::$levels[$level];
         syslog($syslog_level, '{' . $app . '} ' . $message);
     }
 }
Example #16
0
 protected function tearDown()
 {
     \OC_Config::setValue('datadirectory', $this->datadir);
     \OC_User::setUserId($this->uid);
     \OC_Util::setupFS($this->uid);
     \OC\Files\Filesystem::mount($this->originalStorage, array(), '/');
     parent::tearDown();
 }
Example #17
0
 public static function getCapabilities($parameters)
 {
     $result = array();
     list($major, $minor, $micro) = OC_Util::getVersion();
     $result['version'] = array('major' => $major, 'minor' => $minor, 'micro' => $micro, 'string' => OC_Util::getVersionString(), 'edition' => OC_Util::getEditionString());
     $result['capabilities'] = array('core' => array('pollinterval' => OC_Config::getValue('pollinterval', 60)));
     return new OC_OCS_Result($result);
 }
Example #18
0
 /**
  * Returns a list of Sabre_DAV_Locks_LockInfo objects
  *
  * This method should return all the locks for a particular uri, including
  * locks that might be set on a parent uri.
  *
  * If returnChildLocks is set to true, this method should also look for
  * any locks in the subtree of the uri for locks.
  *
  * @param string $uri
  * @param bool $returnChildLocks
  * @return array
  */
 public function getLocks($uri, $returnChildLocks)
 {
     // NOTE: the following 10 lines or so could be easily replaced by
     // pure sql. MySQL's non-standard string concatination prevents us
     // from doing this though.
     // NOTE: SQLite requires time() to be inserted directly. That's ugly
     // but otherwise reading locks from SQLite Databases will return
     // nothing
     $query = 'SELECT * FROM `*PREFIX*locks`' . ' WHERE `userid` = ? AND (`created` + `timeout`) > ' . time() . ' AND (( `uri` = ?)';
     if (OC_Config::getValue("dbtype") === 'oci') {
         //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
         $query = 'SELECT * FROM `*PREFIX*locks`' . ' WHERE `userid` = ? AND (`created` + `timeout`) > ' . time() . ' AND (( to_char(`uri`) = ?)';
     }
     $params = array(OC_User::getUser(), $uri);
     // We need to check locks for every part in the uri.
     $uriParts = explode('/', $uri);
     // We already covered the last part of the uri
     array_pop($uriParts);
     $currentPath = '';
     foreach ($uriParts as $part) {
         if ($currentPath) {
             $currentPath .= '/';
         }
         $currentPath .= $part;
         //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
         if (OC_Config::getValue("dbtype") === 'oci') {
             $query .= ' OR (`depth` != 0 AND to_char(`uri`) = ?)';
         } else {
             $query .= ' OR (`depth` != 0 AND `uri` = ?)';
         }
         $params[] = $currentPath;
     }
     if ($returnChildLocks) {
         //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
         if (OC_Config::getValue("dbtype") === 'oci') {
             $query .= ' OR (to_char(`uri`) LIKE ?)';
         } else {
             $query .= ' OR (`uri` LIKE ?)';
         }
         $params[] = $uri . '/%';
     }
     $query .= ')';
     $stmt = OC_DB::prepare($query);
     $result = $stmt->execute($params);
     $lockList = array();
     while ($row = $result->fetchRow()) {
         $lockInfo = new Sabre_DAV_Locks_LockInfo();
         $lockInfo->owner = $row['owner'];
         $lockInfo->token = $row['token'];
         $lockInfo->timeout = $row['timeout'];
         $lockInfo->created = $row['created'];
         $lockInfo->scope = $row['scope'];
         $lockInfo->depth = $row['depth'];
         $lockInfo->uri = $row['uri'];
         $lockList[] = $lockInfo;
     }
     return $lockList;
 }
Example #19
0
 /**
  * get the user's home directory
  * @param string $uid the username
  * @return string|false
  */
 public function getHome($uid)
 {
     if ($this->userExists($uid)) {
         $user = substr($uid, 4);
         return OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data") . '/' . $user;
     } else {
         return false;
     }
 }
Example #20
0
 /**
  * Sets a value
  * @param string $key key
  * @param string $value value
  * @return bool
  *
  * This function sets the value and writes the config.php. If the file can
  * not be written, false will be returned.
  */
 public static function setSystemValue($key, $value)
 {
     try {
         \OC_Config::setValue($key, $value);
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
Example #21
0
 protected function tearDown()
 {
     \OC_User::setUserId($this->user);
     \OC_Config::setValue('cachedirectory', $this->datadir);
     // Restore the original mount point
     \OC\Files\Filesystem::clearMounts();
     \OC\Files\Filesystem::mount($this->storage, array(), '/');
     parent::tearDown();
 }
Example #22
0
 public function __construct($prefix = '')
 {
     parent::__construct($prefix);
     if (is_null(self::$cache)) {
         self::$cache = new \Memcached();
         list($host, $port) = \OC_Config::getValue('memcached_server', array('localhost', 11211));
         self::$cache->addServer($host, $port);
     }
 }
Example #23
0
	/**
	* Check if the user verified the login with his password
	*/
	public static function verifyUser() {
		if(OC_Config::getValue('enhancedauth', false) === true) {
			if(!isset($_SESSION['verifiedLogin']) OR $_SESSION['verifiedLogin'] < time()) {
				$l = OC_L10N::get('lib');
				self::error(array( 'data' => array( 'message' => $l->t('Authentication error') )));
				exit();
			}
		}
	}
Example #24
0
 /**
  * write a message in the log
  * @param string $app
  * @param string $message
  * @param int level
  */
 public static function write($app, $message, $level)
 {
     if (!self::$class) {
         self::$class = 'OC_Log_' . ucfirst(OC_Config::getValue('log_type', 'owncloud'));
         call_user_func(array(self::$class, 'init'));
     }
     $log_class = self::$class;
     $log_class::write($app, $message, $level);
 }
Example #25
0
	public function run($logFile) {
		$this->max_log_size = \OC_Config::getValue('log_rotate_size', false);
		if ($this->max_log_size) {
			$filesize = @filesize($logFile);
			if ($filesize >= $this->max_log_size) {
				$this->rotate($logFile);
			}
		}
	}
Example #26
0
 /**
  * @param string $table
  */
 public function assertTableNotExist($table)
 {
     $type = OC_Config::getValue("dbtype", "sqlite");
     if ($type == 'sqlite' || $type == 'sqlite3') {
         // sqlite removes the tables after closing the DB
         $this->assertTrue(true);
     } else {
         $this->assertFalse(OC_DB::tableExists($table), 'Table ' . $table . ' exists.');
     }
 }
Example #27
0
 /**
  * @param string $logger The logger that should be used
  */
 public function __construct($logger = null)
 {
     // FIXME: Add this for backwards compatibility, should be fixed at some point probably
     if ($logger === null) {
         $this->logger = 'OC_Log_' . ucfirst(\OC_Config::getValue('log_type', 'owncloud'));
         call_user_func(array($this->logger, 'init'));
     } else {
         $this->logger = $logger;
     }
 }
 /**
  * This method is called before any HTTP method and returns http status code 503
  * in case the system is in maintenance mode.
  *
  * @throws \Sabre\DAV\Exception\ServiceUnavailable
  * @internal param string $method
  * @return bool
  */
 public function checkMaintenanceMode()
 {
     if (OC_Config::getValue('maintenance', false)) {
         throw new \Sabre\DAV\Exception\ServiceUnavailable();
     }
     if (OC::checkUpgrade(false)) {
         throw new \Sabre\DAV\Exception\ServiceUnavailable('Upgrade needed');
     }
     return true;
 }
Example #29
0
 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(self::TEST_TRASHBIN_USER1);
     \OC_Config::setValue('trashbin_retention_obligation', self::$rememberRetentionObligation);
     \OC_Config::setValue('trashbin_auto_expire', self::$rememberAutoExpire);
     \OC_Hook::clear();
     \OC\Files\Filesystem::getLoader()->removeStorageWrapper('oc_trashbin');
     parent::tearDownAfterClass();
 }
Example #30
0
 public function getHome($uid)
 {
     $uid = $this->checkUid($uid);
     if ($this->userExists($uid)) {
         list($user, $domain) = explode('@', $uid);
         return OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data") . '/' . $domain . '/' . $user;
     } else {
         return false;
     }
 }