forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpluginImport.json.php
44 lines (37 loc) · 1.37 KB
/
pluginImport.json.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
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/plugin.php';
header('Content-Type: application/json');
$obj = new stdClass();
$obj->uploaded = false;
$obj->filename = $_FILES['input-b1']['name'];
if (!empty($global['disableAdvancedConfigurations'])) {
die(json_encode($obj));
}
if (!User::isAdmin()) {
$obj->msg = "You are not admin";
die(json_encode($obj));
}
$allowed = ['zip'];
$path_parts = pathinfo($_FILES['input-b1']['name']);
$extension = $path_parts['extension'];
if (!in_array(strtolower($extension), $allowed)) {
$obj->msg = "File extension error (" . $_FILES['input-b1']['name'] . "), we allow only (" . implode(",", $global['allowed']) . ")";
die(json_encode($obj));
}
if (strcasecmp($extension, 'zip') == 0) {
//$id = File::encodeAndsaveZipFile($_FILES['input-b1']['tmp_name'], $_FILES['input-b1']['name'], $key);
$destination = "{$global['systemRootPath']}plugin/";
$obj->destination = $destination;
$path = $_FILES['input-b1']['tmp_name'];
$dir = "{$destination}/{$path_parts['filename']}";
if (is_dir($dir)) {
rrmdir($dir);
}
exec("unzip {$path} -d {$destination}");
}
die(json_encode($obj));