aboutsummaryrefslogtreecommitdiffstats
path: root/include/api.php
diff options
context:
space:
mode:
authorHaakon Meland Eriksen <haakon.eriksen@far.no>2015-11-05 06:34:14 +0100
committerHaakon Meland Eriksen <haakon.eriksen@far.no>2015-11-05 06:34:14 +0100
commit07bd396837426fbe4cf3ecd189513d50a14081a1 (patch)
tree9ffe32f8b1eb1c6991c0827c7f182a509d12efe7 /include/api.php
parent73bef17365b6ca1a92c78243eed5252ec4869f86 (diff)
parentf7468ab473f49b9594095d29a50f8e921d0b15af (diff)
downloadvolse-hubzilla-07bd396837426fbe4cf3ecd189513d50a14081a1.tar.gz
volse-hubzilla-07bd396837426fbe4cf3ecd189513d50a14081a1.tar.bz2
volse-hubzilla-07bd396837426fbe4cf3ecd189513d50a14081a1.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include/api.php')
-rw-r--r--include/api.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/include/api.php b/include/api.php
index ad29625d8..3862ba7eb 100644
--- a/include/api.php
+++ b/include/api.php
@@ -628,6 +628,67 @@ require_once('include/attach.php');
api_register_func('api/red/files','api_attach_list', true);
+
+
+
+ function api_file_meta(&$a,$type) {
+ if (api_user()===false) return false;
+ if(! $_REQUEST['file_id']) return false;
+ $r = q("select * from attach where uid = %d and hash = '%s' limit 1",
+ intval(api_user()),
+ dbesc($_REQUEST['file_id'])
+ );
+ if($r) {
+ unset($r[0]['data']);
+ $ret = array('attach' => $r[0]);
+ json_return_and_die($ret);
+ }
+ killme();
+ }
+
+ api_register_func('api/red/filemeta', 'api_file_meta', true);
+
+
+ function api_file_data(&$a,$type) {
+ if (api_user()===false) return false;
+ if(! $_REQUEST['file_id']) return false;
+ $start = (($_REQUEST['start']) ? intval($_REQUEST['start']) : 0);
+ $length = (($_REQUEST['length']) ? intval($_REQUEST['length']) : 0);
+
+ $r = q("select * from attach where uid = %d and hash = '%s' limit 1",
+ intval(api_user()),
+ dbesc($_REQUEST['file_id'])
+ );
+ if($r) {
+ if($r[0]['is_dir'])
+ $r[0]['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);
+ }
+ else {
+ $fp = fopen(dbunescbin($r[0]['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);
+ }
+ }
+
+ $ret = array('attach' => $r[0]);
+ json_return_and_die($ret);
+ }
+ killme();
+ }
+
+ api_register_func('api/red/filedata', 'api_file_data', true);
+
+
+
function api_file_detail(&$a,$type) {
if (api_user()===false) return false;
if(! $_REQUEST['file_id']) return false;