本文整理汇总了PHP中OC_Filesystem::mount方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Filesystem::mount方法的具体用法?PHP OC_Filesystem::mount怎么用?PHP OC_Filesystem::mount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Filesystem
的用法示例。
在下文中一共展示了OC_Filesystem::mount方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
}
示例2: 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;
}
}
示例3: setUp
public function setUp()
{
//set testing key
$_SESSION['enckey'] = md5(time());
//clear all proxies and hooks so we can do clean testing
OC_FileProxy::clearProxies();
OC_Hook::clear('OC_Filesystem');
//enable only the encryption hook
OC_FileProxy::register(new OC_FileProxy_Encryption());
//set up temporary storage
OC_Filesystem::clearMounts();
OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
//set up the users home folder in the temp storage
$rootView = new OC_FilesystemView('');
$rootView->mkdir('/' . OC_User::getUser());
$rootView->mkdir('/' . OC_User::getUser() . '/files');
}
示例4: setUp
public function setUp()
{
$this->oldConfig = OCP\Config::getAppValue('files_encryption', 'enable_encryption', 'true');
OCP\Config::setAppValue('files_encryption', 'enable_encryption', 'true');
$this->oldKey = isset($_SESSION['enckey']) ? $_SESSION['enckey'] : null;
//set testing key
$_SESSION['enckey'] = md5(time());
//clear all proxies and hooks so we can do clean testing
OC_FileProxy::clearProxies();
OC_Hook::clear('OC_Filesystem');
//enable only the encryption hook
OC_FileProxy::register(new OC_FileProxy_Encryption());
//set up temporary storage
OC_Filesystem::clearMounts();
OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
//set up the users home folder in the temp storage
$rootView = new OC_FilesystemView('');
$rootView->mkdir('/' . OC_User::getUser());
$rootView->mkdir('/' . OC_User::getUser() . '/files');
}
示例5: loadUserMountPoints
public static function loadUserMountPoints($user)
{
$user_dir = '/' . $user . '/files';
$user_root = OC_User::getHome($user);
$userdirectory = $user_root . '/files';
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);
}
}
}
示例6: setUp
public function setUp()
{
//clear all proxies and hooks so we can do clean testing
OC_FileProxy::clearProxies();
OC_Hook::clear('OC_Filesystem');
//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_Filesystem::clearMounts();
OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
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_FilesystemView('');
$rootView->mkdir('/test');
$this->instance = new OC_Cache_File();
}
示例7: setup
public static function setup($options)
{
$user_dir = $options['user_dir'];
OC_Filesystem::mount('OC_Filestorage_Shared', array('sharedFolder' => '/Shared'), $user_dir . '/Shared/');
}
示例8: 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");
// 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 setting the owner of '" . OC::$SERVERROOT . "' to the user that the web server uses (" . OC_Util::checkWebserverUser() . ")")));
$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();
}
if ($user != "") {
//if we aren't logged in, there is no use to set up the filesystem
//first set up the local "root" storage and the backupstorage if needed
$rootStorage = OC_Filesystem::createStorage('local', array('datadir' => $CONFIG_DATADIRECTORY_ROOT));
// if( OC_Config::getValue( "enablebackup", false )){
// // This creates the Directorys recursively
// if(!is_dir( "$CONFIG_BACKUPDIRECTORY/$user/$root" )){
// mkdir( "$CONFIG_BACKUPDIRECTORY/$user/$root", 0755, true );
// }
// $backupStorage=OC_Filesystem::createStorage('local',array('datadir'=>$CONFIG_BACKUPDIRECTORY));
// $backup=new OC_FILEOBSERVER_BACKUP(array('storage'=>$backupStorage));
// $rootStorage->addObserver($backup);
// }
OC_Filesystem::mount($rootStorage, '/');
// TODO add this storage provider in a proper way
$sharedStorage = OC_Filesystem::createStorage('shared', array('datadir' => '/' . OC_User::getUser() . '/files/Shared'));
OC_Filesystem::mount($sharedStorage, '/' . OC_User::getUser() . '/files/Shared/');
OC::$CONFIG_DATADIRECTORY = $CONFIG_DATADIRECTORY_ROOT . "/{$user}/{$root}";
if (!is_dir(OC::$CONFIG_DATADIRECTORY)) {
mkdir(OC::$CONFIG_DATADIRECTORY, 0755, true);
}
// TODO: find a cool way for doing this
// //set up the other storages according to the system settings
// foreach($CONFIG_FILESYSTEM as $storageConfig){
// if(OC_Filesystem::hasStorageType($storageConfig['type'])){
// $arguments=$storageConfig;
// unset($arguments['type']);
// unset($arguments['mountpoint']);
// $storage=OC_Filesystem::createStorage($storageConfig['type'],$arguments);
// if($storage){
// OC_Filesystem::mount($storage,$storageConfig['mountpoint']);
// }
// }
// }
//jail the user into his "home" directory
OC_Filesystem::chroot("/{$user}/{$root}");
$quotaProxy = new OC_FileProxy_Quota();
OC_FileProxy::register($quotaProxy);
self::$fsSetup = true;
}
}
示例9: testHooks
public function testHooks()
{
if (OC_Filesystem::getView()) {
$user = OC_User::getUser();
} else {
$user = uniqid();
OC_Filesystem::init('/' . $user . '/files');
}
OC_Hook::clear('OC_Filesystem');
OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook');
OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
$rootView = new OC_FilesystemView('');
$rootView->mkdir('/' . $user);
$rootView->mkdir('/' . $user . '/files');
OC_Filesystem::file_put_contents('/foo', 'foo');
OC_Filesystem::mkdir('/bar');
OC_Filesystem::file_put_contents('/bar//foo', 'foo');
$tmpFile = OC_Helper::tmpFile();
file_put_contents($tmpFile, 'foo');
$fh = fopen($tmpFile, 'r');
OC_Filesystem::file_put_contents('/bar//foo', $fh);
}
示例10: autoMount
/**
* automount paths from file hooks
* @param aray params
*/
public static function autoMount($params)
{
if (!self::$enableAutomount) {
return;
}
$path = $params['path'];
if (!self::$rootView) {
self::$rootView = new OC_FilesystemView('');
}
self::$enableAutomount = false;
//prevent recursion
$supported = array('zip', 'tar.gz', 'tar.bz2', 'tgz');
foreach ($supported as $type) {
$ext = '.' . $type . '/';
if (($pos = strpos(strtolower($path), $ext)) !== false) {
$archive = substr($path, 0, $pos + strlen($ext) - 1);
if (self::$rootView->file_exists($archive) and array_search($archive, self::$mounted) === false) {
$localArchive = self::$rootView->getLocalFile($archive);
OC_Filesystem::mount('OC_Filestorage_Archive', array('archive' => $localArchive), $archive . '/');
self::$mounted[] = $archive;
}
}
}
self::$enableAutomount = true;
}
示例11: setup
public static function setup()
{
OC_Filesystem::mount('OC_Filestorage_Shared', array('datadir' => '/' . OCP\USER::getUser() . '/files/Shared'), '/' . OCP\USER::getUser() . '/files/Shared/');
}