-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteallimages.php
38 lines (30 loc) · 1.13 KB
/
deleteallimages.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once(__DIR__ . '/../../config.php');
// Ensure this script is accessed within Moodle.
defined('MOODLE_INTERNAL') || die();
// Require the user to be logged in.
require_login();
$PAGE->set_url(new moodle_url('/auth/faceauth/deleteallimages.php'));
$PAGE->set_context(context_system::instance());
$PAGE->set_title(get_string('deleteallimages', 'auth_faceauth'));
// Directory to store enrolled face images.
$upload_dir = $CFG->dataroot . '/faceauth/faces/';
// Ensure the upload directory exists.
if (!is_dir($upload_dir)) {
debugging("Upload directory does not exist: {$upload_dir}", DEBUG_DEVELOPER);
echo $OUTPUT->notification(get_string('dirdoesnotexist', 'auth_faceauth'), 'notifyproblem');
exit;
}
// Delete all images in the directory.
$files = glob($upload_dir . '*');
foreach ($files as $file) {
if (is_file($file)) {
unlink($file);
}
}
// Output the header.
echo $OUTPUT->header();
// Display the success message.
echo $OUTPUT->notification(get_string('deleteallimagessuccess', 'auth_faceauth'), 'notifysuccess');
// Output the footer.
echo $OUTPUT->footer();