From 889e8eaf7c40817663dd602a21ac771062ccac3b Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Thu, 21 Jun 2012 16:34:27 +0200 Subject: Big change, sir. Can now upload any kind of files. --- .gitignore | 2 +- design/style.css | 3 +++ lib/conf/apps.php | 2 +- lib/conf/file.php | 13 ++++++++++ lib/conf/image.php | 7 ------ lib/file/delete.php | 21 +++++++++++++++++ lib/file/delfld.php | 16 +++++++++++++ lib/file/editfld.php | 44 ++++++++++++++++++++++++++++++++++ lib/file/editinfo.php | 51 +++++++++++++++++++++++++++++++++++++++ lib/file/folder.php | 43 +++++++++++++++++++++++++++++++++ lib/file/index.php | 44 ++++++++++++++++++++++++++++++++++ lib/file/newfld.php | 32 +++++++++++++++++++++++++ lib/file/upload.php | 54 ++++++++++++++++++++++++++++++++++++++++++ lib/image/delete.php | 21 ----------------- lib/image/delfld.php | 16 ------------- lib/image/editfld.php | 44 ---------------------------------- lib/image/editinfo.php | 51 --------------------------------------- lib/image/folder.php | 43 --------------------------------- lib/image/index.php | 49 -------------------------------------- lib/image/newfld.php | 32 ------------------------- lib/image/upload.php | 63 ------------------------------------------------- schema.sql | 46 ++++++++++++++++++------------------ tpl/file/folder.php | 56 +++++++++++++++++++++++++++++++++++++++++++ tpl/file/index.php | 61 +++++++++++++++++++++++++++++++++++++++++++++++ tpl/file/upload-ok.php | 21 +++++++++++++++++ tpl/file/upload.php | 16 +++++++++++++ tpl/general/top.php | 6 ++--- tpl/image/folder.php | 52 ---------------------------------------- tpl/image/index.php | 55 ------------------------------------------ tpl/image/upload-ok.php | 21 ----------------- tpl/image/upload.php | 16 ------------- 31 files changed, 503 insertions(+), 498 deletions(-) create mode 100644 lib/conf/file.php delete mode 100644 lib/conf/image.php create mode 100644 lib/file/delete.php create mode 100644 lib/file/delfld.php create mode 100644 lib/file/editfld.php create mode 100644 lib/file/editinfo.php create mode 100644 lib/file/folder.php create mode 100644 lib/file/index.php create mode 100644 lib/file/newfld.php create mode 100644 lib/file/upload.php delete mode 100644 lib/image/delete.php delete mode 100644 lib/image/delfld.php delete mode 100644 lib/image/editfld.php delete mode 100644 lib/image/editinfo.php delete mode 100644 lib/image/folder.php delete mode 100644 lib/image/index.php delete mode 100644 lib/image/newfld.php delete mode 100644 lib/image/upload.php create mode 100644 tpl/file/folder.php create mode 100644 tpl/file/index.php create mode 100644 tpl/file/upload-ok.php create mode 100644 tpl/file/upload.php delete mode 100644 tpl/image/folder.php delete mode 100644 tpl/image/index.php delete mode 100644 tpl/image/upload-ok.php delete mode 100644 tpl/image/upload.php diff --git a/.gitignore b/.gitignore index 9b7ca5e..e775888 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ lib/conf/sql.php *.swp nohup.out _old -images/* +files/* diff --git a/design/style.css b/design/style.css index 2a537f6..613fed7 100644 --- a/design/style.css +++ b/design/style.css @@ -182,6 +182,9 @@ iframe, textarea { .small_right, .tool_link { font-size: 0.8em; +} + +.small_right a, .tool_link { font-style: italic; } diff --git a/lib/conf/apps.php b/lib/conf/apps.php index 8afeb2d..8e755b1 100644 --- a/lib/conf/apps.php +++ b/lib/conf/apps.php @@ -5,7 +5,7 @@ $homepage = "blog"; $apps = array( // Image upload application - "image" => array( + "file" => array( "index" => 1, "delete" => 1, "editinfo" => 1, diff --git a/lib/conf/file.php b/lib/conf/file.php new file mode 100644 index 0000000..4a8830e --- /dev/null +++ b/lib/conf/file.php @@ -0,0 +1,13 @@ += 3, 'file'); +$fldid = intval($args[2]); + +$fld = mysql_fetch_assoc(sql( + "SELECT id, name, comment, public, owner ". + "FROM folders WHERE id = $fldid" + )); +assert_error($fld && $fld['owner'] == $user['id'], + "This folder does not exist, or you are not allowed to edit it."); + +token_validate("Do you really want to delete this folder ?", "folder-file-$fldid"); +sql("DELETE FROM folders WHERE id = $fldid"); +sql("UPDATE files SET folder = 0 WHERE folder = $fldid"); +header("location: file"); diff --git a/lib/file/editfld.php b/lib/file/editfld.php new file mode 100644 index 0000000..db5a304 --- /dev/null +++ b/lib/file/editfld.php @@ -0,0 +1,44 @@ + "Folder name : ", "name" => "name", "value" => $fld_name), + array("label" => "Public ? ", "name" => "public", "type" => "checkbox", "checked" => $fld_public), + array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $fld_comment), + ); +$validate = "Save"; + +require("tpl/general/form.php"); + 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 @@ + "[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"); diff --git a/lib/file/folder.php b/lib/file/folder.php new file mode 100644 index 0000000..15e8625 --- /dev/null +++ b/lib/file/folder.php @@ -0,0 +1,43 @@ += $apps['file']['editfld'] && $user['id'] == $fld['owner']); +$is_owner = ($user['id'] == $fld['owner']); + +$filters = array ( + "order" => array ( + "name" => "title", + "upl_date" => "date uploaded", + ), + "way" => $ord_ways, +); +$fdefaults = array ( + "order" => "name", + "way" => "ASC", +); + +$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"); +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"); +$folers = array(); +while ($f = mysql_fetch_assoc($s)) $folders[] = $f; + +require("tpl/file/folder.php"); diff --git a/lib/file/index.php b/lib/file/index.php new file mode 100644 index 0000000..34686c5 --- /dev/null +++ b/lib/file/index.php @@ -0,0 +1,44 @@ + array ( + "name" => "title", + "upl_date" => "date uploaded", + "folder_name" => "folder", + ), + "way" => $ord_ways, +); +$fdefaults = array ( + "order" => "upl_date", + "way" => "DESC", +); + +$title = "Image 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'] . + " ORDER BY " . get_filter('order') . " " . get_filter('way')); +while ($img = mysql_fetch_assoc($fileq)) $files[] = $img; + +if ($user['priv'] < $apps['file']['upload']) { + $error = "You don't have the rights to upload files."; + $can_upload = false; +} else { + $can_upload = true; +} + +$folders = array(); +$r = sql("SELECT id, name FROM folders WHERE owner = " . $user['id'] . " ORDER BY name ASC"); +while ($f = mysql_fetch_assoc($r)) { + $folders[] = $f; +} + +$can_delete = ($user['priv'] >= $apps['file']['delete'] && $user['id'] != 0); +$can_rename = ($user['priv'] >= $apps['file']['editinfo'] && $user['id'] != 0); + +require("tpl/file/index.php"); diff --git a/lib/file/newfld.php b/lib/file/newfld.php new file mode 100644 index 0000000..6b5ba1f --- /dev/null +++ b/lib/file/newfld.php @@ -0,0 +1,32 @@ + "Name : ", "name" => "name", "value" => $fld_name), + array("label" => "Public ? ", "name" => "public", "type" => "checkbox", "checked" => $fld_public), + array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $fld_comment), + ); +$validate = "Create folder"; + +require("tpl/general/form.php"); diff --git a/lib/file/upload.php b/lib/file/upload.php new file mode 100644 index 0000000..4b5299d --- /dev/null +++ b/lib/file/upload.php @@ -0,0 +1,54 @@ += 3, 'image'); -$fldid = intval($args[2]); - -$fld = mysql_fetch_assoc(sql( - "SELECT id, name, comment, public, owner ". - "FROM img_folders WHERE id = $fldid" - )); -assert_error($fld && $fld['owner'] == $user['id'], - "This folder does not exist, or you are not allowed to edit it."); - -token_validate("Do you really want to delete this folder ?", "folder-image-$fldid"); -sql("DELETE FROM img_folders WHERE id = $fldid"); -sql("UPDATE images SET folder = 0 WHERE folder = $fldid"); -header("location: image"); diff --git a/lib/image/editfld.php b/lib/image/editfld.php deleted file mode 100644 index a0bef1f..0000000 --- a/lib/image/editfld.php +++ /dev/null @@ -1,44 +0,0 @@ - "Name : ", "name" => "name", "value" => $fld_name), - array("label" => "Public ? ", "name" => "public", "type" => "checkbox", "checked" => $fld_public), - array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $fld_comment), - ); -$validate = "Save"; - -require("tpl/general/form.php"); - diff --git a/lib/image/editinfo.php b/lib/image/editinfo.php deleted file mode 100644 index 8223c18..0000000 --- a/lib/image/editinfo.php +++ /dev/null @@ -1,51 +0,0 @@ - "[no folder]"); -$r = sql("SELECT id, name FROM img_folders WHERE owner = " . $user['id'] . " ORDER BY name ASC"); -while ($n = mysql_fetch_array($r)) - $folders[$n['id']] = $n['name']; - -$title = "Edit image info : " . $info['name']; -$fields = array( - array("label" => "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"); diff --git a/lib/image/folder.php b/lib/image/folder.php deleted file mode 100644 index 574531c..0000000 --- a/lib/image/folder.php +++ /dev/null @@ -1,43 +0,0 @@ -= $apps['image']['editfld'] && $user['id'] == $fld['owner']); -$is_owner = ($user['id'] == $fld['owner']); - -$filters = array ( - "order" => array ( - "name" => "title", - "upl_date" => "date uploaded", - ), - "way" => $ord_ways, -); -$fdefaults = array ( - "order" => "name", - "way" => "ASC", -); - -$title = $fld["name"]; - -$images = array(); -$files = sql("SELECT images.id AS id, images.name AS name, images.extension AS extension, images.upl_date AS upl_date, ". - "images.comment_html AS comment_html FROM images WHERE images.folder = $fldid"); -while ($img = mysql_fetch_assoc($files)) $images[] = $img; - -$s = sql("SELECT id, name FROM img_folders WHERE owner = " . $fld['owner'] . ($fld['owner'] == $user['id'] ? '' : " AND public != 0"). " ORDER BY name ASC"); -$folers = array(); -while ($f = mysql_fetch_assoc($s)) $folders[] = $f; - -require("tpl/image/folder.php"); diff --git a/lib/image/index.php b/lib/image/index.php deleted file mode 100644 index b9748dc..0000000 --- a/lib/image/index.php +++ /dev/null @@ -1,49 +0,0 @@ - array ( - "name" => "title", - "upl_date" => "date uploaded", - "folder_name" => "folder", - ), - "way" => $ord_ways, -); -$fdefaults = array ( - "order" => "name", - "way" => "ASC", -); - -$title = "Image upload"; - -$images = array(); -$files = sql("SELECT images.id AS id, images.name AS name, images.extension AS extension, images.upl_date AS upl_date, ". - "images.comment_html AS comment_html, img_folders.id AS folder_id, img_folders.name AS folder_name ". - " FROM images LEFT JOIN img_folders ON img_folders.id = images.folder ". - "WHERE images.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) { - $error = "You have already exceeded your quota of $quota uploadable images."; - $can_upload = false; -} else */ - -if ($user['priv'] < $apps['image']['upload']) { - $error = "You don't have the rights to upload images."; - $can_upload = false; -} else { - $can_upload = true; -} - -$folders = array(); -$r = sql("SELECT id, name FROM img_folders WHERE owner = " . $user['id'] . " ORDER BY name ASC"); -while ($f = mysql_fetch_assoc($r)) { - $folders[] = $f; -} - -$can_delete = ($user['priv'] >= $apps['image']['delete'] && $user['id'] != 0); -$can_rename = ($user['priv'] >= $apps['image']['editinfo'] && $user['id'] != 0); - -require("tpl/image/index.php"); diff --git a/lib/image/newfld.php b/lib/image/newfld.php deleted file mode 100644 index 63afd17..0000000 --- a/lib/image/newfld.php +++ /dev/null @@ -1,32 +0,0 @@ - "Name : ", "name" => "name", "value" => $fld_name), - array("label" => "Public ? ", "name" => "public", "type" => "checkbox", "checked" => $fld_public), - array("label" => "Comment : ", "name" => "comment", "type" => "textarea", "value" => $fld_comment), - ); -$validate = "Create folder"; - -require("tpl/general/form.php"); diff --git a/lib/image/upload.php b/lib/image/upload.php deleted file mode 100644 index 5176a3a..0000000 --- a/lib/image/upload.php +++ /dev/null @@ -1,63 +0,0 @@ -= $min_priv_for_no_quota || $user['id'] == 0, - "You have already exceeded your upload quota."); -*/ - -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"); - } - $origname = strtolower(basename($_FILES['image']['name'])); - if (preg_match("#\.png$#",$origname)) { - $type = "png"; - } elseif (preg_match("#\.gif$#",$origname)) { - $type = "gif"; - } elseif (preg_match("#\.jpg$#",$origname) or preg_match("#\.jpeg$#",$origname)) { - $type = "jpg"; - } else { - $error = "Sorry, we only accept GIF, PNG and JPEG images."; - require("tpl/image/upload.php"); - } - 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; - if (!copy($_FILES['image']['tmp_name'], $filen)) { - $error = "An internal error occurred. You might want to try again later."; - sql("DELETE FROM images WHERE id = $id"); - require("tpl/image/upload.php"); - } - - if ($type == "png") - $source = imagecreatefrompng($filen); - elseif ($type == "jpg") - $source = imagecreatefromjpeg($filen); - elseif ($type == "gif") - $source = imagecreatefromgif($filen); - $l = imagesx($source); - $h = imagesy($source); - $l2 = $miniature_width; - $h2 = $l2 * $h / $l; - $mini = imagecreatetruecolor($l2, $h2); - imagecopyresampled($mini, $source, 0, 0, 0, 0, $l2, $h2, $l, $h); - if ($type == "png") - imagepng($mini, $minin); - elseif ($type == "jpg") - imagejpeg($mini, $minin); - elseif ($type == "gif") - imagegif($mini, $minin); - $message = "Your image has been uploaded successfully."; - require("tpl/image/upload-ok.php"); -} else { - require("tpl/image/upload.php"); -} diff --git a/schema.sql b/schema.sql index 1c858f2..86bbfe6 100644 --- a/schema.sql +++ b/schema.sql @@ -1,11 +1,11 @@ -- phpMyAdmin SQL Dump --- version 3.5.0 +-- version 3.5.1 -- http://www.phpmyadmin.net -- -- Client: localhost --- Généré le: Ven 13 Avril 2012 à 19:07 --- Version du serveur: 5.5.22-log --- Version de PHP: 5.3.10 +-- Généré le: Jeu 21 Juin 2012 à 14:33 +-- Version du serveur: 5.5.25-log +-- Version de PHP: 5.4.4 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; @@ -35,7 +35,7 @@ CREATE TABLE IF NOT EXISTS `account` ( `reg_date` date NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `login` (`login`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -53,7 +53,7 @@ CREATE TABLE IF NOT EXISTS `batches` ( PRIMARY KEY (`id`), UNIQUE KEY `unique_name` (`list`,`name`), KEY `list` (`list`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -71,7 +71,7 @@ CREATE TABLE IF NOT EXISTS `batch_review` ( PRIMARY KEY (`id`), KEY `batch` (`batch`), KEY `user_idx` (`user`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -87,7 +87,7 @@ CREATE TABLE IF NOT EXISTS `batch_study` ( PRIMARY KEY (`id`), UNIQUE KEY `batch` (`batch`), KEY `user_idx` (`user`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS `blog_comments` ( PRIMARY KEY (`id`), KEY `post` (`post`), KEY `owner` (`owner`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -124,7 +124,7 @@ CREATE TABLE IF NOT EXISTS `blog_posts` ( PRIMARY KEY (`id`), KEY `poster` (`owner`), KEY `draft` (`draft`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -155,7 +155,7 @@ CREATE TABLE IF NOT EXISTS `cards` ( UNIQUE KEY `unique_name` (`deck`,`name`), UNIQUE KEY `unique_number` (`deck`,`number`), KEY `deck_idx` (`deck`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -171,7 +171,7 @@ CREATE TABLE IF NOT EXISTS `card_study` ( `next_review` date NOT NULL, PRIMARY KEY (`id`), KEY `deck_study` (`deck_study`,`card`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -188,7 +188,7 @@ CREATE TABLE IF NOT EXISTS `decks` ( PRIMARY KEY (`id`), UNIQUE KEY `unique_name` (`owner`,`name`), KEY `owner_idx` (`owner`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -207,15 +207,15 @@ CREATE TABLE IF NOT EXISTS `deck_study` ( UNIQUE KEY `unique_user_deck` (`user`,`deck`), KEY `user_idx` (`user`), KEY `deck_idx` (`deck`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- --- Structure de la table `images` +-- Structure de la table `files` -- -CREATE TABLE IF NOT EXISTS `images` ( +CREATE TABLE IF NOT EXISTS `files` ( `id` int(11) NOT NULL AUTO_INCREMENT, `owner` int(11) NOT NULL, `extension` varchar(5) NOT NULL, @@ -227,15 +227,15 @@ CREATE TABLE IF NOT EXISTS `images` ( PRIMARY KEY (`id`), KEY `owner` (`owner`), KEY `folder` (`folder`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- --- Structure de la table `img_folders` +-- Structure de la table `folders` -- -CREATE TABLE IF NOT EXISTS `img_folders` ( +CREATE TABLE IF NOT EXISTS `folders` ( `id` int(11) NOT NULL AUTO_INCREMENT, `owner` int(11) NOT NULL, `name` varchar(255) NOT NULL, @@ -244,7 +244,7 @@ CREATE TABLE IF NOT EXISTS `img_folders` ( `public` tinyint(1) NOT NULL, PRIMARY KEY (`id`), KEY `owner` (`owner`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -261,7 +261,7 @@ CREATE TABLE IF NOT EXISTS `lists` ( PRIMARY KEY (`id`), UNIQUE KEY `unique_name` (`owner`,`name`), KEY `owner` (`owner`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -277,7 +277,7 @@ CREATE TABLE IF NOT EXISTS `list_study` ( UNIQUE KEY `unique_user_list` (`user`,`list`), KEY `user` (`user`), KEY `list_idx` (`list`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -295,7 +295,7 @@ CREATE TABLE IF NOT EXISTS `notes` ( `public` tinyint(1) NOT NULL, PRIMARY KEY (`id`), KEY `owner` (`owner`,`parent`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=35 ; +) ENGINE=MyISAM DEFAULT CHARSET=utf8; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; diff --git a/tpl/file/folder.php b/tpl/file/folder.php new file mode 100644 index 0000000..d7ebd73 --- /dev/null +++ b/tpl/file/folder.php @@ -0,0 +1,56 @@ +edit folder info | '; + echo 'delete folder'; +} + +echo $fld['comment_html']; + +if (count($files) == 0) { + echo '
This folder has no files.
'; +} else { + echo ''; + echo ''; + foreach ($files as $fl) { + $min = $baseurl . $fl['id'] . "-min." . $fl['extension']; + $flf = $baseurl . $fl['id'] . "." . $fl['extension']; + echo ''; + echo ''; + echo ''; + } + echo '
InfoDate
'; + if (has_mini($fl['extension'])) { + echo ''; + } else { + echo 'download'; + } + echo '' . $fl['name'] . ''; + echo '
' . $fl['comment_html'] . '
'; + echo '
' . $fl['upl_date'] . '
'; + if ($can_edit) echo '
delete'; + if ($can_edit) echo '
edit info'; + echo '
'; +} + +echo '
'; +if ($is_owner) { + echo '

