2011-05-25 09:08:15 +00:00
|
|
|
<?php
|
|
|
|
|
2011-07-01 00:35:35 +00:00
|
|
|
require_once('include/security.php');
|
2013-02-01 00:13:44 +00:00
|
|
|
require_once('include/attach.php');
|
2011-07-01 00:35:35 +00:00
|
|
|
|
2011-05-25 09:08:15 +00:00
|
|
|
function attach_init(&$a) {
|
|
|
|
|
2013-02-01 00:13:44 +00:00
|
|
|
if(argc() < 2) {
|
2011-05-25 09:08:15 +00:00
|
|
|
notice( t('Item not available.') . EOL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-01 00:13:44 +00:00
|
|
|
$r = attach_by_hash(argv(1),((argc() > 2) ? intval(argv(2)) : 0));
|
2011-05-25 09:08:15 +00:00
|
|
|
|
2013-02-01 00:13:44 +00:00
|
|
|
if(! $r['success']) {
|
|
|
|
notice( $r['message'] . EOL);
|
2011-05-25 09:08:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-01 00:13:44 +00:00
|
|
|
header('Content-type: ' . $r['data']['filetype']);
|
|
|
|
header('Content-disposition: attachment; filename=' . $r['data']['filename']);
|
|
|
|
echo $r['data']['data'];
|
2011-05-25 09:08:15 +00:00
|
|
|
killme();
|
2013-02-01 00:13:44 +00:00
|
|
|
|
2011-05-25 09:08:15 +00:00
|
|
|
}
|