From 6bb6cfda2f5cbc5c7c9cc25cd228970ce2b582cd Mon Sep 17 00:00:00 2001 From: Jerome Jutteau Date: Wed, 2 Jan 2013 21:31:47 +0100 Subject: [PATCH 1/1] added download button in admin interface --- admin.php | 13 +++++++++++++ lib/functions.php | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/admin.php b/admin.php index bdd0267..87dbcea 100755 --- a/admin.php +++ b/admin.php @@ -229,6 +229,19 @@ if (isset ($_POST['action'])) echo '
' . NL; echo '

' . t('Deleted links') . ' : ' . $count . '

'; } + elseif (strcmp ($_POST['action'], 'download') == 0) + { + $l = jirafeau_get_link ($_POST['link']); + if (!count ($l)) + return; + $p = s2p ($l['md5']); + header ('Content-Length: ' . $l['file_size']); + header ('Content-Type: ' . $l['mime_type']); + header ('Content-Disposition: attachment; filename="' . + $l['file_name'] . '"'); + if (file_exists(VAR_FILES . $p . $l['md5'])) + readfile (VAR_FILES . $p . $l['md5']); + } } require (JIRAFEAU_ROOT.'lib/template/footer.php'); diff --git a/lib/functions.php b/lib/functions.php index c26c5bc..6d7cb34 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -497,7 +497,13 @@ jirafeau_admin_list ($name, $file_hash, $link_hash) continue; /* Print link informations. */ echo ''; - echo '' . $l['file_name'] . ''; + echo '' . + '
' . + '' . + '' . + '' . + '
'; + echo ''; echo '' . $l['mime_type'] . ''; echo '' . jirafeau_human_size ($l['file_size']) . ''; echo '' . ($l['time'] == -1 ? '' : strftime ('%c', $l['time'])) . -- 2.34.1