-
Notifications
You must be signed in to change notification settings - Fork 1
/
checker.php
80 lines (60 loc) · 1.59 KB
/
checker.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
exit ("Return back. This is demo project.");
include_once(__DIR__.'/assets/header.php');
$error=false;
$max_size_limit = 10 * 1000 * 1000;
if (isset($_FILES['fileToUpload']))
{
$file = $_FILES['fileToUpload'];
/* i.e.
[name] => example.zip
[type] => application/zip
[tmp_name] => /path/to/dir/tmp/php233A.tmp
[error] => 0
[size] => 100780
*/
if ($file['size'] > $max_size_limit ){
$error= "Filesize too big (max allowed: $max_size_limit )";
}
else if ( !$f->validate_zip($file['tmp_name']) ){
$error= "incorrect file type. Upload .ZIP file.";
}
//success
else{
//..
}
}
?>
<div class="check_results">
<?php
if ($error) {
echo "<h2>$error</h2>";
}
else{
echo "<h2>Successfully uploaded! Wait for results : ... </h2>";
// The WAR start here....
// ....codes ....
// ....codes ....
// ....codes ....
// ....codes ....
// ....codes ....
// ....codes ....
// ...
$temp_destination = $f->temp_bin().'/'. $file['name'];
move_uploaded_file($file['tmp_name'], $temp_destination);
$temp_unzip_dir = dirname($temp_destination) .'/'. basename( preg_replace('/\.(.*)/', rand(1,999999999), $temp_destination) );
$f->unzip($temp_destination,$temp_unzip_dir);
// scan $temp_unzip_dir with SCANNER, generate & save report, delete temp_dir and show results to user
// ...
// ....codes ....
// ....codes ....
// ....codes ....
// ....codes ....
// ....codes ....
// ....codes ....
}
?>
</div>
<?php
include_once(__DIR__.'/assets/footer.php');
?>