This commit has been accessed 759 times via Git panel.
commit 35ba66b74bba3f0328e415893cde1fa57752288c
tree 796d8a3eb6b6645c84bd645184ce0bb3194ec00a
parent d5cce8ec187820c5ae1803e7cfdc987e6d33664f
author Engels Antonio <engels@majcms.org> 1369957533 +0800
committer Engels Antonio <engels@majcms.org> 1369957533 +0800
Add filedrop display toggle and files sorting
diff --git a/edit.php b/edit.php
index 9017a82..9978d57 100644
--- a/edit.php
+++ b/edit.php
@@ -326,195 +326,238 @@
?>"></td></tr>
<?php
- }
+}
- if ($maj_logged_in_username == $maj_admin_username) {
+if ($maj_logged_in_username == $maj_admin_username) {
?>
<tr><td><input class="input" style="width: 300px;" autocomplete="off" type="password" name="passwd" <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
- echo "value=\"password\"";
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
+ echo "value=\"password\"";
+ }
?>
> <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
- echo "Enter new password or clear field to disable password protection.";
- } else {
- echo "Enter optional entry access password.";
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
+ echo "Enter new password or clear field to disable password protection.";
+ } else {
+ echo "Enter optional entry access password.";
+ }
?></td></tr>
<tr><td><input class="input" style="width: 300px;" autocomplete="off" type="text" name="maxlines" <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
- echo "value=\"";
- readfile("$maj_data_directory/items/$maj_req_entry/maxlines.txt");
- echo "\"";
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
+ echo "value=\"";
+ readfile("$maj_data_directory/items/$maj_req_entry/maxlines.txt");
+ echo "\"";
+ }
?>
> <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
- echo "Enter new maximum lines for initial display or clear field to disable.";
- } else {
- echo "Enter optional maximum lines for initial display.";
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
+ echo "Enter new maximum lines for initial display or clear field to disable.";
+ } else {
+ echo "Enter optional maximum lines for initial display.";
+ }
?></td></tr>
<tr><td><input type="checkbox" name="sticky" <?php
- $sticky_sem = 'data/sticky/' . $maj_req_entry;
- if (file_exists($sticky_sem)) {
- echo checked;
- }
+ $sticky_sem = 'data/sticky/' . $maj_req_entry;
+ if (file_exists($sticky_sem)) {
+ echo checked;
+ }
?>>Put entry title in Quick Links box.</td></tr>
<tr><td><input type="checkbox" name="display" <?php
- $display_sem = "$maj_data_directory/items/$maj_req_entry/cat.txt";
- if (file_exists($display_sem)) {
- echo checked;
- }
+ $display_sem = "$maj_data_directory/items/$maj_req_entry/cat.txt";
+ if (file_exists($display_sem)) {
+ echo checked;
+ }
?>>Always display. If this is not a private entry, it will be displayed even if its category is hidden or isolated.</td></tr>
<tr><td><input type="checkbox" name="private" <?php
- $private_sem = "$maj_data_directory/items/$maj_req_entry/private.txt";
- if (file_exists($private_sem)) {
- echo checked;
- }
+ $private_sem = "$maj_data_directory/items/$maj_req_entry/private.txt";
+ if (file_exists($private_sem)) {
+ echo checked;
+ }
?>>Private entry. This entry will unconditionally be invisible to visitors<?php
- if (file_exists("$maj_data_directory/ml.txt")) {
- echo " and to the mailing list";
- }
+ if (file_exists("$maj_data_directory/ml.txt")) {
+ echo " and to the mailing list";
+ }
?>, even if always display is set.</td></tr>
- <?php
- if (file_exists("$maj_data_directory/bb.txt")) {
+<?php
+ if (file_exists("$maj_data_directory/bb.txt")) {
?>
<tr><td><input type="checkbox" name="member" <?php
- $member_sem = "$maj_data_directory/items/$maj_req_entry/member.txt";
- if (file_exists($member_sem)) {
- echo checked;
- }
+ $member_sem = "$maj_data_directory/items/$maj_req_entry/member.txt";
+ if (file_exists($member_sem)) {
+ echo checked;
+ }
?>>Only registered members can view this entry.</td></tr>
- <?php
- }
+<?php
+ }
?>
- <?php
- if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directory/wiki.txt")) {
+<?php
+ if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directory/wiki.txt")) {
?>
<tr><td><input type="checkbox" name="edit" <?php
- $edit_sem = "$maj_data_directory/items/$maj_req_entry/edit.txt";
- if (file_exists($edit_sem)) {
- echo checked;
- }
+ $edit_sem = "$maj_data_directory/items/$maj_req_entry/edit.txt";
+ if (file_exists($edit_sem)) {
+ echo checked;
+ }
?>>Registered members can edit this entry.</td></tr>
<tr><td><input type="checkbox" name="lock" <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/lock.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/lock.txt")) {
+ echo checked;
+ }
?>>Only the administrator can edit this entry. </td></tr>
- <?php
- }
- }
+<?php
+ }
+}
- if (($maj_logged_in_username == $maj_admin_username) or file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-adm.txt")) {
+if (($maj_logged_in_username == $maj_admin_username) or file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-adm.txt")) {
?>
<tr><td><input type="checkbox" name="xtitle" <?php
- $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xtitle.txt";
- if (file_exists($lastmod_sem)) {
- echo checked;
- }
+ $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xtitle.txt";
+ if (file_exists($lastmod_sem)) {
+ echo checked;
+ }
?>>Do not display the entry title.</td></tr>
<tr><td><input type="checkbox" name="xdate" <?php
- $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xdate.txt";
- if (file_exists($lastmod_sem)) {
- echo checked;
- }
+ $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xdate.txt";
+ if (file_exists($lastmod_sem)) {
+ echo checked;
+ }
?>>Do not display the entry date.</td></tr>
<?php
-if (!file_exists("$maj_data_directory/avatar.txt")) {
+ if (!file_exists("$maj_data_directory/avatar.txt")) {
- echo "<tr><td><input type=\"checkbox\" name=\"xauthor\"";
+ echo "<tr><td><input type=\"checkbox\" name=\"xauthor\"";
- if (file_exists("$maj_data_directory/items/$maj_req_entry/xauthor.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/xauthor.txt")) {
+ echo checked;
+ }
- echo ">Do not display the entry author.</td></tr>";
-}
-else {
- echo "<tr><td><input type=\"checkbox\" name=\"xavatar\"";
+ echo ">Do not display the entry author.</td></tr>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"xavatar\"";
- if (file_exists("$maj_data_directory/items/$maj_req_entry/xavatar.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/xavatar.txt")) {
+ echo checked;
+ }
- echo ">Do not display the entry avatar.</td></tr>";
-}
+ echo ">Do not display the entry avatar.</td></tr>";
+ }
?>
<tr><td><input type="checkbox" name="lastmod" <?php
- $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/lastmod.txt";
- if (file_exists($lastmod_sem)) {
- echo checked;
- }
+ $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/lastmod.txt";
+ if (file_exists($lastmod_sem)) {
+ echo checked;
+ }
?>>Display last modification date and time.</td></tr>
<?php
-if (file_exists("$maj_data_directory/gl.txt")) {
+ if (file_exists("$maj_data_directory/gl.txt")) {
- echo "<tr><td><input type=\"checkbox\" name=\"gl\"";
+ echo "<tr><td><input type=\"checkbox\" name=\"gl\"";
- if (file_exists("$maj_data_directory/items/$maj_req_entry/gl.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/gl.txt")) {
+ echo checked;
+ }
- echo ">Enable Google support.</td></tr>";
-}
+ echo ">Enable Google support.</td></tr>";
+ }
-if (file_exists("$maj_data_directory/fb.txt")) {
+ if (file_exists("$maj_data_directory/fb.txt")) {
- echo "<tr><td><input type=\"checkbox\" name=\"fb\"";
+ echo "<tr><td><input type=\"checkbox\" name=\"fb\"";
- if (file_exists("$maj_data_directory/items/$maj_req_entry/fb.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/fb.txt")) {
+ echo checked;
+ }
- echo ">Enable Facebook support.</td></tr>";
-}
-
-if (file_exists("images/$maj_req_entry/album")) {
+ echo ">Enable Facebook support.</td></tr>";
+ }
- $count_album_images = count(glob("images/$maj_req_entry/album/*"));
+ if (file_exists("images/$maj_req_entry/album")) {
- if ($count_album_images < 1) {
- rmdirr("images/$maj_req_entry/album");
- }
- else {
- if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-album.txt")) {
- echo "<tr><td><input type=\"checkbox\" name=\"auto_album\" checked>";
+ $count_album_images = count(glob("images/$maj_req_entry/album/*"));
+
+ if ($count_album_images < 1) {
+ rmdirr("images/$maj_req_entry/album");
}
else {
- echo "<tr><td><input type=\"checkbox\" name=\"auto_album\">";
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-album.txt")) {
+ echo "<tr><td><input type=\"checkbox\" name=\"auto_album\" checked>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"auto_album\">";
+ }
+
+ if ($count_album_images > 1) {
+ echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images images</a>).</td></tr>";
+ }
+ else {
+ echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images image</a>).</td></tr>";
+ }
}
+ }
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/files")) {
- if ($count_album_images > 1) {
- echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images images</a>).</td></tr>";
+ $count_filedrop_files = count(glob("$maj_data_directory/items/$maj_req_entry/filedrop/files/*"));
+
+ if ($count_filedrop_files < 1) {
+ rmdirr("$maj_data_directory/items/$maj_req_entry/filedrop");
}
else {
- echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images image</a>).</td></tr>";
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt")) {
+ echo "<tr><td><input type=\"checkbox\" name=\"auto_filedrop\" checked>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"auto_filedrop\">";
+ }
+
+ if ($count_filedrop_files > 1) {
+
+ echo "Automatically display filedrop (<a href=\"index.php?entry=$maj_req_entry&show=filedrop\">$count_filedrop_files files</a>).</td></tr>";
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ echo "<tr><td><input type=\"checkbox\" name=\"sort_filedrop_new\" checked>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"sort_filedrop_new\">";
+ }
+
+ echo " Sort filedrop by upload order and display files from newest to oldest.</td></tr>";
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ echo "<tr><td><input type=\"checkbox\" name=\"sort_filedrop_old\" checked>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"sort_filedrop_old\">";
+ }
+
+ echo " Sort filedrop by upload order and display files from oldest to newest.</td></tr>";
+ }
+ else {
+ echo "Automatically display filedrop (<a href=\"index.php?entry=$maj_req_entry&show=filedrop\">$count_filedrop_files file</a>).</td></tr>";
+ }
}
}
-}
}
@@ -1227,6 +1270,68 @@ if (file_exists("images/$maj_req_entry/album")) {
unlink("$maj_data_directory/items/$maj_req_entry/auto-album.txt");
}
}
+
+ if (isset($_POST['auto_filedrop']) and !empty($_POST['auto_filedrop']) and ($_POST['auto_filedrop'] == "on")) {
+
+ if (!file_exists("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt")) {
+ touch("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt");
+ }
+ }
+
+ if (!isset($_POST['auto_filedrop']) or empty($_POST['auto_filedrop'])) {
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt");
+ }
+ }
+
+ if (isset($_POST['sort_filedrop_new']) and !empty($_POST['sort_filedrop_new']) and ($_POST['sort_filedrop_new'] == "on") and isset($_POST['sort_filedrop_old']) and !empty($_POST['sort_filedrop_old']) and ($_POST['sort_filedrop_old'] == "on")) {
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ unset($_POST['sort_filedrop_new']);
+ }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ unset($_POST['sort_filedrop_old']);
+ }
+ }
+
+ if (isset($_POST['sort_filedrop_new']) and !empty($_POST['sort_filedrop_new']) and ($_POST['sort_filedrop_new'] == "on")) {
+
+ if (!file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ mkdir("$maj_data_directory/items/$maj_req_entry/filedrop/sort",0700,true);
+ touch("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt");
+ }
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt");
+ }
+ }
+
+ if (!isset($_POST['sort_filedrop_new']) or empty($_POST['sort_filedrop_new'])) {
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt");
+ }
+ }
+
+ if (isset($_POST['sort_filedrop_old']) and !empty($_POST['sort_filedrop_old']) and ($_POST['sort_filedrop_old'] == "on")) {
+
+ if (!file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ mkdir("$maj_data_directory/items/$maj_req_entry/filedrop/sort",0700,true);
+ touch("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt");
+ }
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt");
+ }
+ }
+
+ if (!isset($_POST['sort_filedrop_old']) or empty($_POST['sort_filedrop_old'])) {
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt");
+ }
+ }
}
if (file_exists("$maj_data_directory/items/$maj_req_entry/title.old")) {
diff --git a/index.php b/index.php
index 26f17ce..027d736 100644
--- a/index.php
+++ b/index.php
@@ -2170,84 +2170,93 @@ foreach ($maj_disp as $maj_d) {
echo "</div></div></td></tr></table>";
}
- if (isset($maj_req_entry) and !empty($maj_req_entry) and isset($maj_req_show) and !empty($maj_req_show) and ($maj_req_show == filedrop) and file_exists("$maj_data_directory/items/$maj_d/filedrop/files")) {
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop") and (file_exists("$maj_data_directory/items/$maj_d/auto-filedrop.txt") or (isset($maj_req_entry) and !empty($maj_req_entry) and isset($maj_req_show) and !empty($maj_req_show) and ($maj_req_show == filedrop)))) {
+ $maj_filedrop_files = glob("$maj_data_directory/items/$maj_d/filedrop/files/*",GLOB_NOSORT);
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"$maj_wentry\"><tr><td>";
-
- echo "<div class=\"panel_wrapper\"><div class=\"panel_title\">Filedrop";
-
- if (isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username)) {
- echo "<a href=del.php?entry=$maj_d&target=filedrop><img src=images/widget.del.png border=0 width=11 height=11 align=right alt=\"delete filedrop\"></a>";
- }
- echo "</div><div class=panel_body>";
+ if (count($maj_filedrop_files) > 0) {
- if (file_exists("$maj_data_directory/items/$maj_d/passwd.txt") and (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) and (!isset($_REQUEST['passwd']) or ($maj_crypt_passwd != $maj_passwd))) {
- echo "This entry is password protected. If you know the magic word, click <a href=passwd.php?entry=$maj_d&show=filedrop>here</a> to enter it.";
- }
- else {
-
- if ($maj_dh_count = opendir("$maj_data_directory/items/$maj_d/filedrop/count")) {
-
- while (($maj_dl_count = readdir($maj_dh_count)) !== false) {
-
- if ($maj_dl_count != "." && $maj_dl_count != "..") {
-
- $maj_dl_match = mb_substr("$maj_dl_count",0,-4);
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"$maj_wentry\"><tr><td>";
+
+ echo "<div class=\"panel_wrapper\"><div class=\"panel_title\">Filedrop";
+
+ if (isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username)) {
+ echo "<a href=del.php?entry=$maj_d&target=filedrop><img src=images/widget.del.png border=0 width=11 height=11 align=right alt=\"delete filedrop\"></a>";
+ }
+ echo "</div><div class=panel_body>";
- if (file_exists("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count") and !file_exists("$maj_data_directory/items/$maj_d/filedrop/files/$maj_dl_match")) {
- unlink("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count");
+ if (file_exists("$maj_data_directory/items/$maj_d/passwd.txt") and (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) and (!isset($_REQUEST['passwd']) or ($maj_crypt_passwd != $maj_passwd))) {
+ echo "This entry is password protected. If you know the magic word, click <a href=passwd.php?entry=$maj_d&show=filedrop>here</a> to enter it.";
+ }
+ else {
+
+ if ($maj_dh_count = opendir("$maj_data_directory/items/$maj_d/filedrop/count")) {
+
+ while (($maj_dl_count = readdir($maj_dh_count)) !== false) {
+
+ if ($maj_dl_count != "." && $maj_dl_count != "..") {
+
+ $maj_dl_match = mb_substr("$maj_dl_count",0,-4);
+
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count") and !file_exists("$maj_data_directory/items/$maj_d/filedrop/files/$maj_dl_match")) {
+ unlink("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count");
+ }
}
}
+ closedir($maj_dh_count);
}
- closedir($maj_dh_count);
- }
-
- if ($maj_dh_filedrop = opendir("$maj_data_directory/items/$maj_d/filedrop/files")) {
- while (($maj_dl_file = readdir($maj_dh_filedrop)) !== false) {
- if ($maj_dl_file != "." && $maj_dl_file != "..") {
- $maj_filedrop_files[] = $maj_dl_file;
- }
+
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/sort/new-on-top.txt")) {
+ array_multisort(array_map("filemtime",$maj_filedrop_files),SORT_DESC,$maj_filedrop_files);
}
- closedir($maj_dh_filedrop);
- }
-
- sort($maj_filedrop_files);
-
- foreach ($maj_filedrop_files as $maj_filedrop_file) {
-
- echo "<table border=0 cellspacing=0 cellpadding=4><tr><td>";
- echo "<a href=\"index.php?entry=$maj_d&download=$maj_filedrop_file&type=filedrop\">";
- echo "<img src=images/filedrop.png width=36 height=36 border=0 alt=\"download file\"></a></td>";
- echo "<td><b>$maj_filedrop_file</b>";
-
- if (file_exists("$maj_data_directory/items/$maj_d/filedrop/sha1.txt")) {
- $maj_sha1 = sha1_file("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
- echo "<br>$maj_sha1 (<a href=\"http://www.faqs.org/rfcs/rfc3174\" target=\"_maj\">sha1</a>)";
+ elseif (file_exists("$maj_data_directory/items/$maj_d/filedrop/sort/old-on-top.txt")) {
+ array_multisort(array_map("filemtime",$maj_filedrop_files),SORT_ASC,$maj_filedrop_files);
}
- if (file_exists("$maj_data_directory/items/$maj_d/filedrop/md5.txt")) {
- $maj_md5 = md5_file("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
- echo "<br>$maj_md5 (<a href=\"http://www.faqs.org/rfcs/rfc1321\" target=\"_maj\">md5</a>)";
+ else {
+ sort($maj_filedrop_files);
}
-
- $maj_size = filesize("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
- $maj_size_string = ($maj_size > 512)?( ($maj_size/1024 > 512) ?sprintf("%.02f MB",($maj_size/1024)/1024) :sprintf("%.02f KB",$maj_size/1024)) :sprintf("%d B",$maj_size);
-
- echo "<br>$maj_size_string";
-
- if (file_exists("$maj_data_directory/items/$maj_d/filedrop/count/{$maj_filedrop_file}.txt")) {
-
- $maj_filedrop_count = file_get_contents("$maj_data_directory/items/$maj_d/filedrop/count/{$maj_filedrop_file}.txt");
-
- echo "<br>$maj_filedrop_count";
-
- if ($maj_filedrop_count == 1) {
- echo " download";
+
+ foreach ($maj_filedrop_files as $maj_filedrop_file) {
+
+ if (is_dir($maj_filedrop_file)) {
+ continue;
}
- if ($maj_filedrop_count > 1) {
- echo " downloads";
+
+ $maj_filedrop_file = basename($maj_filedrop_file);
+
+ echo "<table border=0 cellspacing=0 cellpadding=4><tr><td>";
+ echo "<a href=\"index.php?entry=$maj_d&download=$maj_filedrop_file&type=filedrop\">";
+ echo "<img src=images/filedrop.png width=36 height=36 border=0 alt=\"download file\"></a></td>";
+ echo "<td><b>$maj_filedrop_file</b>";
+
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/sha1.txt")) {
+ $maj_sha1 = sha1_file("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
+ echo "<br>$maj_sha1 (<a href=\"http://www.faqs.org/rfcs/rfc3174\" target=\"_maj\">sha1</a>)";
+ }
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/md5.txt")) {
+ $maj_md5 = md5_file("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
+ echo "<br>$maj_md5 (<a href=\"http://www.faqs.org/rfcs/rfc1321\" target=\"_maj\">md5</a>)";
+ }
+
+ $maj_size = filesize("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
+ $maj_size_string = ($maj_size > 512)?( ($maj_size/1024 > 512) ?sprintf("%.02f MB",($maj_size/1024)/1024) :sprintf("%.02f KB",$maj_size/1024)) :sprintf("%d B",$maj_size);
+
+ echo "<br>$maj_size_string";
+
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/count/{$maj_filedrop_file}.txt")) {
+
+ $maj_filedrop_count = file_get_contents("$maj_data_directory/items/$maj_d/filedrop/count/{$maj_filedrop_file}.txt");
+
+ echo "<br>$maj_filedrop_count";
+
+ if ($maj_filedrop_count == 1) {
+ echo " download";
+ }
+ if ($maj_filedrop_count > 1) {
+ echo " downloads";
+ }
}
+ echo "</td></tr></table>";
}
- echo "</td></tr></table>";
}
}
echo "</div></div>";
tree 796d8a3eb6b6645c84bd645184ce0bb3194ec00a
parent d5cce8ec187820c5ae1803e7cfdc987e6d33664f
author Engels Antonio <engels@majcms.org> 1369957533 +0800
committer Engels Antonio <engels@majcms.org> 1369957533 +0800
Add filedrop display toggle and files sorting
diff --git a/edit.php b/edit.php
index 9017a82..9978d57 100644
--- a/edit.php
+++ b/edit.php
@@ -326,195 +326,238 @@
?>"></td></tr>
<?php
- }
+}
- if ($maj_logged_in_username == $maj_admin_username) {
+if ($maj_logged_in_username == $maj_admin_username) {
?>
<tr><td><input class="input" style="width: 300px;" autocomplete="off" type="password" name="passwd" <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
- echo "value=\"password\"";
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
+ echo "value=\"password\"";
+ }
?>
> <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
- echo "Enter new password or clear field to disable password protection.";
- } else {
- echo "Enter optional entry access password.";
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/passwd.txt")) {
+ echo "Enter new password or clear field to disable password protection.";
+ } else {
+ echo "Enter optional entry access password.";
+ }
?></td></tr>
<tr><td><input class="input" style="width: 300px;" autocomplete="off" type="text" name="maxlines" <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
- echo "value=\"";
- readfile("$maj_data_directory/items/$maj_req_entry/maxlines.txt");
- echo "\"";
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
+ echo "value=\"";
+ readfile("$maj_data_directory/items/$maj_req_entry/maxlines.txt");
+ echo "\"";
+ }
?>
> <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
- echo "Enter new maximum lines for initial display or clear field to disable.";
- } else {
- echo "Enter optional maximum lines for initial display.";
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/maxlines.txt")) {
+ echo "Enter new maximum lines for initial display or clear field to disable.";
+ } else {
+ echo "Enter optional maximum lines for initial display.";
+ }
?></td></tr>
<tr><td><input type="checkbox" name="sticky" <?php
- $sticky_sem = 'data/sticky/' . $maj_req_entry;
- if (file_exists($sticky_sem)) {
- echo checked;
- }
+ $sticky_sem = 'data/sticky/' . $maj_req_entry;
+ if (file_exists($sticky_sem)) {
+ echo checked;
+ }
?>>Put entry title in Quick Links box.</td></tr>
<tr><td><input type="checkbox" name="display" <?php
- $display_sem = "$maj_data_directory/items/$maj_req_entry/cat.txt";
- if (file_exists($display_sem)) {
- echo checked;
- }
+ $display_sem = "$maj_data_directory/items/$maj_req_entry/cat.txt";
+ if (file_exists($display_sem)) {
+ echo checked;
+ }
?>>Always display. If this is not a private entry, it will be displayed even if its category is hidden or isolated.</td></tr>
<tr><td><input type="checkbox" name="private" <?php
- $private_sem = "$maj_data_directory/items/$maj_req_entry/private.txt";
- if (file_exists($private_sem)) {
- echo checked;
- }
+ $private_sem = "$maj_data_directory/items/$maj_req_entry/private.txt";
+ if (file_exists($private_sem)) {
+ echo checked;
+ }
?>>Private entry. This entry will unconditionally be invisible to visitors<?php
- if (file_exists("$maj_data_directory/ml.txt")) {
- echo " and to the mailing list";
- }
+ if (file_exists("$maj_data_directory/ml.txt")) {
+ echo " and to the mailing list";
+ }
?>, even if always display is set.</td></tr>
- <?php
- if (file_exists("$maj_data_directory/bb.txt")) {
+<?php
+ if (file_exists("$maj_data_directory/bb.txt")) {
?>
<tr><td><input type="checkbox" name="member" <?php
- $member_sem = "$maj_data_directory/items/$maj_req_entry/member.txt";
- if (file_exists($member_sem)) {
- echo checked;
- }
+ $member_sem = "$maj_data_directory/items/$maj_req_entry/member.txt";
+ if (file_exists($member_sem)) {
+ echo checked;
+ }
?>>Only registered members can view this entry.</td></tr>
- <?php
- }
+<?php
+ }
?>
- <?php
- if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directory/wiki.txt")) {
+<?php
+ if (file_exists("$maj_data_directory/bb.txt") and file_exists("$maj_data_directory/wiki.txt")) {
?>
<tr><td><input type="checkbox" name="edit" <?php
- $edit_sem = "$maj_data_directory/items/$maj_req_entry/edit.txt";
- if (file_exists($edit_sem)) {
- echo checked;
- }
+ $edit_sem = "$maj_data_directory/items/$maj_req_entry/edit.txt";
+ if (file_exists($edit_sem)) {
+ echo checked;
+ }
?>>Registered members can edit this entry.</td></tr>
<tr><td><input type="checkbox" name="lock" <?php
- if (file_exists("$maj_data_directory/items/$maj_req_entry/lock.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/lock.txt")) {
+ echo checked;
+ }
?>>Only the administrator can edit this entry. </td></tr>
- <?php
- }
- }
+<?php
+ }
+}
- if (($maj_logged_in_username == $maj_admin_username) or file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-adm.txt")) {
+if (($maj_logged_in_username == $maj_admin_username) or file_exists("$maj_data_directory/members/active/$maj_logged_in_username/bb-adm.txt")) {
?>
<tr><td><input type="checkbox" name="xtitle" <?php
- $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xtitle.txt";
- if (file_exists($lastmod_sem)) {
- echo checked;
- }
+ $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xtitle.txt";
+ if (file_exists($lastmod_sem)) {
+ echo checked;
+ }
?>>Do not display the entry title.</td></tr>
<tr><td><input type="checkbox" name="xdate" <?php
- $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xdate.txt";
- if (file_exists($lastmod_sem)) {
- echo checked;
- }
+ $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/xdate.txt";
+ if (file_exists($lastmod_sem)) {
+ echo checked;
+ }
?>>Do not display the entry date.</td></tr>
<?php
-if (!file_exists("$maj_data_directory/avatar.txt")) {
+ if (!file_exists("$maj_data_directory/avatar.txt")) {
- echo "<tr><td><input type=\"checkbox\" name=\"xauthor\"";
+ echo "<tr><td><input type=\"checkbox\" name=\"xauthor\"";
- if (file_exists("$maj_data_directory/items/$maj_req_entry/xauthor.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/xauthor.txt")) {
+ echo checked;
+ }
- echo ">Do not display the entry author.</td></tr>";
-}
-else {
- echo "<tr><td><input type=\"checkbox\" name=\"xavatar\"";
+ echo ">Do not display the entry author.</td></tr>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"xavatar\"";
- if (file_exists("$maj_data_directory/items/$maj_req_entry/xavatar.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/xavatar.txt")) {
+ echo checked;
+ }
- echo ">Do not display the entry avatar.</td></tr>";
-}
+ echo ">Do not display the entry avatar.</td></tr>";
+ }
?>
<tr><td><input type="checkbox" name="lastmod" <?php
- $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/lastmod.txt";
- if (file_exists($lastmod_sem)) {
- echo checked;
- }
+ $lastmod_sem = "$maj_data_directory/items/$maj_req_entry/lastmod.txt";
+ if (file_exists($lastmod_sem)) {
+ echo checked;
+ }
?>>Display last modification date and time.</td></tr>
<?php
-if (file_exists("$maj_data_directory/gl.txt")) {
+ if (file_exists("$maj_data_directory/gl.txt")) {
- echo "<tr><td><input type=\"checkbox\" name=\"gl\"";
+ echo "<tr><td><input type=\"checkbox\" name=\"gl\"";
- if (file_exists("$maj_data_directory/items/$maj_req_entry/gl.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/gl.txt")) {
+ echo checked;
+ }
- echo ">Enable Google support.</td></tr>";
-}
+ echo ">Enable Google support.</td></tr>";
+ }
-if (file_exists("$maj_data_directory/fb.txt")) {
+ if (file_exists("$maj_data_directory/fb.txt")) {
- echo "<tr><td><input type=\"checkbox\" name=\"fb\"";
+ echo "<tr><td><input type=\"checkbox\" name=\"fb\"";
- if (file_exists("$maj_data_directory/items/$maj_req_entry/fb.txt")) {
- echo checked;
- }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/fb.txt")) {
+ echo checked;
+ }
- echo ">Enable Facebook support.</td></tr>";
-}
-
-if (file_exists("images/$maj_req_entry/album")) {
+ echo ">Enable Facebook support.</td></tr>";
+ }
- $count_album_images = count(glob("images/$maj_req_entry/album/*"));
+ if (file_exists("images/$maj_req_entry/album")) {
- if ($count_album_images < 1) {
- rmdirr("images/$maj_req_entry/album");
- }
- else {
- if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-album.txt")) {
- echo "<tr><td><input type=\"checkbox\" name=\"auto_album\" checked>";
+ $count_album_images = count(glob("images/$maj_req_entry/album/*"));
+
+ if ($count_album_images < 1) {
+ rmdirr("images/$maj_req_entry/album");
}
else {
- echo "<tr><td><input type=\"checkbox\" name=\"auto_album\">";
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-album.txt")) {
+ echo "<tr><td><input type=\"checkbox\" name=\"auto_album\" checked>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"auto_album\">";
+ }
+
+ if ($count_album_images > 1) {
+ echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images images</a>).</td></tr>";
+ }
+ else {
+ echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images image</a>).</td></tr>";
+ }
}
+ }
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/files")) {
- if ($count_album_images > 1) {
- echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images images</a>).</td></tr>";
+ $count_filedrop_files = count(glob("$maj_data_directory/items/$maj_req_entry/filedrop/files/*"));
+
+ if ($count_filedrop_files < 1) {
+ rmdirr("$maj_data_directory/items/$maj_req_entry/filedrop");
}
else {
- echo "Automatically display album (<a href=\"index.php?entry=$maj_req_entry&show=album\">$count_album_images image</a>).</td></tr>";
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt")) {
+ echo "<tr><td><input type=\"checkbox\" name=\"auto_filedrop\" checked>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"auto_filedrop\">";
+ }
+
+ if ($count_filedrop_files > 1) {
+
+ echo "Automatically display filedrop (<a href=\"index.php?entry=$maj_req_entry&show=filedrop\">$count_filedrop_files files</a>).</td></tr>";
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ echo "<tr><td><input type=\"checkbox\" name=\"sort_filedrop_new\" checked>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"sort_filedrop_new\">";
+ }
+
+ echo " Sort filedrop by upload order and display files from newest to oldest.</td></tr>";
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ echo "<tr><td><input type=\"checkbox\" name=\"sort_filedrop_old\" checked>";
+ }
+ else {
+ echo "<tr><td><input type=\"checkbox\" name=\"sort_filedrop_old\">";
+ }
+
+ echo " Sort filedrop by upload order and display files from oldest to newest.</td></tr>";
+ }
+ else {
+ echo "Automatically display filedrop (<a href=\"index.php?entry=$maj_req_entry&show=filedrop\">$count_filedrop_files file</a>).</td></tr>";
+ }
}
}
-}
}
@@ -1227,6 +1270,68 @@ if (file_exists("images/$maj_req_entry/album")) {
unlink("$maj_data_directory/items/$maj_req_entry/auto-album.txt");
}
}
+
+ if (isset($_POST['auto_filedrop']) and !empty($_POST['auto_filedrop']) and ($_POST['auto_filedrop'] == "on")) {
+
+ if (!file_exists("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt")) {
+ touch("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt");
+ }
+ }
+
+ if (!isset($_POST['auto_filedrop']) or empty($_POST['auto_filedrop'])) {
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/auto-filedrop.txt");
+ }
+ }
+
+ if (isset($_POST['sort_filedrop_new']) and !empty($_POST['sort_filedrop_new']) and ($_POST['sort_filedrop_new'] == "on") and isset($_POST['sort_filedrop_old']) and !empty($_POST['sort_filedrop_old']) and ($_POST['sort_filedrop_old'] == "on")) {
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ unset($_POST['sort_filedrop_new']);
+ }
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ unset($_POST['sort_filedrop_old']);
+ }
+ }
+
+ if (isset($_POST['sort_filedrop_new']) and !empty($_POST['sort_filedrop_new']) and ($_POST['sort_filedrop_new'] == "on")) {
+
+ if (!file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ mkdir("$maj_data_directory/items/$maj_req_entry/filedrop/sort",0700,true);
+ touch("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt");
+ }
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt");
+ }
+ }
+
+ if (!isset($_POST['sort_filedrop_new']) or empty($_POST['sort_filedrop_new'])) {
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt");
+ }
+ }
+
+ if (isset($_POST['sort_filedrop_old']) and !empty($_POST['sort_filedrop_old']) and ($_POST['sort_filedrop_old'] == "on")) {
+
+ if (!file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ mkdir("$maj_data_directory/items/$maj_req_entry/filedrop/sort",0700,true);
+ touch("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt");
+ }
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/filedrop/sort/new-on-top.txt");
+ }
+ }
+
+ if (!isset($_POST['sort_filedrop_old']) or empty($_POST['sort_filedrop_old'])) {
+
+ if (file_exists("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt")) {
+ unlink("$maj_data_directory/items/$maj_req_entry/filedrop/sort/old-on-top.txt");
+ }
+ }
}
if (file_exists("$maj_data_directory/items/$maj_req_entry/title.old")) {
diff --git a/index.php b/index.php
index 26f17ce..027d736 100644
--- a/index.php
+++ b/index.php
@@ -2170,84 +2170,93 @@ foreach ($maj_disp as $maj_d) {
echo "</div></div></td></tr></table>";
}
- if (isset($maj_req_entry) and !empty($maj_req_entry) and isset($maj_req_show) and !empty($maj_req_show) and ($maj_req_show == filedrop) and file_exists("$maj_data_directory/items/$maj_d/filedrop/files")) {
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop") and (file_exists("$maj_data_directory/items/$maj_d/auto-filedrop.txt") or (isset($maj_req_entry) and !empty($maj_req_entry) and isset($maj_req_show) and !empty($maj_req_show) and ($maj_req_show == filedrop)))) {
+ $maj_filedrop_files = glob("$maj_data_directory/items/$maj_d/filedrop/files/*",GLOB_NOSORT);
- echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"$maj_wentry\"><tr><td>";
-
- echo "<div class=\"panel_wrapper\"><div class=\"panel_title\">Filedrop";
-
- if (isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username)) {
- echo "<a href=del.php?entry=$maj_d&target=filedrop><img src=images/widget.del.png border=0 width=11 height=11 align=right alt=\"delete filedrop\"></a>";
- }
- echo "</div><div class=panel_body>";
+ if (count($maj_filedrop_files) > 0) {
- if (file_exists("$maj_data_directory/items/$maj_d/passwd.txt") and (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) and (!isset($_REQUEST['passwd']) or ($maj_crypt_passwd != $maj_passwd))) {
- echo "This entry is password protected. If you know the magic word, click <a href=passwd.php?entry=$maj_d&show=filedrop>here</a> to enter it.";
- }
- else {
-
- if ($maj_dh_count = opendir("$maj_data_directory/items/$maj_d/filedrop/count")) {
-
- while (($maj_dl_count = readdir($maj_dh_count)) !== false) {
-
- if ($maj_dl_count != "." && $maj_dl_count != "..") {
-
- $maj_dl_match = mb_substr("$maj_dl_count",0,-4);
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"$maj_wentry\"><tr><td>";
+
+ echo "<div class=\"panel_wrapper\"><div class=\"panel_title\">Filedrop";
+
+ if (isset($maj_logged_in_username) and ($maj_logged_in_username == $maj_admin_username)) {
+ echo "<a href=del.php?entry=$maj_d&target=filedrop><img src=images/widget.del.png border=0 width=11 height=11 align=right alt=\"delete filedrop\"></a>";
+ }
+ echo "</div><div class=panel_body>";
- if (file_exists("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count") and !file_exists("$maj_data_directory/items/$maj_d/filedrop/files/$maj_dl_match")) {
- unlink("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count");
+ if (file_exists("$maj_data_directory/items/$maj_d/passwd.txt") and (!isset($maj_logged_in_username) or ($maj_logged_in_username != $maj_admin_username)) and (!isset($_REQUEST['passwd']) or ($maj_crypt_passwd != $maj_passwd))) {
+ echo "This entry is password protected. If you know the magic word, click <a href=passwd.php?entry=$maj_d&show=filedrop>here</a> to enter it.";
+ }
+ else {
+
+ if ($maj_dh_count = opendir("$maj_data_directory/items/$maj_d/filedrop/count")) {
+
+ while (($maj_dl_count = readdir($maj_dh_count)) !== false) {
+
+ if ($maj_dl_count != "." && $maj_dl_count != "..") {
+
+ $maj_dl_match = mb_substr("$maj_dl_count",0,-4);
+
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count") and !file_exists("$maj_data_directory/items/$maj_d/filedrop/files/$maj_dl_match")) {
+ unlink("$maj_data_directory/items/$maj_d/filedrop/count/$maj_dl_count");
+ }
}
}
+ closedir($maj_dh_count);
}
- closedir($maj_dh_count);
- }
-
- if ($maj_dh_filedrop = opendir("$maj_data_directory/items/$maj_d/filedrop/files")) {
- while (($maj_dl_file = readdir($maj_dh_filedrop)) !== false) {
- if ($maj_dl_file != "." && $maj_dl_file != "..") {
- $maj_filedrop_files[] = $maj_dl_file;
- }
+
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/sort/new-on-top.txt")) {
+ array_multisort(array_map("filemtime",$maj_filedrop_files),SORT_DESC,$maj_filedrop_files);
}
- closedir($maj_dh_filedrop);
- }
-
- sort($maj_filedrop_files);
-
- foreach ($maj_filedrop_files as $maj_filedrop_file) {
-
- echo "<table border=0 cellspacing=0 cellpadding=4><tr><td>";
- echo "<a href=\"index.php?entry=$maj_d&download=$maj_filedrop_file&type=filedrop\">";
- echo "<img src=images/filedrop.png width=36 height=36 border=0 alt=\"download file\"></a></td>";
- echo "<td><b>$maj_filedrop_file</b>";
-
- if (file_exists("$maj_data_directory/items/$maj_d/filedrop/sha1.txt")) {
- $maj_sha1 = sha1_file("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
- echo "<br>$maj_sha1 (<a href=\"http://www.faqs.org/rfcs/rfc3174\" target=\"_maj\">sha1</a>)";
+ elseif (file_exists("$maj_data_directory/items/$maj_d/filedrop/sort/old-on-top.txt")) {
+ array_multisort(array_map("filemtime",$maj_filedrop_files),SORT_ASC,$maj_filedrop_files);
}
- if (file_exists("$maj_data_directory/items/$maj_d/filedrop/md5.txt")) {
- $maj_md5 = md5_file("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
- echo "<br>$maj_md5 (<a href=\"http://www.faqs.org/rfcs/rfc1321\" target=\"_maj\">md5</a>)";
+ else {
+ sort($maj_filedrop_files);
}
-
- $maj_size = filesize("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
- $maj_size_string = ($maj_size > 512)?( ($maj_size/1024 > 512) ?sprintf("%.02f MB",($maj_size/1024)/1024) :sprintf("%.02f KB",$maj_size/1024)) :sprintf("%d B",$maj_size);
-
- echo "<br>$maj_size_string";
-
- if (file_exists("$maj_data_directory/items/$maj_d/filedrop/count/{$maj_filedrop_file}.txt")) {
-
- $maj_filedrop_count = file_get_contents("$maj_data_directory/items/$maj_d/filedrop/count/{$maj_filedrop_file}.txt");
-
- echo "<br>$maj_filedrop_count";
-
- if ($maj_filedrop_count == 1) {
- echo " download";
+
+ foreach ($maj_filedrop_files as $maj_filedrop_file) {
+
+ if (is_dir($maj_filedrop_file)) {
+ continue;
}
- if ($maj_filedrop_count > 1) {
- echo " downloads";
+
+ $maj_filedrop_file = basename($maj_filedrop_file);
+
+ echo "<table border=0 cellspacing=0 cellpadding=4><tr><td>";
+ echo "<a href=\"index.php?entry=$maj_d&download=$maj_filedrop_file&type=filedrop\">";
+ echo "<img src=images/filedrop.png width=36 height=36 border=0 alt=\"download file\"></a></td>";
+ echo "<td><b>$maj_filedrop_file</b>";
+
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/sha1.txt")) {
+ $maj_sha1 = sha1_file("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
+ echo "<br>$maj_sha1 (<a href=\"http://www.faqs.org/rfcs/rfc3174\" target=\"_maj\">sha1</a>)";
+ }
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/md5.txt")) {
+ $maj_md5 = md5_file("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
+ echo "<br>$maj_md5 (<a href=\"http://www.faqs.org/rfcs/rfc1321\" target=\"_maj\">md5</a>)";
+ }
+
+ $maj_size = filesize("$maj_data_directory/items/$maj_d/filedrop/files/$maj_filedrop_file");
+ $maj_size_string = ($maj_size > 512)?( ($maj_size/1024 > 512) ?sprintf("%.02f MB",($maj_size/1024)/1024) :sprintf("%.02f KB",$maj_size/1024)) :sprintf("%d B",$maj_size);
+
+ echo "<br>$maj_size_string";
+
+ if (file_exists("$maj_data_directory/items/$maj_d/filedrop/count/{$maj_filedrop_file}.txt")) {
+
+ $maj_filedrop_count = file_get_contents("$maj_data_directory/items/$maj_d/filedrop/count/{$maj_filedrop_file}.txt");
+
+ echo "<br>$maj_filedrop_count";
+
+ if ($maj_filedrop_count == 1) {
+ echo " download";
+ }
+ if ($maj_filedrop_count > 1) {
+ echo " downloads";
+ }
}
+ echo "</td></tr></table>";
}
- echo "</td></tr></table>";
}
}
echo "</div></div>";