From: Jerome Jutteau Date: Wed, 2 Jan 2013 20:31:47 +0000 (+0100) Subject: added download button in admin interface X-Git-Tag: 1.0~7 X-Git-Url: https://git.p6c8.net/jirafeau_project.git/commitdiff_plain/6bb6cfda2f5cbc5c7c9cc25cd228970ce2b582cd?ds=inline;hp=4b1444392bd5b597869029fc412618bc21268b6c added download button in admin interface --- 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'])) .