-
Notifications
You must be signed in to change notification settings - Fork 0
/
saveFile.php
49 lines (40 loc) · 1.3 KB
/
saveFile.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
<?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! |
// +-----------------------------------+
session_start();
$ses = $_SESSION["user"];
$u = filter_var($_POST["user"], FILTER_SANITIZE_STRING);
$file = filter_var($_POST["dir"], FILTER_SANITIZE_STRING);
$contents = filter_var($_POST["contenuto"], FILTER_SANITIZE_STRING);
$file = str_replace("%20", " ", $file);
if (empty($u)) {
die("User");
}
if ($u !== $ses) {
header("Location: /u/$ses/dashboard");
die("Permessi insufficenti");
}
if (empty($contents)) {
die("Content");
}
if (empty($file)) {
die("FileDir");
}
$user = json_decode(file_get_contents("protected/users/$u/userinfo.conf"));
$h = fopen('protected/disk/' . $user->dir . '/' . $file, "w+");
fwrite($h, $contents);
fclose($h);
header("Location: /u/$u/fileopen/$file");