-
Notifications
You must be signed in to change notification settings - Fork 0
/
process.php
88 lines (67 loc) · 2.67 KB
/
process.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
81
82
83
84
85
86
87
88
<?php
// setup
if( !isset($_GET['id']) ){
die();
}
// data & checks
$user_ip = $_GET['id'];
$filename = $_FILES['file']['name'];
$date = date('m/d/Y h:i:s', time());
$size = (int)$_FILES['file']['size'] / (int)1000000;
$sizename = number_format((float)$size, 2, '.', '') . ' mb';
$conf = parse_ini_file("config.ini");
if( ($_FILES['file']['name'] == '.htaccess') ){
die();
}
if( ($_FILES['file']['name'] == '.htpasswd') ){
die();
}
if (strpos($_FILES['file']['name'], '.php') !== false) {
die();
}
// SQL Insert
$con = new mysqli($conf['server'], $conf['user'], $conf['pass'], $conf['dbname']);
if($con->connect_error){
die();
}
// Handle Upload
switch($_GET['protected']){
/* Private Upload */
case true:
if(empty($_GET['pass'])){
die();
}
$filepass = password_hash($_GET['pass'], PASSWORD_DEFAULT);
$private_sql = "INSERT INTO private_uploads (IP, fname, fsize, fdate, fpwd)
VALUES ('$user_ip', '$filename', '$sizename', '$date', '$filepass')";
if ($con->query($private_sql) === TRUE) {
# success
} else {
die();
}
$con->close();
$filename = 'pvt-up_'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], '../sec_shared/'.$filename);
// mail
$message = 'New file upload by ' . $user_ip . ' <br> Filename: ' . $filename;
mail('[email protected]','New Shared Protected Upload',$message,'From: [email protected]');
break;
/* Public Upload */
case false:
$sql = "INSERT INTO public_uploads (IP, fname, fsize, fdate)
VALUES ('$user_ip', '$filename', '$sizename', '$date')";
if ($con->query($sql) === TRUE) {
# success
} else {
die();
}
$con->close();
$filename = 't-up_'.$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], 'shared/'.$filename);
// mail
$message = 'New file upload by ' . $user_ip . ' <br> Filename: ' . $filename;
mail($conf['mailto'],'New Shared Public Upload',$message,$conf['mailfrom']);
break;
}
die;
?>