コード例 #1
0
ファイル: scan.php プロジェクト: heldernl/owncloud8-extended
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getOption('path');
     if ($path) {
         $path = '/' . trim($path, '/');
         list(, $user, ) = explode('/', $path, 3);
         $users = array($user);
     } else {
         if ($input->getOption('all')) {
             $users = $this->userManager->search('');
         } else {
             $users = $input->getArgument('user_id');
         }
     }
     $quiet = $input->getOption('quiet');
     if (count($users) === 0) {
         $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
         return;
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         if ($this->userManager->userExists($user)) {
             $this->scanFiles($user, $path, $quiet, $output);
         } else {
             $output->writeln("<error>Unknown user {$user}</error>");
         }
     }
 }
コード例 #2
0
ファイル: scan.php プロジェクト: hjimmy/owncloud
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     \OC_App::loadApps('authentication');
     if ($input->getOption('all')) {
         $users = $this->userManager->search('');
     } else {
         $users = $input->getArgument('user_id');
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         if ($this->userManager->userExists($user)) {
             $this->scanFiles($user, $output);
         } else {
             $output->writeln("<error>Unknown user {$user}</error>");
         }
     }
 }
コード例 #3
0
ファイル: scan.php プロジェクト: kenwi/core
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $inputPath = $input->getOption('path');
     if ($inputPath) {
         $inputPath = '/' . trim($inputPath, '/');
         list(, $user, ) = explode('/', $inputPath, 3);
         $users = array($user);
     } else {
         if ($input->getOption('all')) {
             $users = $this->userManager->search('');
         } else {
             $users = $input->getArgument('user_id');
         }
     }
     if (count($users) === 0) {
         $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
         return;
     }
     # no messaging level option means: no full printout but statistics
     # $quiet   means no print at all
     # $verbose means full printout including statistics
     # -q	-v	full	stat
     #  0	 0	no	yes
     #  0	 1	yes	yes
     #  1	--	no	no  (quiet overrules verbose)
     $verbose = $input->getOption('verbose');
     $quiet = $input->getOption('quiet');
     # restrict the verbosity level to VERBOSITY_VERBOSE
     if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
         $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
     }
     if ($quiet) {
         $verbose = false;
     }
     $this->initTools();
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         $path = $inputPath ? $inputPath : '/' . $user;
         if ($this->userManager->userExists($user)) {
             # full: printout data if $verbose was set
             $this->scanFiles($user, $path, $verbose, $output);
         } else {
             $output->writeln("<error>Unknown user {$user}</error>");
         }
     }
     # stat: printout statistics if $quiet was not set
     if (!$quiet) {
         $this->presentStats($output);
     }
 }
コード例 #4
0
ファイル: scan.php プロジェクト: WYSAC/oregon-owncloud
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('all')) {
         $users = $this->userManager->search('');
     } else {
         $users = $input->getArgument('user_id');
     }
     if (count($users) === 0) {
         $output->writeln("<error>Please specify the user id to scan or \"--all\" to scan for all users</error>");
         return;
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         if ($this->userManager->userExists($user)) {
             $this->scanFiles($user, $output);
         } else {
             $output->writeln("<error>Unknown user {$user}</error>");
         }
     }
 }
コード例 #5
0
ファイル: migratekeys.php プロジェクト: kenwi/core
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // perform system reorganization
     $migration = new Migration($this->config, $this->view, $this->connection, $this->logger);
     $users = $input->getArgument('user_id');
     if (!empty($users)) {
         foreach ($users as $user) {
             if ($this->userManager->userExists($user)) {
                 $output->writeln("Migrating keys   <info>{$user}</info>");
                 $migration->reorganizeFolderStructureForUser($user);
             } else {
                 $output->writeln("<error>Unknown user {$user}</error>");
             }
         }
     } else {
         $output->writeln("Reorganize system folder structure");
         $migration->reorganizeSystemFolderStructure();
         $migration->updateDB();
         foreach ($this->userManager->getBackends() as $backend) {
             $name = get_class($backend);
             if ($backend instanceof IUserBackend) {
                 $name = $backend->getBackendName();
             }
             $output->writeln("Migrating keys for users on backend <info>{$name}</info>");
             $limit = 500;
             $offset = 0;
             do {
                 $users = $backend->getUsers('', $limit, $offset);
                 foreach ($users as $user) {
                     $output->writeln("   <info>{$user}</info>");
                     $migration->reorganizeFolderStructureForUser($user);
                 }
                 $offset += $limit;
             } while (count($users) >= $limit);
         }
     }
     $migration->finalCleanUp();
 }
