-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgui.php
More file actions
114 lines (101 loc) · 3.08 KB
/
gui.php
File metadata and controls
114 lines (101 loc) · 3.08 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
<html>
<head>
<script>
function uploadFile(file) {
var xhr = new XMLHttpRequest();
xhr.upload.onprogress = function(e) {
var percentComplete = (e.loaded / e.total) * 100;
if (percentComplete < 99) {
document.getElementById("pasteOutput").innerHTML = "Uploaded " + percentComplete + "%";
} else {
document.getElementById("pasteOutput").innerHTML = "Almost done";
}
};
var fd = new FormData();
fd.append("data", file);
if (pastePassword.value != '') {
fd.append("password", pastePassword.value);
}
if (pastePassword.duration != '') {
fd.append("duration", pasteDuration.value);
}
xhr.onload = function() {
if (xhr.status == 200) {
document.getElementById("pasteOutput").innerHTML = "<a href='" + xhr.responseText + "' target='_blank'>" + xhr.responseText + "</a>";
} else {
alert("Error! Upload failed");
document.getElementById("pasteOutput").innerHTML = 'Upload failed';
}
};
xhr.onerror = function() {
alert("Error! Upload failed. Can not connect to server.");
};
xhr.open("POST", "ajax_gui_upload.php", true);
xhr.send(fd);
}
function handlePaste(e) {
document.getElementById("pasteOutput").innerHTML = "Starting";
ok = false;
for (var i = 0 ; i < e.clipboardData.items.length ; i++) {
var item = e.clipboardData.items[i];
if (item.type.indexOf("image") -1) {
if (item.getAsFile() != null) {
uploadFile(item.getAsFile());
ok = true;
}
}
}
if (!ok) {
document.getElementById("pasteOutput").innerHTML = "Error";
alert("Error, the thing you pasted isn't a file. It works if you copy paste a file or a picture.");
}
}
</script>
</head>
<body>
<?php
require_once('lib/lib.php');
alert_default_password_html();
?>
<fieldset>
<legend>Usual upload button (you can drag n' drop)</legend>
<div>
<form class="box" method="post" action="gui_upload.php" enctype="multipart/form-data">
Duration in minutes (link will work only in that duration):<input type="numeric" min="1" />
<br>Password:<input type="password" name="password" />
<input type="file" name="data" required />
<br/>
<button type="submit">Upload</button>
</form>
</div>
</fieldset>
<fieldset>
<legend>Copy paste</legend>
Start with filling the password etc before, as soon as you paste the link is created
<br>Duration in minutes (link will work only in that duration):<input id="pasteDuration" type="numeric" min="1" />
<br>Password:<input type="password" id="pastePassword" name="password" />
<div id="pasteTarget">
<fieldset style="width: 200px; height:100px">
<legend>click and past here</legend>
</fieldset>
</div>
<div id="pasteOutput">
Link will appear here
</div>
</fieldset>
<fieldset>
<legend>Url shortener</legend>
Enter the url
<form class="box" method="post" action="gui_shortener.php" enctype="multipart/form-data">
<input type="text" style="width: 100%" name="url" required />
<br/>
<button type="submit">Process</button>
<form>
</fieldset>
</body>
<script>
window.onload = function() {
document.getElementById("pasteTarget").addEventListener("paste", handlePaste);
}
</script>
</html>