streams/mod/attach.php

28 lines
592 B
PHP
Raw Normal View History

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