forked from WWBN/AVideo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaveImage.json.php
65 lines (51 loc) · 1.46 KB
/
saveImage.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
global $global, $config;
header('Content-Type: application/json');
if (!isset($global['systemRootPath'])) {
require_once '../../videos/configuration.php';
}
$result = new stdClass();
$result->error = true;
$result->msg = '';
$result->url = '';
$result->imageURL = '';
if (!User::isAdmin()) {
$result->msg = __("You can not do this");
die(json_encode($result));
}
require_once $global['systemRootPath'] . 'plugin/API/API.php';
$obj = AVideoPlugin::getObjectDataIfEnabled("ADs");
if (empty($obj)) {
$result->msg = __("The plugin is disabled");
die(json_encode($result));
}
$type = $_REQUEST['type'];
if (empty($type)) {
$result->msg = __("Type is not defined");
die(json_encode($result));
}
$typeFound = false;
foreach (ADs::$AdsPositions as $key => $value) {
if($type===$value[0]){
$typeFound = true;
break;
}
}
if (empty($typeFound)) {
$result->msg = __("Type NOT found");
die(json_encode($result));
}
if(!IsValidURL(@$_REQUEST['url'])){
$_REQUEST['url'] = '';
}
$paths = ADs::getNewAdsPath($type);
saveCroppieImage($paths['path'], "image");
file_put_contents($paths['txt'], @$_REQUEST['url']);
$result->type = $type;
$result->url = $_REQUEST['url'];
$result->imageURL = $paths['url'];
$result->fileName = $paths['fileName'];
$result->error = false;
$result->save = ADs::saveAdsHTML($type);
// save plugin parameter
die(json_encode($result));