-
Notifications
You must be signed in to change notification settings - Fork 18
/
make.php
80 lines (80 loc) · 1.92 KB
/
make.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
if($_FILES['file']['error']>0)
{
echo "Error: ".$_FILES['file']['error']."<br />";
}
else if($_FILES['file']['size']>20500)
{
echo "The size of the uploaded file is greater than 20 KB";
}
else
{
if(($_FILES['file']['type']=="application/zip") || ($_FILES['file']['type']=="application/x-gzip"))
{
move_uploaded_file($_FILES['file']['tmp_name'],$_FILES['file']['name']);
$dir_name="multi";
mkdir($dir_name);
if($_FILES['file']['type']=="application/zip")
{
$extract_error="extract_error.txt";
$extract="unzip ".$_FILES['file']['name']." -d $dir_name";
$extract_out="extract_out.txt";
shell_exec("$extract 1>$extract_out 2>$extract_error");
}
else
{
$extract_error="extract_error.txt";
$extract="tar -xzf ".$_FILES['file']['name']." -C $dir_name";
$extract_out="extract_out.txt";
shell_exec("$extract 1>$extract_out 2>$extract_error");
}
$error=file_get_contents($extract_error);
$out=file_get_contents($extract_out);
if(trim($error)=="")
{
$dir=opendir($dir_name);
$count=0;
while (($file = readdir($dir)) !== false)
{
$file_name=$file;
$count=$count+1;
}
$make_error="make_error.txt";
if(($count==3) && (is_dir($file_name)==true))
{
$make="make -C $dir_name/$file_name";
}
else
{
$make="make -C $dir_name";
}
$make_out="make_out.txt";
shell_exec("$make 1>$make_out 2>$make_error");
$error=file_get_contents($make_error);
$out=file_get_contents($make_out);
if(trim($error)=="")
{
echo "<pre>$out</pre>";
}
else
{
echo "<pre>$error</pre>";
}
closedir($dir_name);
}
else
{
echo "<pre>$out</pre><pre>$error</pre>";
}
}
else
{
echo 'Please upload only ".zip" or ".tar.gz" files';
}
}
include "../recursive_directory_delete.php";
recursive_remove_directory("multi");
exec("rm *.txt");
exec("rm *.zip");
exec("rm *.tar.gz");
?>