-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbackimage.php
More file actions
46 lines (33 loc) · 1.13 KB
/
backimage.php
File metadata and controls
46 lines (33 loc) · 1.13 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
<?php
ob_start();
include ("includes/vars.php");
include ("includes/functions.php");
$output = array();
if (array_key_exists('getbackground', $_REQUEST)) {
if (is_dir('prefs/userbackgrounds/'.$_REQUEST['getbackground'])) {
$f = glob('prefs/userbackgrounds/'.$_REQUEST['getbackground'].'/*.*');
if (count($f) > 0) {
$output = array('image' => $f[0]);
}
}
} else if (array_key_exists('clearbackground', $_REQUEST)) {
if (is_dir('prefs/userbackgrounds/'.$_REQUEST['clearbackground'])) {
system('rm -rf prefs/userbackgrounds/'.$_REQUEST['clearbackground']);
}
} else {
$file = $_FILES['imagefile']['name'];
$base = $_REQUEST['currbackground'];
$download_file = "";
$fname = basename($file);
$download_file = get_user_file($file, $fname, $_FILES['imagefile']['tmp_name']);
if (is_dir('prefs/userbackgrounds/'.$base)) {
system('rm prefs/userbackgrounds/'.$base.'/*.*');
} else {
system('mkdir prefs/userbackgrounds/'.$base);
}
system('mv "'.$download_file.'" "prefs/userbackgrounds/'.$base.'/'.$fname.'"');
$output = array('image' => 'prefs/userbackgrounds/'.$base.'/'.$fname);
}
print json_encode($output);
ob_flush();
?>