本文整理汇总了PHP中Crypt::isLegacyEncryptedContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt::isLegacyEncryptedContent方法的具体用法?PHP Crypt::isLegacyEncryptedContent怎么用?PHP Crypt::isLegacyEncryptedContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypt
的用法示例。
在下文中一共展示了Crypt::isLegacyEncryptedContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findEncFiles
/**
* @brief Find all files and their encryption status within a directory
* @param string $directory The path of the parent directory to search
* @param bool $found the founded files if called again
* @return mixed false if 0 found, array on success. Keys: name, path
* @note $directory needs to be a path relative to OC data dir. e.g.
* /admin/files NOT /backup OR /home/www/oc/data/admin/files
*/
public function findEncFiles($directory, &$found = false)
{
// Disable proxy - we don't want files to be decrypted before
// we handle them
\OC_FileProxy::$enabled = false;
if ($found === false) {
$found = array('plain' => array(), 'encrypted' => array(), 'legacy' => array());
}
if ($this->view->is_dir($directory) && ($handle = $this->view->opendir($directory))) {
if (is_resource($handle)) {
while (false !== ($file = readdir($handle))) {
if ($file !== "." && $file !== "..") {
$filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
$relPath = \OCA\Encryption\Helper::stripUserFilesPath($filePath);
// If the path is a directory, search
// its contents
if ($this->view->is_dir($filePath)) {
$this->findEncFiles($filePath, $found);
// If the path is a file, determine
// its encryption status
} elseif ($this->view->is_file($filePath)) {
// Disable proxies again, some-
// where they got re-enabled :/
\OC_FileProxy::$enabled = false;
$isEncryptedPath = $this->isEncryptedPath($filePath);
// If the file is encrypted
// NOTE: If the userId is
// empty or not set, file will
// detected as plain
// NOTE: This is inefficient;
// scanning every file like this
// will eat server resources :(
if (Keymanager::getFileKey($this->view, $this, $relPath) && $isEncryptedPath) {
$found['encrypted'][] = array('name' => $file, 'path' => $filePath);
// If the file uses old
// encryption system
} elseif (Crypt::isLegacyEncryptedContent($isEncryptedPath, $relPath)) {
$found['legacy'][] = array('name' => $file, 'path' => $filePath);
// If the file is not encrypted
} else {
$found['plain'][] = array('name' => $file, 'path' => $relPath);
}
}
}
}
}
\OC_FileProxy::$enabled = true;
if (empty($found)) {
return false;
} else {
return $found;
}
}
\OC_FileProxy::$enabled = true;
return false;
}