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


PHP OC_FileProxy类代码示例

本文整理汇总了PHP中OC_FileProxy的典型用法代码示例。如果您正苦于以下问题:PHP OC_FileProxy类的具体用法?PHP OC_FileProxy怎么用?PHP OC_FileProxy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

 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\File();
 }
开发者ID:Romua1d,项目名称:core,代码行数:28,代码来源:file.php

示例2: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // note: not using a data provider because these
     // files all need to coexist to make sure the
     // share keys are found properly (pattern matching)
     self::$testFiles = array('t est.txt', 't est_.txt', 't est.doc.txt', 't est(.*).txt', 'multiple.dots.can.happen.too.txt', 't est.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.txt', 't est_.' . self::TEST_ENCRYPTION_HOOKS_USER1 . '.shareKey.txt', 'who would upload their.shareKey', 'user ones file.txt', 'user ones file.txt.backup', '.t est.txt');
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     \OC_Hook::clear('OC_Filesystem');
     \OC_Hook::clear('OC_User');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // Sharing related hooks
     \OCA\Encryption\Helper::registerShareHooks();
     // clear and register proxies
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create test user
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Hooks::TEST_ENCRYPTION_HOOKS_USER2, true);
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:26,代码来源:hooks.php

示例3: stream_open

 public function stream_open($path, $mode, $options, &$opened_path)
 {
     if (!self::$rootView) {
         self::$rootView = new OC_FilesystemView('');
     }
     $path = str_replace('crypt://', '', $path);
     if (dirname($path) == 'streams' and isset(self::$sourceStreams[basename($path)])) {
         $this->source = self::$sourceStreams[basename($path)]['stream'];
         $this->path = self::$sourceStreams[basename($path)]['path'];
         $this->size = self::$sourceStreams[basename($path)]['size'];
     } else {
         $this->path = $path;
         if ($mode == 'w' or $mode == 'w+' or $mode == 'wb' or $mode == 'wb+') {
             $this->size = 0;
         } else {
             $this->size = self::$rootView->filesize($path, $mode);
         }
         OC_FileProxy::$enabled = false;
         //disable fileproxies so we can open the source file
         $this->source = self::$rootView->fopen($path, $mode);
         OC_FileProxy::$enabled = true;
         if (!is_resource($this->source)) {
             OCP\Util::writeLog('files_encryption', 'failed to open ' . $path, OCP\Util::ERROR);
         }
     }
     if (is_resource($this->source)) {
         $this->meta = stream_get_meta_data($this->source);
     }
     return is_resource($this->source);
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:30,代码来源:cryptstream.php

示例4: __construct

 /**
  * if session is started, check if ownCloud key pair is set up, if not create it
  * @param \OC\Files\View $view
  *
  * @note The ownCloud key pair is used to allow public link sharing even if encryption is enabled
  */
 public function __construct($view)
 {
     $this->view = $view;
     if (!$this->view->is_dir('files_encryption')) {
         $this->view->mkdir('files_encryption');
     }
     $appConfig = \OC::$server->getAppConfig();
     $publicShareKeyId = Helper::getPublicShareKeyId();
     if ($publicShareKeyId === false) {
         $publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8);
         $appConfig->setValue('files_encryption', 'publicShareKeyId', $publicShareKeyId);
     }
     if (!Keymanager::publicShareKeyExists($view)) {
         $keypair = Crypt::createKeypair();
         // Save public key
         Keymanager::setPublicKey($keypair['publicKey'], $publicShareKeyId);
         // Encrypt private key empty passphrase
         $cipher = Helper::getCipher();
         $encryptedKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], '', $cipher);
         if ($encryptedKey) {
             Keymanager::setPrivateSystemKey($encryptedKey, $publicShareKeyId);
         } else {
             \OCP\Util::writeLog('files_encryption', 'Could not create public share keys', \OCP\Util::ERROR);
         }
     }
     if (Helper::isPublicAccess() && !self::getPublicSharePrivateKey()) {
         // Disable encryption proxy to prevent recursive calls
         $proxyStatus = \OC_FileProxy::$enabled;
         \OC_FileProxy::$enabled = false;
         $encryptedKey = Keymanager::getPrivateSystemKey($publicShareKeyId);
         $privateKey = Crypt::decryptPrivateKey($encryptedKey, '');
         self::setPublicSharePrivateKey($privateKey);
         \OC_FileProxy::$enabled = $proxyStatus;
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:41,代码来源:session.php

示例5: setupHooks

 public static function setupHooks()
 {
     // Filesystem related hooks
     Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new Files_Encryption\Proxy());
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:8,代码来源:helper.php

示例6: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     // cleanup test user
     \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER1);
     \OC_User::deleteUser(\Test_Encryption_Helper::TEST_ENCRYPTION_HELPER_USER2);
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:8,代码来源:helper.php

