aboutsummaryrefslogtreecommitdiffstats
path: root/include/api.php
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-11-04 23:17:09 -0800
committerredmatrix <redmatrix@redmatrix.me>2015-11-04 23:17:09 -0800
commitf8b612a2c04e947f18614f3e8a412a0bd6365b2e (patch)
treef882e50dfe0ba74cf9fd6a7f36e25a6dde051189 /include/api.php
parentf7468ab473f49b9594095d29a50f8e921d0b15af (diff)
parent76043d97bd5d38e12ae84b18d48bc2dc4537ece0 (diff)
downloadvolse-hubzilla-f8b612a2c04e947f18614f3e8a412a0bd6365b2e.tar.gz
volse-hubzilla-f8b612a2c04e947f18614f3e8a412a0bd6365b2e.tar.bz2
volse-hubzilla-f8b612a2c04e947f18614f3e8a412a0bd6365b2e.zip
Merge https://github.com/redmatrix/redmatrix into pending_merge
Conflicts: install/update.php
Diffstat (limited to 'include/api.php')
-rw-r--r--include/api.php26
1 files changed, 15 insertions, 11 deletions
diff --git a/include/api.php b/include/api.php
index 3862ba7eb..711b946ed 100644
--- a/include/api.php
+++ b/include/api.php
@@ -660,26 +660,30 @@ require_once('include/attach.php');
dbesc($_REQUEST['file_id'])
);
if($r) {
- if($r[0]['is_dir'])
- $r[0]['data'] = '';
+ $ptr = $r[0];
+ if($length === 0)
+ $length = intval($ptr['filesize']);
+
+ if($ptr['is_dir'])
+ $ptr['data'] = '';
elseif(! intval($r[0]['os_storage'])) {
- $r[0]['start'] = $start;
- $x = substr(dbunescbin($r[0]['data'],$start,$length));
- $r[0]['length'] = strlen($x);
- $r[0]['data'] = base64_encode($x);
+ $ptr['start'] = $start;
+ $x = substr(dbunescbin($ptr['data'],$start,$length));
+ $ptr['length'] = strlen($x);
+ $ptr['data'] = base64_encode($x);
}
else {
- $fp = fopen(dbunescbin($r[0]['data'],'r'));
+ $fp = fopen(dbunescbin($ptr['data'],'r'));
if($fp) {
$seek = fseek($fp,$start,SEEK_SET);
$x = fread($fp,$length);
- $r[0]['start'] = $start;
- $r[0]['length'] = strlen($x);
- $r[0]['data'] = base64_encode($x);
+ $ptr['start'] = $start;
+ $ptr['length'] = strlen($x);
+ $ptr['data'] = base64_encode($x);
}
}
- $ret = array('attach' => $r[0]);
+ $ret = array('attach' => $ptr);
json_return_and_die($ret);
}
killme();