mod/attach support for files/attachments using OS storage

This commit is contained in:
friendica 2013-02-05 15:34:30 -08:00
parent 74d23fcf8c
commit 05ba851d52
3 changed files with 9 additions and 6 deletions

View File

@ -150,7 +150,7 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $
// Retrieve all columns except 'data' // Retrieve all columns except 'data'
$r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d $sql_extra $orderby $limit", $r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d $sql_extra $orderby $limit",
intval($channel_id) intval($channel_id)
); );
@ -241,7 +241,7 @@ function attach_by_hash_nodata($hash,$rev = 0) {
// Now we'll see if we can access the attachment // Now we'll see if we can access the attachment
$r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_extra limit 1", $r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_extra limit 1",
intval($r[0]['uid']), intval($r[0]['uid']),
dbesc($hash) dbesc($hash)
); );
@ -311,7 +311,7 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) {
if($options === 'update' && $arr && array_key_exists('revision',$arr)) if($options === 'update' && $arr && array_key_exists('revision',$arr))
$sql_options = " and revision = " . intval($arr['revision']) . " "; $sql_options = " and revision = " . intval($arr['revision']) . " ";
$x =q("select id, aid, uid, filename, filetype, filesize, hash, revision, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where hash = '%s' and uid = %d $sql_options limit 1", $x =q("select id, aid, uid, filename, filetype, filesize, hash, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where hash = '%s' and uid = %d $sql_options limit 1",
dbesc($arr['hash']), dbesc($arr['hash']),
intval($channel_id) intval($channel_id)
); );
@ -426,7 +426,7 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) {
// Caution: This re-uses $sql_options set further above // Caution: This re-uses $sql_options set further above
$r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_options limit 1", $r = q("select id, aid, uid, hash, filename, filetype, filesize, revision, folder, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_options limit 1",
intval($channel_id), intval($channel_id),
dbesc($hash) dbesc($hash)
); );

View File

@ -19,7 +19,10 @@ function attach_init(&$a) {
header('Content-type: ' . $r['data']['filetype']); header('Content-type: ' . $r['data']['filetype']);
header('Content-disposition: attachment; filename=' . $r['data']['filename']); header('Content-disposition: attachment; filename=' . $r['data']['filename']);
echo $r['data']['data']; if($r['data']['flags'] & ATTACH_FLAG_OS )
echo @file_get_contents($r['data']['data']);
else
echo $r['data']['data'];
killme(); killme();
} }

View File

@ -1 +1 @@
2013-02-04.221 2013-02-05.222