summaryrefslogtreecommitdiff
path: root/lib/image
diff options
context:
space:
mode:
authorNicolas BERNSTEIN <alexis211@gmail.com>2012-02-12 19:50:55 +0100
committerNicolas BERNSTEIN <alexis211@gmail.com>2012-02-12 19:50:55 +0100
commit24547ccec6526fcef3cccb34bc35fb81f31236b3 (patch)
treefc908fb06a6b8b4d4131c7303c4fb3b7d348f9bf /lib/image
parentcd76af42463bd80539db8c9671a427a9f0fe5d69 (diff)
downloadBits-24547ccec6526fcef3cccb34bc35fb81f31236b3.tar.gz
Bits-24547ccec6526fcef3cccb34bc35fb81f31236b3.zip
A lot of changes : blogging system essentially.
Diffstat (limited to 'lib/image')
-rw-r--r--lib/image/index.php22
-rw-r--r--lib/image/rename.php32
-rw-r--r--lib/image/upload.php8
3 files changed, 57 insertions, 5 deletions
diff --git a/lib/image/index.php b/lib/image/index.php
index 01c0928..59a304d 100644
--- a/lib/image/index.php
+++ b/lib/image/index.php
@@ -2,16 +2,31 @@
require("lib/conf/image.php");
+$filters = array (
+ "order" => array (
+ "name" => "title",
+ "upl_date" => "date uploaded",
+ ),
+ "way" => $ord_ways,
+);
+$fdefaults = array (
+ "order" => "name",
+ "way" => "ASC",
+);
+
$title = "Image upload";
$images = array();
-$files = sql("SELECT * FROM images WHERE owner = " . $user['id']);
+$files = sql("SELECT * FROM images WHERE owner = " . $user['id'] .
+ " ORDER BY " . get_filter('order') . " " . get_filter('way'));
while ($img = mysql_fetch_assoc($files)) $images[] = $img;
-if (count($images) >= $quota && $user['priv'] < $min_priv_for_no_quota) {
+/*if (count($images) >= $quota && $user['priv'] < $min_priv_for_no_quota) {
$error = "You have already exceeded your quota of $quota uploadable images.";
$can_upload = false;
-} else if ($user['priv'] < $apps['image']['upload']) {
+} else */
+
+if ($user['priv'] < $apps['image']['upload']) {
$error = "You don't have the rights to upload images.";
$can_upload = false;
} else {
@@ -19,5 +34,6 @@ if (count($images) >= $quota && $user['priv'] < $min_priv_for_no_quota) {
}
$can_delete = ($user['priv'] >= $apps['image']['delete'] && $user['id'] != 0);
+$can_rename = ($user['priv'] >= $apps['image']['rename'] && $user['id'] != 0);
require("tpl/image/index.php");
diff --git a/lib/image/rename.php b/lib/image/rename.php
new file mode 100644
index 0000000..0fbc442
--- /dev/null
+++ b/lib/image/rename.php
@@ -0,0 +1,32 @@
+<?php
+
+require("lib/conf/image.php");
+
+$title = "Rename an image";
+
+if (count($args) < 3) header("location: index.php");
+$id = intval($args[2]);
+
+$info = mysql_fetch_assoc(sql("SELECT * FROM images WHERE id = $id"));
+
+assert_error($info["owner"] == $user["id"], "You cannot rename this image.");
+
+$name = $info['name'];
+if (isset($_POST['name'])) {
+ $name = esca($_POST['name']);
+ if ($name == "") {
+ $error = "You must give a non-empty name to this image. Please.";
+ } else {
+ sql("UPDATE images SET name = '" . escs($name) . "' WHERE id = $id");
+ header("Location: image");
+ die();
+ }
+}
+
+$title = "Rename : " . $info['name'];
+$fields = array(
+ array("label" => "New name : ", "name" => "name", "value" => $name),
+);
+$validate = "Rename";
+
+require("tpl/general/form.php");
diff --git a/lib/image/upload.php b/lib/image/upload.php
index 812295f..5176a3a 100644
--- a/lib/image/upload.php
+++ b/lib/image/upload.php
@@ -4,11 +4,15 @@ $title = "Upload an image";
require("lib/conf/image.php");
+/*
$number = mysql_fetch_assoc(sql("SELECT count(*) AS count FROM images WHERE owner = " . $user['id']));
assert_error($number['count'] < $quota || $user['priv'] >= $min_priv_for_no_quota || $user['id'] == 0,
"You have already exceeded your upload quota.");
+*/
-if (isset($_FILES['image'])) {
+if (isset($_FILES['image']) && isset($_POST['name'])) {
+ $name = esca($_POST['name']);
+ if ($name == "") $name = $_FILES['image']['name'];
if ($_FILES['image']['error'] != 0) {
$error = "Sorry, an error occurred while uploading your file. Try with a smaller one.";
require("tpl/image/upload.php");
@@ -24,7 +28,7 @@ if (isset($_FILES['image'])) {
$error = "Sorry, we only accept GIF, PNG and JPEG images.";
require("tpl/image/upload.php");
}
- sql("INSERT INTO images(owner, extension) VALUES(" . $user['id'] . ", '$type')");
+ sql("INSERT INTO images(owner, extension, name, upl_date) VALUES(" . $user['id'] . ", '$type', '" . escs($name) . "', NOW())");
$id = mysql_insert_id();
$filen = $savedir . $id . "." . $type;
$minin = $savedir . $id . "-min." . $type;