-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·126 lines (116 loc) · 3.7 KB
/
Copy pathindex.php
File metadata and controls
executable file
·126 lines (116 loc) · 3.7 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
/* For license information please read the LICENSE file */
/* Copyright (c) 2015 Antonios A. Chariton <daknob.mac@gmail.com> */
$WEBSITE = "https://daknob.net/"; /* Website for redirects */
require("password.php");
if($_SERVER['HTTPS'] != 'on'){
header("Location: https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
if(isset($_POST['action']) && $_POST['action'] == "action"){ /* Check if the form is submitted */
$saveTo = "../STORAGE/" . $_FILES['filename']['name']; /* Generate the path the file's supposed to be saved in */
if(hash("sha256", $_POST['pass']) === $PASSWORD && strcmp(hash("sha256", $_POST['pass']), $PASSWORD)===0){ /* Check if the password is correct */
unset($_POST['pass']); /* Attempt to remove password from memory */
if(is_dir("../STORAGE") === FALSE){ /* If it's the first time this runs, do some filesystem initialization */
mkdir("../STORAGE");
chmod("../STORAGE", 0700);
chmod("index.php", 0700);
file_put_contents("../STORAGE/.htaccess", "Allow from none\nDeny from all\nSatisfy all\n");
file_put_contents("../STORAGE/index.php", "<?php header('Location: $WEBSITE'); ?>\n");
chmod("../STORAGE/.htaccess", 0755);
}
while(file_exists($saveTo)){ /* Dumb way to avoid filename collisions */
$saveTo = $saveTo . ".n";
}
if(move_uploaded_file($_FILES['filename']['tmp_name'], $saveTo)){ /* Try to 'upload' the file */
print("<h1 class='suc'>File upload completed.</h1>"); /* File uploaded successfully */
mail(get_current_user() . "@csd.uoc.gr", "File upload successful!", "You have successfully uploaded the file " . array_pop(explode("/", $saveTo)) . " using FileUpload.", "From: File Upload<fileupload@csd.uoc.gr>");
}else{
print("<h1>An error occured while uploading the file.</h1>");
}
}else{
print("<h1>An error occured while uploading file. Wrong password.</h1>");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php print get_current_user(); ?>'s File Uploader</title>
<style>
.suc{
color:#282;
background-color:rgba(63, 190, 63, 0.3);
}
h1{
font:20px Helvetica;
color:#822;
width:60%;
border: 2px solid;
text-align:center;
margin-left:auto;
margin-right:auto;
padding-top:5px;
padding-bottom:5px;
background-color:rgba(190, 63, 63, 0.3);
}
body{
background-color:#abc;
}
div.bodi{
padding-top:100px;
padding-bottom:100px;
}
img{
margin-left:auto;
margin-right:auto;
display:block;
}
form{
margin-left:auto;
margin-right:auto;
text-align:center;
padding-top:20px;
}
span.filed{
font:20px Helvetica;
color:#666;
padding-left:100px;
}
#filename{
font:15px Helvetica;
color:#666;
}
#pass{
font:20px Helvetica;
margin-top:10px;
color:#666;
border-radius:10px;
padding-left:5px;
padding-right:5px;
border: 1px solid;
}
#submit{
font:18px Helvetica;
color:#666;
border-radius:10px;
border: 1px solid;
padding: 5px;
}
</style>
</head>
<body>
<div class="bodi">
<img src="logo.png" height="200px"/>
<form action="." method="post" enctype="multipart/form-data">
<span class="filed">File: </span>
<input type="file" name="filename" id="filename"><br/>
<input type="hidden" name="action" value="action">
<input type="password" name="pass" id="pass">
<input type="submit" value="Upload" name="submit" id="submit">
</form>
<br>
<center><span style="text-align:center; margin-left:auto;margin-right:auto;font: 12px Helvetica; color:#666;">Copyright © 2015 - Antonios A. Chariton <daknob.mac@gmail.com></span></center>
</div>
</body>
</html>