コード例 #6
0
ファイル: util.php プロジェクト: samj1912/repo
 /**
  * check if it is a path which is excluded by ownCloud from encryption
  *
  * @param string $path
  * @return boolean
  */
 public function isExcluded($path)
 {
     $normalizedPath = \OC\Files\Filesystem::normalizePath($path);
     $root = explode('/', $normalizedPath, 4);
     if (count($root) > 1) {
         //detect system wide folders
         if (in_array($root[1], $this->excludedPaths)) {
             return true;
         }
         // detect user specific folders
         if ($this->userManager->userExists($root[1]) && in_array($root[2], $this->excludedPaths)) {
             return true;
         }
     }
     return false;
 }
コード例 #7
0
 /**
  * @param string $token
  * @return string Resolved file path of the token
  * @throws \Exception In case share could not get properly resolved
  */
 private function getPath($token)
 {
     $linkItem = Share::getShareByToken($token, false);
     if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
         // seems to be a valid share
         $rootLinkItem = Share::resolveReShare($linkItem);
         if (isset($rootLinkItem['uid_owner'])) {
             if (!$this->userManager->userExists($rootLinkItem['uid_owner'])) {
                 throw new \Exception('Owner of the share does not exist anymore');
             }
             OC_Util::tearDownFS();
             OC_Util::setupFS($rootLinkItem['uid_owner']);
             $path = Filesystem::getPath($linkItem['file_source']);
             if (!empty($path) && Filesystem::isReadable($path)) {
                 return $path;
             }
         }
     }
     throw new \Exception('No file found belonging to file.');
 }
コード例 #8
0
ファイル: util.php プロジェクト: loulancn/core
 /**
  * check if it is a path which is excluded by ownCloud from encryption
  *
  * @param string $path
  * @return boolean
  */
 public function isExcluded($path)
 {
     $normalizedPath = Filesystem::normalizePath($path);
     $root = explode('/', $normalizedPath, 4);
     if (count($root) > 1) {
         // detect alternative key storage root
         $rootDir = $this->getKeyStorageRoot();
         if ($rootDir !== '' && 0 === strpos(Filesystem::normalizePath($path), Filesystem::normalizePath($rootDir))) {
             return true;
         }
         //detect system wide folders
         if (in_array($root[1], $this->excludedPaths)) {
             return true;
         }
         // detect user specific folders
         if ($this->userManager->userExists($root[1]) && in_array($root[2], $this->excludedPaths)) {
             return true;
         }
     }
     return false;
 }
コード例 #9
0
ファイル: scan.php プロジェクト: matthias-g/core
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $inputPath = $input->getOption('path');
     if ($inputPath) {
         $inputPath = '/' . trim($inputPath, '/');
         list(, $user, ) = explode('/', $inputPath, 3);
         $users = array($user);
     } else {
         if ($input->getOption('all')) {
             $users = $this->userManager->search('');
         } else {
             $users = $input->getArgument('user_id');
         }
     }
     # no messaging level option means: no full printout but statistics
     # $quiet   means no print at all
     # $verbose means full printout including statistics
     # -q	-v	full	stat
     #  0	 0	no	yes
     #  0	 1	yes	yes
     #  1	--	no	no  (quiet overrules verbose)
     $verbose = $input->getOption('verbose');
     $quiet = $input->getOption('quiet');
     # restrict the verbosity level to VERBOSITY_VERBOSE
     if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) {
         $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
     }
     if ($quiet) {
         $verbose = false;
     }
     # check quantity of users to be process and show it on the command line
     $users_total = count($users);
     if ($users_total === 0) {
         $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>");
         return;
     } else {
         if ($users_total > 1) {
             $output->writeln("\nScanning files for {$users_total} users");
         }
     }
     $this->initTools();
     $user_count = 0;
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         $path = $inputPath ? $inputPath : '/' . $user;
         $user_count += 1;
         if ($this->userManager->userExists($user)) {
             # add an extra line when verbose is set to optical seperate users
             if ($verbose) {
                 $output->writeln("");
             }
             $output->writeln("Starting scan for user {$user_count} out of {$users_total} ({$user})");
             # full: printout data if $verbose was set
             $this->scanFiles($user, $path, $verbose, $output);
         } else {
             $output->writeln("<error>Unknown user {$user_count} {$user}</error>");
         }
         # check on each user if there was a user interrupt (ctrl-c) and exit foreach
         if ($this->hasBeenInterrupted()) {
             break;
         }
     }
     # stat: printout statistics if $quiet was not set
     if (!$quiet) {
         $this->presentStats($output);
     }
 }