-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathshare.php
More file actions
95 lines (87 loc) · 2.79 KB
/
share.php
File metadata and controls
95 lines (87 loc) · 2.79 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
<?php
header('Content-Type: text/plain');
// Preparation :
// i need a DB, with conf/config.php describing the connection id
// need php-mysql
// the help is displayed if we call this php without any parameter
// clear.php can be called manually to clean the db of outdated stuff
// all files and dir should be readable by www-data
require_once('lib/lib.php');
require_once('lib/init.php');
function debug()
{
// récupère tout de la collection
$cursor = $coll->find();
// traverse les résultats
foreach ($cursor as $document) {
echo $document["id"] . "\n";
}
}
function print_help() {
alert_default_password();
print("Syntax :\n");
print("\n");
print(" To upload somethg\n");
print("somethg | curl -F data=@- ".page_url_upload()."\n");
print("\n");
print("Will return the url to reach the posted data\n");
print("\n");
print(" To upload somethg with a limited duration, in minutes\n");
print("somethg | curl -F data=@- -F 'duration=1' ".page_url_upload()." \n");
print("\n");
print("Will return the url to reach the posted data. After the duration written, the posted element won't be available\n");
print("\n");
print(" To upload somethg with a password\n");
print("somethg | curl -F data=@- -F 'password=foobar' ".page_url_upload()."\n");
print("\n");
print("Will return the url to reach the posted data, and the parameter password ready to be filled.\n");
print("\n");
print("Notes :\n");
print(" - you can have duration and password\n");
print("\n");
print(" To upload somethg with the gui\n");
printf("go to %s", page_url_gui());
print("\n");
print("\n");
print(" To download somethg\n");
print("\n");
#printf("curl %s[url given when uploading]\n", (defined("SHORTURL") ? "-L " : ""));
printf("curl [url given when uploading]\n");
print("\n");
print("If the url has a password parameter, you have to fill it with the password used to upload the element.\n");
print("\n");
print("Notes :\n");
print("- if the password is wrong, the message 'incorrect password' will be returned\n");
print("- if the element doesn't exists anymore, or never existed, the message 'not found' will be returned\n");
print("\n");
}
if (isset($_GET['id'])) {
// fetching something
$password = '';
if (isset($_GET['password'])) {
$password = $_GET['password']; }
print(get($conn, $_GET['id'], $password));
}
elseif (isset($_FILES['data'])) {
// storing something
$duration = Null;
if (isset($_POST['duration'])) {
if ($_POST['duration'] != '') {
$duration = $_POST['duration'];
}
}
$password = Null;
if (isset($_POST['password'])) {
if ($_POST['password'] != '') {
$password = $_POST['password'];
}
}
if (isset($_FILES['data'])) {
$id = put($conn, $duration, $_FILES['data'], $password);
print(page_url_download($id, isset($password)) . "\n");
}
}
else {
print_help();
}
?>