-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathvideoFileManagement.php
More file actions
82 lines (70 loc) · 2.01 KB
/
Copy pathvideoFileManagement.php
File metadata and controls
82 lines (70 loc) · 2.01 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/*
* This is a short API to allow user to interact with rendered files such as :
* - list file rendered
* - remove a file
* - download a file
*
*/
include "config.php";
function listFiles($project)
{
global $DIR_projectsData;
$path = '../' . $DIR_projectsData . $project . '/RENDER_DATA/';
$dir = opendir($path);
$tabListVideoFile = [];
$i = 0;
while($file = readdir($dir))
{
if($file != '.' && $file != '..' && !is_dir($path . $file))
{
if(is_numeric(explode(".",$file)[0]))
{
$tabListVideoFile[$i] = $file;
$i++ ;
}
}
}
closedir($dir);
return json_encode($tabListVideoFile);
}
function readVideoFile($project, $id)
{
global $DIR_projectsData;
$path = '../' . $DIR_projectsData . $project . '/RENDER_DATA/';
$file=$id;
if (($file != "") && (file_exists($path . basename($file))))
{
$size = filesize($path . basename($file));
header("Content-Type: application/force-download; name=\"" . basename($file) . "\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $size");
header("Content-Disposition: attachment; filename=\"" . basename($file) . "\"");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile($path . basename($file));
exit();
}
}
function deleteFile($project, $id)
{
global $DIR_projectsData;
$path = '../' . $DIR_projectsData .$project . '/RENDER_DATA/';
unlink($path.basename($id));
unlink($path.basename(explode(".",$id)[0]."_WEB.".explode(".",$id)[1]));
}
switch ($_GET['action'])
{
case "list":
echo listFiles($_GET['projectName']);
break;
case "read":
readVideoFile($_GET['projectName'],$_GET['id']);
break;
case "delete":
deleteFile($_GET['projectName'],$_GET['id']);
break;
default:
echo "Missing args";
}