示例7: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->deleteAll('files_encryption');
     parent::tearDownAfterClass();
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:9,代码来源:testcase.php

示例8: getDocumentHash

 protected function getDocumentHash($view, $path)
 {
     $this->validate($view, $path);
     $proxyStatus = \OC_FileProxy::$enabled;
     \OC_FileProxy::$enabled = false;
     $hash = sha1($view->file_get_contents($path));
     \OC_FileProxy::$enabled = $proxyStatus;
     return $hash;
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:9,代码来源:genesis.php

示例9: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     \OC_Hook::clear();
     \OC_FileProxy::clearProxies();
     // Delete keys in /data/
     $view = new \OC\Files\View('/');
     $view->rmdir('public-keys');
     $view->rmdir('owncloud_private_key');
 }
开发者ID:Romua1d,项目名称:core,代码行数:9,代码来源:helper.php

示例10: setupFS

 /**
  * @brief Can be set up
  * @param string $user
  * @return boolean
  * @description configure the initial filesystem based on the configuration
  */
 public static function setupFS($user = '')
 {
     //setting up the filesystem twice can only lead to trouble
     if (self::$fsSetup) {
         return false;
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     // load all filesystem apps before, so no setup-hook gets lost
     if (!isset($RUNTIME_NOAPPS) || !$RUNTIME_NOAPPS) {
         OC_App::loadApps(array('filesystem'));
     }
     // the filesystem will finish when $user is not empty,
     // mark fs setup here to avoid doing the setup from loading
     // OC_Filesystem
     if ($user != '') {
         self::$fsSetup = true;
     }
     $configDataDirectory = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     //first set up the local "root" storage
     \OC\Files\Filesystem::initMounts();
     if (!self::$rootMounted) {
         \OC\Files\Filesystem::mount('\\OC\\Files\\Storage\\Local', array('datadir' => $configDataDirectory), '/');
         self::$rootMounted = true;
     }
     //if we aren't logged in, there is no use to set up the filesystem
     if ($user != "") {
         \OC\Files\Filesystem::addStorageWrapper(function ($mountPoint, $storage) {
             // set up quota for home storages, even for other users
             // which can happen when using sharing
             if ($storage instanceof \OC\Files\Storage\Home) {
                 $user = $storage->getUser()->getUID();
                 $quota = OC_Util::getUserQuota($user);
                 if ($quota !== \OC\Files\SPACE_UNLIMITED) {
                     return new \OC\Files\Storage\Wrapper\Quota(array('storage' => $storage, 'quota' => $quota));
                 }
             }
             return $storage;
         });
         $userDir = '/' . $user . '/files';
         $userRoot = OC_User::getHome($user);
         $userDirectory = $userRoot . '/files';
         if (!is_dir($userDirectory)) {
             mkdir($userDirectory, 0755, true);
             OC_Util::copySkeleton($userDirectory);
         }
         //jail the user into his "home" directory
         \OC\Files\Filesystem::init($user, $userDir);
         $fileOperationProxy = new OC_FileProxy_FileOperations();
         OC_FileProxy::register($fileOperationProxy);
         OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $userDir));
     }
     return true;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:62,代码来源:util.php

示例11: setupFS

 public static function setupFS($user = "", $root = "files")
 {
     // configure the initial filesystem based on the configuration
     if (self::$fsSetup) {
         //setting up the filesystem twice can only lead to trouble
         return false;
     }
     $CONFIG_DATADIRECTORY_ROOT = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     $CONFIG_BACKUPDIRECTORY = OC_Config::getValue("backupdirectory", OC::$SERVERROOT . "/backup");
     // Check if config folder is writable.
     if (!is_writable(OC::$SERVERROOT . "/config/")) {
         $tmpl = new OC_Template('', 'error', 'guest');
         $tmpl->assign('errors', array(1 => array('error' => "Can't write into config directory 'config'", 'hint' => "You can usually fix this by giving the webserver user write access to the config directory in owncloud")));
         $tmpl->printPage();
         exit;
     }
     // Check if apps folder is writable.
     if (!is_writable(OC::$SERVERROOT . "/apps/")) {
         $tmpl = new OC_Template('', 'error', 'guest');
         $tmpl->assign('errors', array(1 => array('error' => "Can't write into apps directory 'apps'", 'hint' => "You can usually fix this by giving the webserver user write access to the config directory in owncloud")));
         $tmpl->printPage();
         exit;
     }
     // Create root dir.
     if (!is_dir($CONFIG_DATADIRECTORY_ROOT)) {
         $success = @mkdir($CONFIG_DATADIRECTORY_ROOT);
         if (!$success) {
             $tmpl = new OC_Template('', 'error', 'guest');
             $tmpl->assign('errors', array(1 => array('error' => "Can't create data directory (" . $CONFIG_DATADIRECTORY_ROOT . ")", 'hint' => "You can usually fix this by giving the webserver write access to the ownCloud directory '" . OC::$SERVERROOT . "' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' ")));
             $tmpl->printPage();
             exit;
         }
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     //first set up the local "root" storage
     if (!self::$rootMounted) {
         OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $CONFIG_DATADIRECTORY_ROOT), '/');
         self::$rootMounted = true;
     }
     if ($user != "") {
         //if we aren't logged in, there is no use to set up the filesystem
         OC::$CONFIG_DATADIRECTORY = $CONFIG_DATADIRECTORY_ROOT . "/{$user}/{$root}";
         if (!is_dir(OC::$CONFIG_DATADIRECTORY)) {
             mkdir(OC::$CONFIG_DATADIRECTORY, 0755, true);
         }
         //jail the user into his "home" directory
         OC_Filesystem::init('/' . $user . '/' . $root);
         $quotaProxy = new OC_FileProxy_Quota();
         OC_FileProxy::register($quotaProxy);
         self::$fsSetup = true;
     }
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:55,代码来源:util.php

