summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-06-21 17:12:06 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-06-21 17:12:06 +0200
commit80e0f88b56ca7e306d415604c608d8bc09496e21 (patch)
tree913d120f4e245a7b95bc948d12fa913eed01d840
parent889e8eaf7c40817663dd602a21ac771062ccac3b (diff)
downloadBits-80e0f88b56ca7e306d415604c608d8bc09496e21.tar.gz
Bits-80e0f88b56ca7e306d415604c608d8bc09496e21.zip
Changes. But minor. Mostly usability changes.
-rw-r--r--lib/file/editinfo.php6
-rw-r--r--lib/file/folder.php3
-rw-r--r--lib/file/index.php6
-rw-r--r--lib/file/upload.php3
-rw-r--r--tpl/file/folder.php22
-rw-r--r--tpl/file/index.php10
-rw-r--r--tpl/file/upload-ok.php11
7 files changed, 44 insertions, 17 deletions
diff --git a/lib/file/editinfo.php b/lib/file/editinfo.php
index eea9f35..500a7fc 100644
--- a/lib/file/editinfo.php
+++ b/lib/file/editinfo.php
@@ -30,7 +30,11 @@ if (isset($_POST['name']) && isset($_POST['comment']) && isset($_POST['folder'])
} else {
sql("UPDATE files SET name = '" . escs($name) . "', comment='" . escs($comment). "',
comment_html = '" . escs($comment_html) . "', folder = $folder WHERE id = $id");
- header("Location: file");
+ if ($folder == 0) {
+ header("Location: file");
+ } else {
+ header("Location: folder-file-$folder");
+ }
die();
}
}
diff --git a/lib/file/folder.php b/lib/file/folder.php
index 15e8625..f3beedd 100644
--- a/lib/file/folder.php
+++ b/lib/file/folder.php
@@ -33,7 +33,8 @@ $title = $fld["name"];
$files = array();
$fileq = sql("SELECT files.id AS id, files.name AS name, files.extension AS extension, files.upl_date AS upl_date, ".
- "files.comment_html AS comment_html FROM files WHERE files.folder = $fldid");
+ "files.comment_html AS comment_html FROM files WHERE files.folder = $fldid ".
+ "ORDER BY " . get_filter('order') . " " . get_filter('way'));
while ($img = mysql_fetch_assoc($fileq)) $files[] = $img;
$s = sql("SELECT id, name FROM folders WHERE owner = " . $fld['owner'] . ($fld['owner'] == $user['id'] ? '' : " AND public != 0"). " ORDER BY name ASC");
diff --git a/lib/file/index.php b/lib/file/index.php
index 34686c5..1a60a79 100644
--- a/lib/file/index.php
+++ b/lib/file/index.php
@@ -6,7 +6,7 @@ $filters = array (
"order" => array (
"name" => "title",
"upl_date" => "date uploaded",
- "folder_name" => "folder",
+ //"folder_name" => "folder",
),
"way" => $ord_ways,
);
@@ -15,13 +15,13 @@ $fdefaults = array (
"way" => "DESC",
);
-$title = "Image upload";
+$title = "File upload";
$files = array();
$fileq = sql("SELECT files.id AS id, files.name AS name, files.extension AS extension, files.upl_date AS upl_date, ".
"files.comment_html AS comment_html, folders.id AS folder_id, folders.name AS folder_name ".
" FROM files LEFT JOIN folders ON folders.id = files.folder ".
- "WHERE files.owner = " . $user['id'] .
+ "WHERE files.folder = 0 AND files.owner = " . $user['id'] .
" ORDER BY " . get_filter('order') . " " . get_filter('way'));
while ($img = mysql_fetch_assoc($fileq)) $files[] = $img;
diff --git a/lib/file/upload.php b/lib/file/upload.php
index 4b5299d..21fa065 100644
--- a/lib/file/upload.php
+++ b/lib/file/upload.php
@@ -7,6 +7,7 @@ require("lib/conf/file.php");
if (isset($_FILES['file']) && isset($_POST['name'])) {
$name = esca($_POST['name']);
+ $folder = (isset($_POST['folder']) ? intval($_POST['folder']) : 0);
if ($name == "") $name = $_FILES['file']['name'];
if ($_FILES['file']['error'] != 0) {
$error = "Sorry, an error occurred while uploading your file. Try with a smaller one.";
@@ -15,7 +16,7 @@ if (isset($_FILES['file']) && isset($_POST['name'])) {
$origname = strtolower(basename($_FILES['file']['name']));
$type = preg_replace("#^.+\.([a-z0-9]+)$#", "$1", $origname);
- sql("INSERT INTO files(owner, extension, name, upl_date) VALUES(" . $user['id'] . ", '$type', '" . escs($name) . "', NOW())");
+ sql("INSERT INTO files(owner, folder, extension, name, upl_date) VALUES(" . $user['id'] . ", $folder, '$type', '" . escs($name) . "', NOW())");
$id = mysql_insert_id();
$filen = $savedir . $id . "." . $type;
if (!copy($_FILES['file']['tmp_name'], $filen)) {
diff --git a/tpl/file/folder.php b/tpl/file/folder.php
index d7ebd73..61b4ed3 100644
--- a/tpl/file/folder.php
+++ b/tpl/file/folder.php
@@ -12,7 +12,7 @@ if (count($files) == 0) {
echo '<div class="message">This folder has no files.</div>';
} else {
echo '<div class="ordering_links">' . filters_html_full() . '</div>';
- echo '<table><tr><th width="' . ($img_mini_width) . 'px"></th><th>Info</th><th>Date</th></tr>';
+ echo '<table><tr><th width="' . ($img_mini_width) . 'px"></th><th>Info</th><th width="120px">Date</th></tr>';
foreach ($files as $fl) {
$min = $baseurl . $fl['id'] . "-min." . $fl['extension'];
$flf = $baseurl . $fl['id'] . "." . $fl['extension'];
@@ -24,17 +24,32 @@ if (count($files) == 0) {
}
echo '</a></td>';
echo '<td><strong>' . $fl['name'] . '</strong>';
+ echo '<br /><strong>MD:</strong> <code>' . (has_mini($fl['extension']) ? '!' : '') . '['.$fl['name'].']('.$flf.')</code>';
echo '<br />' . $fl['comment_html'] . '<br />';
echo '</td>';
- echo '<td>' . $fl['upl_date'] . '<br />';
+ echo '<td>' . $fl['upl_date'];
if ($can_edit) echo '<br /><a href="delete-file-' . $fl['id'] . '">delete</a>';
- if ($can_edit) echo '<br /><a href="editinfo-file-' . $fl['id'] . '">edit info</a>';
+ if ($can_edit) echo ' | <a href="editinfo-file-' . $fl['id'] . '">edit</a>';
echo '</td></tr>';
}
echo '</table>';
}
echo '</div><div class="contents-left">';
+
+if ($is_owner) {
+ ?>
+<h1>Upload a file</h1>
+<form method="POST" action="index.php?p=upload-file" enctype="multipart/form-data">
+If you upload an image, a <?php echo $img_mini_width; ?>px preview will be created.<br /><br />
+Title : <input type="text" name="name" style="width: 200px;" ><br />
+<input type="file" name="file" /><br />
+<input type="hidden" name="folder" value="<?php echo $fldid; ?>" />
+<input type="submit" value="Upload" /></form>
+<br /><br />
+ <?php
+}
+
if ($is_owner) {
echo '<h1>Your folders</h1>';
} else {
@@ -49,6 +64,7 @@ foreach ($folders as $f) {
}
}
if ($is_owner) {
+ echo '<li><a class="tool_link" href="file">[files in no folder]</a></li>';
echo '<li><a class="tool_link" href="newfld-file">[+] New folder</a></li>';
}
echo '</ul>';
diff --git a/tpl/file/index.php b/tpl/file/index.php
index dc8cb52..abc340a 100644
--- a/tpl/file/index.php
+++ b/tpl/file/index.php
@@ -2,11 +2,11 @@
require("tpl/general/top.php");
if (count($files) == 0) {
- echo '<div class="message">You have uploaded no files yet.</div>';
+ echo '<p>You have no files that are uploaded and not put in a folder.</p>';
} else {
- echo '<p>You have uploaded ' . count($files) .' files.</p>';
+ echo '<p>You have ' . count($files) .' files uploaded in no folder. Select a folder to view the files it contains.</p>';
echo '<div class="ordering_links">' . filters_html_full() . '</div>';
- echo '<table><tr><th width="' . ($img_mini_width) . 'px"></th><th>Info</th><th>Date</th></tr>';
+ echo '<table><tr><th width="' . ($img_mini_width) . 'px"></th><th>Info</th><th width="120px">Date</th></tr>';
foreach ($files as $fl) {
$min = $baseurl . $fl['id'] . "-min." . $fl['extension'];
$flf = $baseurl . $fl['id'] . "." . $fl['extension'];
@@ -26,9 +26,9 @@ if (count($files) == 0) {
/*echo '<strong>Miniature:</strong> <a href="' . $min . '">' . $min . '</a><br />';
echo '<strong>Image:</strong> <a href="' . $flf . '">' . $flf . '</a><br />'; */
echo '</td>';
- echo '<td>' . $fl['upl_date'] . '<br />';
+ echo '<td>' . $fl['upl_date'] . '';
if ($can_delete) echo '<br /><a href="delete-file-' . $fl['id'] . '">delete</a>';
- if ($can_rename) echo '<br /><a href="editinfo-file-' . $fl['id'] . '">edit info</a>';
+ if ($can_rename) echo ' | <a href="editinfo-file-' . $fl['id'] . '">edit</a>';
echo '</td></tr>';
}
echo '</table>';
diff --git a/tpl/file/upload-ok.php b/tpl/file/upload-ok.php
index a0edee1..1d6559f 100644
--- a/tpl/file/upload-ok.php
+++ b/tpl/file/upload-ok.php
@@ -10,10 +10,15 @@ $imgurl = $baseurl . $id . "." . $type;
Markdown code : <code><?php echo (has_mini($type) ? '!' : '') . '[' . $name; ?>](<?php echo $imgurl; ?>)</code></p>
<p>
<p>
- <a href="upload-file">Back to upload form</a>
+ <a href="upload-file">back to upload form</a>
<?php
- if ($user['priv'] >= $apps['file']['index'])
- echo ' - <a href="index-file">back to list of uploaded files</a>';
+ if ($user['priv'] >= $apps['file']['index']) {
+ echo ' | <a href="index-file">back to list of uploaded files</a>';
+ if ($folder != 0) {
+ echo ' | <a href="folder-file-' . $folder . '">go to folder</a>';
+ }
+ echo ' | <a href="editinfo-file-' . $id . '">edit file info</a>';
+ }
?>
</p>
<?php