aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Willingham <founder@kakste.com>2013-02-02 14:56:17 +0000
committerThomas Willingham <founder@kakste.com>2013-02-02 14:56:17 +0000
commit0f13ae0ade10d6d2b0ef185ae6d6cc2d35831433 (patch)
tree7d6ac98d5f0b4e10ef86ba0f312401830c751250
parent1633f95db8a004055e51d1580fa4394527ca8a91 (diff)
parent5c6c4395f4ab7924cad619d3a1ca4cee69219769 (diff)
downloadvolse-hubzilla-0f13ae0ade10d6d2b0ef185ae6d6cc2d35831433.tar.gz
volse-hubzilla-0f13ae0ade10d6d2b0ef185ae6d6cc2d35831433.tar.bz2
volse-hubzilla-0f13ae0ade10d6d2b0ef185ae6d6cc2d35831433.zip
Merge remote-tracking branch 'upstream/master'
-rw-r--r--include/attach.php11
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/photos.php38
-rw-r--r--include/zot.php8
-rw-r--r--mod/item.php6
-rw-r--r--mod/network.php4
-rw-r--r--mod/photos.php245
-rw-r--r--version.inc2
-rw-r--r--view/js/mod_connections.js1
9 files changed, 67 insertions, 250 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'];
diff --git a/mod/item.php b/mod/item.php
index 8d01a12f8..080413be9 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -434,7 +434,7 @@ function item_post(&$a) {
'uid' => $profile_uid,
'type' => $success['termtype'],
'otype' => TERM_OBJ_POST,
- 'term' => substr($tag,1),
+ 'term' => $success['term'],
'url' => $success['url']
);
}
@@ -853,7 +853,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
$str_tags .= ',';
$str_tags .= $newtag;
}
- return array('replaced' => $replaced, 'termtype' => $termtype, 'url' => $url, 'contact' => $r[0]);
+ return array('replaced' => $replaced, 'termtype' => $termtype, 'term' => $basetag, 'url' => $url, 'contact' => $r[0]);
}
//is it a person tag?
if(strpos($tag,'@') === 0) {
@@ -965,7 +965,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
}
}
- return array('replaced' => $replaced, 'termtype' => $termtype, 'url' => $url, 'contact' => $r[0]);
+ return array('replaced' => $replaced, 'termtype' => $termtype, 'term' => $newname, 'url' => $url, 'contact' => $r[0]);
}
diff --git a/mod/network.php b/mod/network.php
index cca69dc52..4176f0047 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -707,8 +707,8 @@ function network_content(&$a, $update = 0, $load = false) {
if(! $update)
$o .= alt_pager($a,count($items));
-// logger('parent dba_timer: ' . sprintf('%01.4f',$first - $start));
-// logger('child dba_timer: ' . sprintf('%01.4f',$second - $first));
+ logger('parent dba_timer: ' . sprintf('%01.4f',$first - $start));
+ logger('child dba_timer: ' . sprintf('%01.4f',$second - $first));
return $o;
diff --git a/mod/photos.php b/mod/photos.php
index 127ea4893..101cb20b2 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -305,41 +305,7 @@ function photos_post(&$a) {
$visibility = 1;
if(! $item_id) {
-
- // Create item container
-
- $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
- $item_restrict = (($visibility) ? ITEM_HIDDEN : ITEM_VISIBLE);
-
- $title = '';
- $uri = item_message_id();
-
- $arr = array();
-
- $arr['aid'] = $a->data['channel']['channel_account_id'];
- $arr['uid'] = $page_owner_uid;
- $arr['uri'] = $uri;
- $arr['parent_uri'] = $uri;
- $arr['item_flags'] = $item_flags;
- $arr['item_restrict'] = $item_restrict;
- $arr['resource_type'] = 'photo';
- $arr['resource_id'] = $p[0]['resource_id'];
- $arr['owner_xchan'] = $a->data['channel']['channel_hash'];
- $arr['author_xchan'] = $a->data['channel']['channel_hash']; // FIXME for AUTH guests
-
- $arr['title'] = $title;
- $arr['allow_cid'] = $p[0]['allow_cid'];
- $arr['allow_gid'] = $p[0]['allow_gid'];
- $arr['deny_cid'] = $p[0]['deny_cid'];
- $arr['deny_gid'] = $p[0]['deny_gid'];
-
-
-
- $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $p[0]['resource_id'] . ']'
- . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource_id'] . '-' . $p[0]['scale'] . '[/img]'
- . '[/url]';
-
- $item_id = item_store($arr);
+ $item_id = photos_create_item($a->data['channel'],get_observer_hash(),$p[0],$visibility);
}
@@ -559,213 +525,14 @@ function photos_post(&$a) {
* default post action - upload a photo
*/
- call_hooks('photo_post_init', $_POST);
-
- /**
- * Determine the album to use
- */
-
- $album = notags(trim($_REQUEST['album']));
- $newalbum = notags(trim($_REQUEST['newalbum']));
-
- logger('mod/photos.php: photos_post(): album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG);
-
- if(! strlen($album)) {
- if(strlen($newalbum))
- $album = $newalbum;
- else
- $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
- }
-
- /**
- *
- * We create a wall item for every photo, but we don't want to
- * overwhelm the data stream with a hundred newly uploaded photos.
- * So we will make the first photo uploaded to this album in the last several hours
- * visible by default, the rest will become visible over time when and if
- * they acquire comments, likes, dislikes, and/or tags
- *
- */
-
- $r = q("SELECT * FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `created` > UTC_TIMESTAMP() - INTERVAL 3 HOUR ",
- dbesc($album),
- intval($page_owner_uid)
- );
- if((! count($r)) || ($album == t('Profile Photos')))
- $visible = 1;
- else
- $visible = 0;
-
- if(intval($_REQUEST['not_visible']) || $_REQUEST['not_visible'] === 'true')
- $visible = 0;
-
- $str_group_allow = perms2str(((is_array($_REQUEST['group_allow'])) ? $_REQUEST['group_allow'] : explode(',',$_REQUEST['group_allow'])));
- $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',',$_REQUEST['contact_allow'])));
- $str_group_deny = perms2str(((is_array($_REQUEST['group_deny'])) ? $_REQUEST['group_deny'] : explode(',',$_REQUEST['group_deny'])));
- $str_contact_deny = perms2str(((is_array($_REQUEST['contact_deny'])) ? $_REQUEST['contact_deny'] : explode(',',$_REQUEST['contact_deny'])));
-
- $ret = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
-
- call_hooks('photo_post_file',$ret);
-
- if(x($ret,'src') && x($ret,'filesize')) {
- $src = $ret['src'];
- $filename = $ret['filename'];
- $filesize = $ret['filesize'];
- $type = $ret['type'];
- }
- else {
- $src = $_FILES['userfile']['tmp_name'];
- $filename = basename($_FILES['userfile']['name']);
- $filesize = intval($_FILES['userfile']['size']);
- $type = $_FILES['userfile']['type'];
- }
- if ($type=="") $type=guess_image_type($filename);
-
- logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
-
- $maximagesize = get_config('system','maximagesize');
-
- if(($maximagesize) && ($filesize > $maximagesize)) {
- notice( t('Image exceeds size limit of ') . $maximagesize . EOL);
- @unlink($src);
- $foo = 0;
- call_hooks('photo_post_end',$foo);
- return;
- }
-
- if(! $filesize) {
- notice( t('Image file is empty.') . EOL);
- @unlink($src);
- $foo = 0;
- call_hooks('photo_post_end',$foo);
- return;
- }
-
- logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG);
-
- $imagedata = @file_get_contents($src);
-
-
-
- $r = q("select sum(size) as total from photo where uid = %d and scale = 0 ",
- intval($a->data['channel']['channel_id'])
- );
-
- $limit = service_class_fetch($a->data['channel']['channel_id'],'photo_upload_limit');
-
- if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
- notice( upgrade_message() . EOL );
- @unlink($src);
- $foo = 0;
- call_hooks('photo_post_end',$foo);
- killme();
- }
-
-
- $ph = new Photo($imagedata, $type);
-
- if(! $ph->is_valid()) {
- logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG);
- notice( t('Unable to process image.') . EOL );
- @unlink($src);
- $foo = 0;
- call_hooks('photo_post_end',$foo);
- killme();
- }
-
- $ph->orient($src);
- @unlink($src);
-
- $max_length = get_config('system','max_image_length');
- if(! $max_length)
- $max_length = MAX_IMAGE_LENGTH;
- if($max_length > 0)
- $ph->scaleImage($max_length);
-
- $width = $ph->getWidth();
- $height = $ph->getHeight();
-
- $smallest = 0;
-
- $photo_hash = photo_new_resource();
-
- $page_owner_aid = $a->data['channel']['channel_account_id'];
- $r = $ph->store($page_owner_aid, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
-
- if(! $r) {
- logger('mod/photos.php: photos_post(): image store failed' , LOGGER_DEBUG);
- notice( t('Image upload failed.') . EOL );
- killme();
- }
-
- if($width > 640 || $height > 640) {
- $ph->scaleImage(640);
- $ph->store($page_owner_aid, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
- $smallest = 1;
- }
-
- if($width > 320 || $height > 320) {
- $ph->scaleImage(320);
- $ph->store($page_owner_aid, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
- $smallest = 2;
- }
-
- $basename = basename($filename);
- $uri = item_message_id();
-
-
- // Create item container
-
- $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
- $item_restrict = (($visibility) ? ITEM_HIDDEN : ITEM_VISIBLE);
- $title = '';
- $uri = item_message_id();
-
- $arr = array();
-
- $arr['aid'] = $a->data['channel']['channel_account_id'];
- $arr['uid'] = $page_owner_uid;
- $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_hash;
- $arr['owner_xchan'] = $a->data['channel']['channel_hash'];
- $arr['author_xchan'] = $a->data['channel']['channel_hash']; // FIXME for AUTH guests
- $arr['title'] = $title;
- $arr['allow_cid'] = $str_contact_allow;
- $arr['allow_gid'] = $str_group_allow;
- $arr['deny_cid'] = $str_contact_deny;
- $arr['deny_gid'] = $str_group_deny;
-
-
- $arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $photo_hash . ']'
- . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
- . '[/url]';
-
- $item_id = item_store($arr);
-
- if($item_id) {
- q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
- dbesc($a->get_baseurl() . '/display/' . $owner_record['nickname'] . '/' . $item_id),
- intval($page_owner_uid),
- intval($item_id)
- );
- }
-
- if($visible)
- proc_run('php', "include/notifier.php", 'wall-new', $item_id);
-
- call_hooks('photo_post_end',intval($item_id));
-
- // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook
- // if they do not wish to be redirected
+ $r = photo_upload($a->channel,$a->get_observer(), $_REQUEST);
+ if(! $r['success']) {
+ notice($r['message'] . EOL);
+ }
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
- // NOTREACHED
+
}
diff --git a/version.inc b/version.inc
index 629a3deb4..c1c5fa011 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2013-01-31.217
+2013-02-01.218
diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js
index 485e2244b..33fc61883 100644
--- a/view/js/mod_connections.js
+++ b/view/js/mod_connections.js
@@ -57,6 +57,7 @@ function connectForum() {
$('#me_id_perms_view_storage').attr('checked','checked');
$('#me_id_perms_view_pages').attr('checked','checked');
$('#me_id_perms_send_stream').attr('checked','checked');
+ $('#me_id_perms_post_wall').attr('checked','checked');
$('#me_id_perms_post_comments').attr('checked','checked');
$('#me_id_perms_post_mail').attr('checked','checked');
$('#me_id_perms_tag_deliver').attr('checked','checked');