-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.php
57 lines (51 loc) · 1.44 KB
/
handler.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
<?php
ini_set('display_errors', 'On');
include("moss.php");
$userid = ""; // Enter your MOSS userid
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir."/".$object))
rrmdir($dir."/".$object);
else
unlink($dir."/".$object);
}
}
rmdir($dir);
} else {
unlink($dir);
}
}
if(isset($_GET['delete'])) {
$path = "./uploads/".$_GET['delete'];
rrmdir($path);
echo $_GET['delete']." deleted!";
header( "Location:index.php");
}
if(isset($_FILES['upload']['name'])) {
$total = count($_FILES['upload']['name']);
if($_POST['assignment'] != "") {
$assigndir = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['assignment']);
} else {
$assigndir = "tmpdir".rand();
}
for($i=0; $i<$total; $i++) {
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
if ($tmpFilePath != ""){
if (!file_exists("./uploads/".$assigndir)) {
mkdir("./uploads/".$assigndir, 0755, true);
}
$newFilePath = "./uploads/". $assigndir . "/" . $_FILES['upload']['name'][$i];
move_uploaded_file($tmpFilePath, $newFilePath);
}
}
$moss = new MOSS($userid);
$moss->setLanguage($_POST['language']);
$moss->addByWildcard("./uploads/".$assigndir."/*");
$url = $moss->send();
rrmdir("./uploads/".$assigndir);
header( "Location:".$url);
}
?>