示例12: setupFS

 public static function setupFS($user = '')
 {
     // configure the initial filesystem based on the configuration
     if (self::$fsSetup) {
         //setting up the filesystem twice can only lead to trouble
         return false;
     }
     // If we are not forced to load a specific user we load the one that is logged in
     if ($user == "" && OC_User::isLoggedIn()) {
         $user = OC_User::getUser();
     }
     // the filesystem will finish when $user is not empty,
     // mark fs setup here to avoid doing the setup from loading
     // OC_Filesystem
     if ($user != '') {
         self::$fsSetup = true;
     }
     $CONFIG_DATADIRECTORY = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     //first set up the local "root" storage
     if (!self::$rootMounted) {
         OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $CONFIG_DATADIRECTORY), '/');
         self::$rootMounted = true;
     }
     if ($user != "") {
         //if we aren't logged in, there is no use to set up the filesystem
         $user_dir = '/' . $user . '/files';
         $user_root = OC_User::getHome($user);
         $userdirectory = $user_root . '/files';
         if (!is_dir($userdirectory)) {
             mkdir($userdirectory, 0755, true);
         }
         //jail the user into his "home" directory
         OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => $user_root), $user);
         OC_Filesystem::init($user_dir);
         $quotaProxy = new OC_FileProxy_Quota();
         OC_FileProxy::register($quotaProxy);
         // Load personal mount config
         if (is_file($user_root . '/mount.php')) {
             $mountConfig = (include $user_root . '/mount.php');
             if (isset($mountConfig['user'][$user])) {
                 foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
                     OC_Filesystem::mount($options['class'], $options['options'], $mountPoint);
                 }
             }
             $mtime = filemtime($user_root . '/mount.php');
             $previousMTime = OC_Preferences::getValue($user, 'files', 'mountconfigmtime', 0);
             if ($mtime > $previousMTime) {
                 //mount config has changed, filecache needs to be updated
                 OC_FileCache::triggerUpdate($user);
                 OC_Preferences::setValue($user, 'files', 'mountconfigmtime', $mtime);
             }
         }
         OC_Hook::emit('OC_Filesystem', 'setup', array('user' => $user, 'user_dir' => $user_dir));
     }
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:55,代码来源:util.php

示例13: testSimple

 public function testSimple()
 {
     $file = OC::$SERVERROOT . '/3rdparty/MDB2.php';
     $original = file_get_contents($file);
     OC_Filesystem::file_put_contents('/file', $original);
     OC_FileProxy::$enabled = false;
     $stored = OC_Filesystem::file_get_contents('/file');
     OC_FileProxy::$enabled = true;
     $fromFile = OC_Filesystem::file_get_contents('/file');
     $this->assertNotEqual($original, $stored);
     $this->assertEqual($original, $fromFile);
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:12,代码来源:proxy.php

示例14: createkey

 public static function createkey($username, $passcode)
 {
     // generate a random key
     $key = mt_rand(10000, 99999) . mt_rand(10000, 99999) . mt_rand(10000, 99999) . mt_rand(10000, 99999);
     // encrypt the key with the passcode of the user
     $enckey = OC_Crypt::encrypt($key, $passcode);
     // Write the file
     $proxyEnabled = OC_FileProxy::$enabled;
     OC_FileProxy::$enabled = false;
     $view = new OC_FilesystemView('/' . $username);
     $view->file_put_contents('/encryption.key', $enckey);
     OC_FileProxy::$enabled = $proxyEnabled;
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:13,代码来源:crypt.php

示例15: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create test user
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Stream::TEST_ENCRYPTION_STREAM_USER1, true);
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:13,代码来源:stream.php


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