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
|
<?php
require("lib/markdown.php");
require("lib/conf/file.php");
$title = "Rename a file";
if (count($args) < 3) header("location: index.php");
$id = intval($args[2]);
$info = mysql_fetch_assoc(sql(
"SELECT files.owner AS owner, files.id AS id, files.name AS name, files.comment AS comment,
folders.id AS folder_id, folders.name AS folder_name
FROM files LEFT JOIN folders ON files.folder = folders.id WHERE files.id = $id"
));
assert_error($info["owner"] == $user["id"], "You cannot rename this file.");
$name = $info['name'];
$comment = $info['comment'];
$folder = $info['folder_id'];
if (isset($_POST['name']) && isset($_POST['comment']) && isset($_POST['folder'])) {
$name = esca($_POST['name']);
$comment = esca($_POST['comment']);
$comment_html = Markdown($comment);
$folder = intval($_POST['folder']);
if ($name == "") {
$error = "You must give a non-empty name to this file. Please.";
} else {
sql("UPDATE files SET name = '" . escs($name) . "', comment='" . escs($comment). "',
comment_html = '" . escs($comment_html) . "', folder = $folder WHERE id = $id");
header("Location: file");
die();
}
}
$folders = array(0 => "[no folder]");
$r = sql("SELECT id, name FROM folders WHERE owner = " . $user['id'] . " ORDER BY name ASC");
while ($n = mysql_fetch_array($r))
$folders[$n['id']] = $n['name'];
$title = "Edit file info : " . $info['name'];
$fields = array(
array("label" => "File name : ", "name" => "name", "value" => $name),
array("label" => "Folder : ", "type" => "select", "name" => "folder", "choices" => $folders, "value" => $folder),
array("label" => "Comment : ", "name" => "comment", "value" => $comment, "type" => "textarea"),
);
$validate = "Save";
require("tpl/general/form.php");
|