-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
来自codeium
function scanDirectory($directory)
{
$currentPath = realpath(DIR);
$allowedPaths = array(
$currentPath,
);
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST
);
$files = array();
foreach ($iterator as $file) {
if ($file->isFile()) {
$filePath = $file->getPathname();
$realPath = realpath($filePath);
if ($realPath !== false && isAllowedPath($realPath, $allowedPaths)) {
$files[] = $realPath;
}
}
}
return $files;
}
function isAllowedPath($path, $allowedPaths)
{
foreach ($allowedPaths as $allowedPath) {
if (strpos($path, $allowedPath) === 0) {
return true;
}
}
return false;
}
另外把同步的主机弄成参数 我现在的方案 管理20台机太难了
添加了白名单 但是strpos要消耗平方算力 虽然也不多 看看有没有优化空间
Metadata
Metadata
Assignees
Labels
No labels