-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup_delete.php
52 lines (41 loc) · 1.17 KB
/
backup_delete.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
define('CLI_SCRIPT', true); //enable for command line execution
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->dirroot . '/course/lib.php');
global $DB;
$sql = <<<SQL
SELECT
component
, filearea
, itemid
, contextid
, filepath
, filename
FROM mdl_files as f
LIMIT 1
SQL;
$records = $DB->get_records_sql($sql);
//var_dump($records);
//print_r($records);
$fs = get_file_storage();
// Prepare file record object
$fileinfo = array(
'component' => $records['course']->component,
'filearea' => $records['course']->filearea, // usually = table name
'itemid' => $records['course']->itemid, // usually = ID of row in table
'contextid' => $records['course']->contextid, // ID of context
'filepath' => $records['course']->filepath, // any path beginning and ending in /
'filename' => $records['course']->filename,); // any filename
// Get file
$file = $fs->get_file($fileinfo['contextid'], $fileinfo['component'], $fileinfo['filearea'],
$fileinfo['itemid'], $fileinfo['filepath'], $fileinfo['filename']);
if(empty($file))
{
echo "empty";
}
else {
print_r($file);
//$file->delete();
//echo "Deleted";
}
?>