-
Notifications
You must be signed in to change notification settings - Fork 0
/
sharing.php
95 lines (87 loc) · 3.35 KB
/
sharing.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
89
90
91
92
93
94
95
<?php
// +-----------------------------------+
// | FoxCloud |
// +-----------------------------------+
// | Questo file fa parte del progetto |
// | di Cloud Open Source "FoxCloud", |
// | realizzato da FoxWorn. |
// +-----------------------------------+
// | Web: https://foxcloud.fcosma.it |
// | GH: github.com/FoxWorn3365/Cloud |
// | License: GNU GPL 3.0 |
// +-----------------------------------+
// | You can write me an email at: |
// | [email protected], also for |
// | talk! |
// +-----------------------------------+
function randomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
session_start();
$user = $_SESSION["user"];
if (empty($user)) {
die("ERROR 02: Permission denied");
}
$url = $_SERVER["HTTP_REFERER"];
$server = $_SERVER["SERVER_NAME"];
$password = $_POST["typePasswordOfShared1"];
$file = str_replace("https://$server/u/$user/share/", "", $url);
$s = randomString(20);
$string = "$user{}file{}$file";
$cloudConf = json_decode(file_get_contents('protected/config/config.json'));
if ($cloudConf->fewShared) {
foreach (glob('protected/shared/*') as $shared) {
$sh = file_get_contents($shared);
$shared = str_replace('protected/shared/', '', $shared);
if ($sh == $string && empty(explode('{}', $sh)[3])) {
require_once('protected/components/header.php');
?>
<br>
<h1>File condiviso - FoxCloud</h1>
Il file non è stato propriamente condiviso, a causa di un'impostazione voluta dall'admin non puoi creare più link di condivisione per un unico file.<br>
Pertanto quello che sta per essere fornito sarà quello già esistente. Ti ricordiamo che puoi sempre eliminare i tuoi shared<br><br>
<b>Codice dello shared:</b> <?= $shared; ?><br>
<b>Link dello shared:</b> <a onclick='copyurl()' title='Clicca per copiare'>https://<?= $_SERVER["SERVER_NAME"]; ?>/s/<?= $shared; ?></a><br><br><br>
<a href="/u/<?= $user; ?>/files/"><button class="foxcloud-button">Torna ai tuoi File</button></a>
<script>
function copyurl() {
navigator.clipboard.writeText('https://<?= $_SERVER["SERVER_NAME"]; ?>/s/<?= $shared; ?>');
}
</script>
<?php
die();
}
}
}
if (!empty($password)) {
// Ok, niente password
file_put_contents("protected/shared/$s", $string . '{}' . $password);
$password = "<span style='color: green'>SI</span>";
} else {
file_put_contents("protected/shared/$s", $string);
$password = "<span style='color: red'>NO</span>";
}
require("protected/components/header.php");
?>
<br>
<h1>File condiviso - Fox Cloud</h1>
<br><br>
<h3 style="color: green">File condiviso con successo!</h3>
<br><br><br>
<b>Codice dello shared:</b> <?= $s; ?><br>
<b>Link dello shared:</b> <a onclick='copyurl()' title='Clicca per copiare'>https://<?= $_SERVER["SERVER_NAME"]; ?>/s/<?= $s; ?></a><br>
<b>Password:</b> <?= $password; ?>
<br><br><br>
<a href="/u/<?= $user; ?>/files/"><button class="foxcloud-button">Torna ai tuoi File</button></a>
<br><br><br>
<script>
function copyurl() {
navigator.clipboard.writeText('https://<?= $_SERVER["SERVER_NAME"]; ?>/s/<?= $s; ?>');
}
</script>