Display mmc from FS

This commit is contained in:
Александр Бабкин
2022-07-12 12:14:24 +03:00
parent 22a4895262
commit 8a971e1667
5 changed files with 130 additions and 4 deletions

View File

@@ -127,6 +127,62 @@ class MMCController extends Controller
{
$project_id = $request->session()->get('project_id');
$project = Project::find($project_id);
return view('mmc.scan', ['project' => $project]);
$MMC = array();
$total_size = 0;
$total_count = 0;
$MMC_PATH = $project->mmc_path;
$mmc_dir = scandir($MMC_PATH);
foreach ($mmc_dir as $entry) {
$course_path = $MMC_PATH . '/' . $entry;
if (is_dir($course_path)) {
if (intval($entry) > 0 && intval($entry) < 99) {
// $MMC[] = $entry;
// echo ($entry . "\n");
$mmc_course_dir = scandir($course_path);
foreach ($mmc_course_dir as $course_entry) {
// VVV Images VVV
if (strcasecmp($course_entry, 'images') == 0) {
$course_image_path = $course_path . '/' . $course_entry;
if (is_dir($course_image_path)) {
// echo ($course_image_path . "\n");
$MMC[$entry]['image_dir'] = $course_entry;
$course_images = scandir($course_image_path);
foreach ($course_images as $image) {
$image_file_path = $course_image_path . '/' . $image;
if (is_file($image_file_path)) {
if (strncmp($entry, $image, 2) == 0) {
if (
strcasecmp(substr($image, -3, 3), 'jpg') == 0 ||
strcasecmp(substr($image, -3, 3), 'svg') == 0 ||
strcasecmp(substr($image, -3, 3), 'swf') == 0
) {
// $MMC[$entry][] = $image;
$tmp_array = array();
$tmp_array['file'] = $image;
$tmp_array['size'] = filesize($image_file_path);
$tmp_array['mtime'] = filemtime($image_file_path);
$tmp_array['atime'] = fileatime($image_file_path);
$MMC[$entry]['images'][] = $tmp_array;
$total_size += $tmp_array['size'];
$total_count++;
}
}
}
}
}
}
// ^^^ Images ^^^
}
}
}
}
return view('mmc.scan', ['project' => $project,'MMC' => $MMC]);
}
}