diff options
author | Alex AUVOLAT <alexis211@gmail.com> | 2012-06-21 16:34:27 +0200 |
---|---|---|
committer | Alex AUVOLAT <alexis211@gmail.com> | 2012-06-21 16:34:27 +0200 |
commit | 889e8eaf7c40817663dd602a21ac771062ccac3b (patch) | |
tree | ca8ac81ee202165333e5ffe16147d09e5cdaf2ab /lib/file/editinfo.php | |
parent | 5c4caed8560d5fded00525844dfa8386b97e7918 (diff) | |
download | Bits-889e8eaf7c40817663dd602a21ac771062ccac3b.tar.gz Bits-889e8eaf7c40817663dd602a21ac771062ccac3b.zip |
Big change, sir. Can now upload any kind of files.
Diffstat (limited to 'lib/file/editinfo.php')
-rw-r--r-- | lib/file/editinfo.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/file/editinfo.php b/lib/file/editinfo.php new file mode 100644 index 0000000..eea9f35 --- /dev/null +++ b/lib/file/editinfo.php @@ -0,0 +1,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"); |