diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/attach.php | 11 | ||||
-rwxr-xr-x | include/items.php | 2 | ||||
-rw-r--r-- | include/photos.php | 38 | ||||
-rw-r--r-- | include/zot.php | 8 |
4 files changed, 54 insertions, 5 deletions
diff --git a/include/attach.php b/include/attach.php index b2c57f36f..e4ef28637 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1,5 +1,14 @@ <?php +/* + * File/attach API with the potential for revision control. + * + * TODO: a filesystem storage abstraction which maintains security (and 'data' contains a system filename + * which is inaccessible from the web). This could get around PHP storage limits and store videos and larger + * items, using fread or OS methods or native code to read/write or chunk it through. + * Also an 'append' option to the storage function might be a useful addition. + */ + require_once('include/permissions.php'); function z_mime_content_type($filename) { @@ -151,6 +160,8 @@ function attach_list_files($channel_id, $observer, $hash = '', $filename = '', $ } +// Find an attachment by hash and revision. Returns the entire attach structure including data. +// This could exhaust memory so most useful only when immediately sending the data. function attach_by_hash($hash,$rev = 0) { diff --git a/include/items.php b/include/items.php index 5afb0816d..7a00754e6 100755 --- a/include/items.php +++ b/include/items.php @@ -635,7 +635,7 @@ function decode_tags($t) { $ret = array(); foreach($t as $x) { $tag = array(); - $tag['term'] = htmlentities($x['term'], ENT_COMPAT,'UTF-8',false); + $tag['term'] = htmlentities($x['tag'], ENT_COMPAT,'UTF-8',false); $tag['url'] = htmlentities($x['url'], ENT_COMPAT,'UTF-8',false); switch($x['type']) { case 'hashtag': diff --git a/include/photos.php b/include/photos.php index 0d0750c22..8e07c612f 100644 --- a/include/photos.php +++ b/include/photos.php @@ -181,7 +181,6 @@ function photo_upload($channel, $observer, $args) { $basename = basename($filename); $uri = item_message_id(); - // Create item container $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; @@ -319,3 +318,40 @@ function photos_album_get_db_idstr($channel_id,$album,$remote_xchan = '') { return false; } + +function photos_create_item($channel, $creator_hash, $photo, $visible = false) { + + // Create item container + + $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; + $item_restrict = (($visible) ? ITEM_HIDDEN : ITEM_VISIBLE); + + $title = ''; + $uri = item_message_id(); + + $arr = array(); + + $arr['aid'] = $channel['channel_account_id']; + $arr['uid'] = $channel['channel_id']; + $arr['uri'] = $uri; + $arr['parent_uri'] = $uri; + $arr['item_flags'] = $item_flags; + $arr['item_restrict'] = $item_restrict; + $arr['resource_type'] = 'photo'; + $arr['resource_id'] = $photo['resource_id']; + $arr['owner_xchan'] = $channel['channel_hash']; + $arr['author_xchan'] = $creator_hash; + + $arr['allow_cid'] = $photo['allow_cid']; + $arr['allow_gid'] = $photo['allow_gid']; + $arr['deny_cid'] = $photo['deny_cid']; + $arr['deny_gid'] = $photo['deny_gid']; + + $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' + . '[img]' . $a->get_baseurl() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/img]' + . '[/url]'; + + $item_id = item_store($arr); + return $item_id; + +}
\ No newline at end of file diff --git a/include/zot.php b/include/zot.php index a1169ea3b..5afa9d496 100644 --- a/include/zot.php +++ b/include/zot.php @@ -229,8 +229,10 @@ function zot_refresh($them,$channel = null) { $j = json_decode($result['body'],true); - if(! (($j) && ($j['success']))) + if(! (($j) && ($j['success']))) { + logger('zot_refresh: result not decodable'); return false; + } $x = import_xchan($j); @@ -548,10 +550,10 @@ function import_xchan($arr) { && ($arr['site']['url'] != z_root())) $arr['searchable'] = false; - + $hidden = (1 - intval($arr['searchable'])); // Be careful - XCHAN_FLAGS_HIDDEN should evaluate to 1 - if(($r[0]['xchan_flags'] & XCHAN_FLAGS_HIDDEN) != $arr['searchable']) + if(($r[0]['xchan_flags'] & XCHAN_FLAGS_HIDDEN) != $hidden) $new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_HIDDEN; else $new_flags = $r[0]['xchan_flags']; |