Your folders

'; +} else { + echo '

' . $fld["ownername"] . "'s folders

"; +} +echo ''; + +require("tpl/general/bottom.php"); diff --git a/tpl/file/index.php b/tpl/file/index.php new file mode 100644 index 0000000..dc8cb52 --- /dev/null +++ b/tpl/file/index.php @@ -0,0 +1,61 @@ +You have uploaded no files yet.
'; +} else { + echo '

You have uploaded ' . count($files) .' files.

'; + echo ''; + echo ''; + foreach ($files as $fl) { + $min = $baseurl . $fl['id'] . "-min." . $fl['extension']; + $flf = $baseurl . $fl['id'] . "." . $fl['extension']; + echo ''; + echo ''; + echo ''; + } + echo '
InfoDate
'; + if (has_mini($fl['extension'])) { + echo ''; + } else { + echo 'download'; + } + echo '' . $fl['name'] . ''; + if ($fl['folder_id'] != 0) { + echo ' (in folder: ' . $fl['folder_name'] . ')'; + } + echo '
MD: ' . (has_mini($fl['extension']) ? '!' : '') . '['.$fl['name'].']('.$flf.')'; + echo '
' . $fl['comment_html'] . '
'; + /*echo 'Miniature: ' . $min . '
'; + echo 'Image: ' . $flf . '
'; */ + echo '
' . $fl['upl_date'] . '
'; + if ($can_delete) echo '
delete'; + if ($can_rename) echo '
edit info'; + echo '
'; +} + +if ($can_upload) { +?> + +
+

Upload a file

+
+If you upload an image, a px preview will be created.

+Title :
+
+
+ +

+

Your folders

+ + +

Preview :
+ Image :
+ Markdown code : ]()

+

+

+ Back to upload form + = $apps['file']['index']) + echo ' - back to list of uploaded files'; + ?> +

+ "Image file : ", "type" => "file", "name" => "file"), + array("label" => "Image title (optionnal) : ", "type" => "text", "name" => "name") + ); +$validate = "Upload"; + +require("tpl/general/form.php"); + + diff --git a/tpl/general/top.php b/tpl/general/top.php index 08481fd..e2b168a 100644 --- a/tpl/general/top.php +++ b/tpl/general/top.php @@ -34,11 +34,11 @@ if ($user['id'] == 0) { My studies'; - echo 'Uploaded images'; + echo 'Uploaded files'; } else { echo 'Studies'; - if ($user['priv'] >= $apps['image']['upload']) { - echo 'Upload image'; + if ($user['priv'] >= $apps['file']['upload']) { + echo 'Upload file'; } } ?> diff --git a/tpl/image/folder.php b/tpl/image/folder.php deleted file mode 100644 index 5d5e57b..0000000 --- a/tpl/image/folder.php +++ /dev/null @@ -1,52 +0,0 @@ -edit folder info | '; - echo 'delete folder
'; -} - -echo $fld['comment_html']; - -if (count($images) == 0) { - echo '
This folder has no images.
'; -} else { - echo ''; - echo ''; - foreach ($images as $img) { - $min = $baseurl . $img['id'] . "-min." . $img['extension']; - $imgf = $baseurl . $img['id'] . "." . $img['extension']; - echo ''; - echo ''; - echo ''; - } - echo '
PreviewInfoDate
' . $img['name'] . ''; - echo '
' . $img['comment_html'] . '
'; - /*echo 'Miniature: ' . $min . '
'; - echo 'Image: ' . $imgf . '
'; */ - echo '
' . $img['upl_date'] . '
'; - if ($can_edit) echo '
delete'; - if ($can_edit) echo '
edit info'; - echo '
'; -} - -echo '
'; -if ($is_owner) { - echo '

Your folders

'; -} else { - echo '

' . $fld["ownername"] . "'s folders

"; -} -echo ''; - -require("tpl/general/bottom.php"); diff --git a/tpl/image/index.php b/tpl/image/index.php deleted file mode 100644 index a89d024..0000000 --- a/tpl/image/index.php +++ /dev/null @@ -1,55 +0,0 @@ -You have uploaded no images yet.
'; -} else { - echo '

You have uploaded ' . count($images) .' images.

'; - echo ''; - echo ''; - foreach ($images as $img) { - $min = $baseurl . $img['id'] . "-min." . $img['extension']; - $imgf = $baseurl . $img['id'] . "." . $img['extension']; - echo ''; - echo ''; - echo ''; - } - echo '
PreviewInfoDate
' . $img['name'] . ''; - if ($img['folder_id'] != 0) { - echo ' (in folder: ' . $img['folder_name'] . ')'; - } - echo '
MD: !['.$img['name'].']('.$imgf.')'; - echo '
' . $img['comment_html'] . '
'; - /*echo 'Miniature: ' . $min . '
'; - echo 'Image: ' . $imgf . '
'; */ - echo '
' . $img['upl_date'] . '
'; - if ($can_delete) echo '
delete'; - if ($can_rename) echo '
edit info'; - echo '
'; -} - -if ($can_upload) { -?> - -
-

Upload an image

-
-A px preview will be created.

-Title :
-
-
- -

-

Your folders

- - -

Preview :
- Image :
- Markdown code : ![]()

-

-

- Back to upload form - = $apps['image']['index']) - echo ' - back to list of uploaded images'; - ?> -

- "Image file : ", "type" => "file", "name" => "image"), - array("label" => "Image title (optionnal) : ", "type" => "text", "name" => "name") - ); -$validate = "Upload"; - -require("tpl/general/form.php"); - - -- cgit v1.2.3