Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Haakon Meland Eriksen 2015-08-27 17:57:59 +02:00
commit 1b82fb7349
23 changed files with 1184 additions and 1161 deletions

View file

@ -33,6 +33,10 @@ At this point, the $Projectname [i]Affinity Slider[/i] tool, which usually appea
The Affinity Slider allows instantaneous filtering of large amounts of content, grouped by levels of closeness.
[b]Connection Filtering[/b]
You have the ability to control precisely what appears in your stream using the optional "Connection Filter". When enabled, the Connection Editor provides inputs for selecting criteria which needs to be matched in order to include or exclude a specific post from a specific channel. Once a post has been allowed, all comments to that post are allowed regardless of whether they match the selection criteria. You may select words that if present block the post or ensure it is included in your stream. Regular expressions may be used for even finer control, as well as hashtags or even the detected language of the post.
[b]Access Control Lists[/b]
When sharing content, members have the option of restricting who sees the content. By clicking on the padlock underneath the sharing box, one may choose desired recipients of the post, by clicking on their names.

View file

@ -174,9 +174,6 @@ function abook_toggle_flag($abook,$flag) {
);
}
$a = get_app();
if($a->data['abook'])
$a->data['abook']['abook_flags'] = $a->data['abook']['abook_flags'] ^ $flag;
return $r;
}

View file

@ -645,7 +645,27 @@ require_once('include/items.php');
if(array_key_exists('os_storage',$r[0]) && intval($r[0]['os_storage']))
$data = file_get_contents($data);
$r[0]['data'] = base64_encode($data);
json_return_and_die($r[0]);
$ret = array('photo' => $r[0]);
$i = q("select id from item where uid = %d and resource_type = 'photo' and resource_id = '%s' limit 1",
intval(local_channel()),
dbesc($_REQUEST['photo_id'])
);
if($i) {
$ii = q("select * from item where parent = %d order by id",
intval($i[0]['id'])
);
if($ii) {
xchan_query($ii,true,0);
$ii = fetch_post_tags($ii,true);
if($ii) {
$ret['item'] = array();
foreach($ii as $iii)
$ret['item'][] = encode_item($iii,true);
}
}
}
json_return_and_die($ret);
}
killme();
}

View file

@ -414,9 +414,19 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$hash = (($arr && $arr['hash']) ? $arr['hash'] : null);
$upload_path = (($arr && $arr['directory']) ? $arr['directory'] : '');
$observer = array();
if($observer_hash) {
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($observer_hash)
);
if($x)
$observer = $x[0];
}
logger('arr: ' . print_r($arr,true));
if(! perm_is_allowed($channel_id,get_observer_hash(), 'write_storage')) {
if(! perm_is_allowed($channel_id,$observer_hash, 'write_storage')) {
$ret['message'] = t('Permission denied.');
return $ret;
}
@ -434,7 +444,13 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
// revise or update must provide $arr['hash'] of the thing to revise/update
if($options !== 'update') {
if($options === 'import') {
$src = $arr['src'];
$filename = $arr['filename'];
$filesize = @filesize($src);
$hash = $arr['resource_id'];
}
elseif($options !== 'update') {
if(! x($_FILES,'userfile')) {
$ret['message'] = t('No source file.');
return $ret;
@ -480,12 +496,19 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$def_extension = '';
$is_photo = 0;
$gis = @getimagesize($src);
logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA);
if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) {
$is_photo = 1;
if($gis[2] === IMAGETYPE_GIF)
$def_extension = '.gif';
if($gis[2] === IMAGETYPE_JPEG)
$def_extension = '.jpg';
if($gis[2] === IMAGETYPE_PNG)
$def_extension = '.png';
}
$pathname = '';
@ -527,7 +550,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$folder_hash = '';
}
if(! $options) {
if((! $options) || ($options === 'import')) {
// A freshly uploaded file. Check for duplicate and resolve with the channel's overwrite settings.
@ -544,9 +567,18 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$hash = $x[0]['hash'];
}
else {
if(strpos($filename,'.') !== false) {
$basename = substr($filename,0,strrpos($filename,'.'));
$ext = substr($filename,strrpos($filename,'.'));
}
else {
$basename = $filename;
$ext = $def_extension;
}
$r = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ",
dbesc($filename),
dbesc($filename . '(%)'),
dbesc($basename . $ext),
dbesc($basename . '(%)' . $ext),
dbesc($folder_hash)
);
@ -556,7 +588,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
do {
$found = false;
foreach($r as $rr) {
if($rr['filename'] === $filename . '(' . $x . ')') {
if($rr['filename'] === $basename . '(' . $x . ')' . $ext) {
$found = true;
break;
}
@ -565,8 +597,10 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$x++;
}
while($found);
$filename = $filename . '(' . $x . ')';
$filename = $basename . '(' . $x . ')' . $ext;
}
else
$filename = $basename . $ext;
}
}
}
@ -614,8 +648,17 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
if($src)
@file_put_contents($os_basepath . $os_relpath,@file_get_contents($src));
if(array_key_exists('created', $arr))
$created = $arr['created'];
else
$created = datetime_convert();
if(array_key_exists('edited', $arr))
$edited = $arr['edited'];
else
$edited = $created;
if($options === 'replace') {
$r = q("update attach set filename = '%s', filetype = '%s', folder = '%s', filesize = %d, os_storage = %d, is_photo = %d, data = '%s', edited = '%s' where id = %d and uid = %d",
dbesc($filename),
@ -704,7 +747,21 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$args['contact_deny'] = $arr['contact_deny'];
if($arr['group_deny'])
$args['group_deny'] = $arr['group_deny'];
$p = photo_upload($channel,get_app()->get_observer(),$args);
if(array_key_exists('allow_cid',$arr))
$args['allow_cid'] = $arr['allow_cid'];
if(array_key_exists('allow_gid',$arr))
$args['allow_gid'] = $arr['allow_gid'];
if(array_key_exists('deny_cid',$arr))
$args['deny_cid'] = $arr['deny_cid'];
if(array_key_exists('deny_gid',$arr))
$args['deny_gid'] = $arr['deny_gid'];
$args['created'] = $created;
$args['edited'] = $edited;
if($arr['item'])
$args['item'] = $arr['item'];
$p = photo_upload($channel,$observer,$args);
if($p['success']) {
$ret['body'] = $p['body'];
}

View file

@ -395,7 +395,9 @@ function count_descendants($item) {
* @brief Check if the activity of the item is visible.
*
* likes (etc.) can apply to other things besides posts. Check if they are post
* children, in which case we handle them specially.
* children, in which case we handle them specially. Activities which are unrecognised
* as having special meaning and hidden will be treated as posts or comments and visible
* in the stream.
*
* @param array $item
* @return boolean
@ -403,12 +405,21 @@ function count_descendants($item) {
function visible_activity($item) {
$hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
$post_types = array(ACTIVITY_OBJ_NOTE,ACTIVITY_OBJ_COMMENT,basename(ACTIVITY_OBJ_NOTE),basename(ACTIVITY_OBJ_COMMENT));
foreach ($hidden_activities as $act) {
if ((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) {
return false;
}
}
// In order to share edits with networks which have no concept of editing, we'll create
// separate activities to indicate the edit. Our network will not require them, since our
// edits are automatically applied and the activity indicated.
if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types)))
return false;
return true;
}

View file

@ -778,7 +778,12 @@ function event_store_item($arr, $event) {
$private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0);
q("UPDATE item SET title = '%s', body = '%s', object = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d",
// @FIXME can only update sig if we have the author's channel on this site
// Until fixed, set it to nothing so it won't give us signature errors
$sig = '';
q("UPDATE item SET title = '%s', body = '%s', object = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', sig = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d",
dbesc($arr['summary']),
dbesc($prefix . format_event_bbcode($arr)),
dbesc($object),
@ -787,6 +792,7 @@ function event_store_item($arr, $event) {
dbesc($arr['deny_cid']),
dbesc($arr['deny_gid']),
dbesc($arr['edited']),
dbesc($sig),
intval($r[0]['item_flags']),
intval($private),
dbesc(ACTIVITY_OBJ_EVENT),

View file

@ -272,6 +272,8 @@ function can_comment_on_post($observer_xchan, $item) {
}
if(strstr($item['comment_policy'],'network:') && strstr($item['comment_policy'],'red'))
return true;
if(strstr($item['comment_policy'],'network:') && strstr($item['comment_policy'],'diaspora'))
return true;
if(strstr($item['comment_policy'],'site:') && strstr($item['comment_policy'],get_app()->get_hostname()))
return true;
@ -4366,7 +4368,7 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
);
}
else {
$r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where if = %d",
$r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d",
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])

View file

@ -52,12 +52,21 @@ function photo_upload($channel, $observer, $args) {
// Set to default channel permissions. If the parent directory (album) has permissions set,
// use those instead. If we have specific permissions supplied, they take precedence over
// all other settings.
// all other settings. 'allow_cid' being passed from an external source takes priority over channel settings.
// ...messy... needs re-factoring once the photos/files integration stabilises
if(array_key_exists('allow_cid',$args)) {
$str_group_allow = $args['allow_gid'];
$str_contact_allow = $args['allow_cid'];
$str_group_deny = $args['deny_gid'];
$str_contact_deny = $args['deny_cid'];
}
else {
$str_group_allow = $channel['channel_allow_gid'];
$str_contact_allow = $channel['channel_allow_cid'];
$str_group_deny = $channel['channel_deny_gid'];
$str_contact_deny = $channel['channel_deny_cid'];
}
if($args['directory']) {
$str_group_allow = $args['directory']['allow_gid'];
@ -261,6 +270,48 @@ function photo_upload($channel, $observer, $args) {
}
}
if($args['item']) {
foreach($args['item'] as $i) {
$item = get_item_elements($i);
$force = false;
if($item['mid'] === $item['parent_mid']) {
$item['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
. $tag . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]'
. '[/zrl]';
if($item['author_xchan'] === $channel['channel_hash']) {
$item['sig'] = base64url_encode(rsa_sign($item['body'],$channel['channel_prvkey']));
$item['item_verified'] = 1;
}
else {
$item['sig'] = '';
}
$force = true;
}
$r = q("select id, edited from item where mid = '%s' and uid = %d limit 1",
dbesc($item['mid']),
intval($channel['channel_id'])
);
if($r) {
if(($item['edited'] > $r[0]['edited']) || $force) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
item_store_update($item);
continue;
}
}
else {
$item['aid'] = $channel['channel_account_id'];
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item);
}
}
}
else {
$title = '';
$mid = item_message_id();
@ -291,7 +342,7 @@ function photo_upload($channel, $observer, $args) {
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
// We should also put a width_x_height on large photos. Left as an exercise for
// devs looking fo simple stuff to fix.
// devs looking for simple stuff to fix.
$larger = feature_enabled($channel['channel_id'], 'large_photos');
if($larger) {
@ -317,6 +368,7 @@ function photo_upload($channel, $observer, $args) {
if($visible)
proc_run('php', "include/notifier.php", 'wall-new', $item_id);
}
$ret['success'] = true;
$ret['item'] = $arr;

View file

@ -98,9 +98,6 @@ function ref_session_destroy ($id) {
function ref_session_gc($expire) {
q("DELETE FROM session WHERE expire < %d", dbesc(time()));
if (! get_config('system', 'innodb'))
db_optimizetable('session');
return true;
}

View file

@ -294,12 +294,12 @@ function zot_refresh($them, $channel = null, $force = false) {
if ($them['hubloc_url']) {
$url = $them['hubloc_url'];
} else {
$r = q("select hubloc_url, hubloc_flags from hubloc where hubloc_hash = '%s'",
$r = q("select hubloc_url, hubloc_primary from hubloc where hubloc_hash = '%s'",
dbesc($them['xchan_hash'])
);
if ($r) {
foreach ($r as $rr) {
if ($rr['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) {
if (intval($rr['hubloc_primary'])) {
$url = $rr['hubloc_url'];
break;
}
@ -2207,7 +2207,7 @@ function sync_locations($sender, $arr, $absolute = false) {
dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
$r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY;
$r[0]['hubloc_primary'] = intval($location['primary']);
hubloc_change_primary($r[0]);
$what .= 'primary_hub ';
$changed = true;
@ -2911,6 +2911,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
$total_feeds ++;
}
$disallowed = array('abook_id','abook_account','abook_channel','abook_rating','abook_rating_text');
foreach($arr['abook'] as $abook) {
@ -2999,7 +3000,6 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
foreach($clean as $k => $v) {
if($k == 'abook_dob')
$v = dbescdate($v);
$r = dbq("UPDATE abook set " . dbesc($k) . " = '" . dbesc($v)
. "' where abook_xchan = '" . dbesc($clean['abook_xchan']) . "' and abook_channel = " . intval($channel['channel_id']));
}

View file

@ -19,143 +19,6 @@ function connections_init(&$a) {
}
function connections_post(&$a) {
if(! local_channel())
return;
$contact_id = intval(argv(1));
if(! $contact_id)
return;
$orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1",
intval($contact_id),
intval(local_channel())
);
if(! $orig_record) {
notice( t('Could not access contact record.') . EOL);
goaway(z_root() . '/connections');
return; // NOTREACHED
}
call_hooks('contact_edit_post', $_POST);
$profile_id = $_POST['profile_assign'];
if($profile_id) {
$r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND `uid` = %d LIMIT 1",
dbesc($profile_id),
intval(local_channel())
);
if(! count($r)) {
notice( t('Could not locate selected profile.') . EOL);
return;
}
}
$hidden = intval($_POST['hidden']);
$priority = intval($_POST['poll']);
if($priority > 5 || $priority < 0)
$priority = 0;
$closeness = intval($_POST['closeness']);
if($closeness < 0)
$closeness = 99;
$abook_my_perms = 0;
foreach($_POST as $k => $v) {
if(strpos($k,'perms_') === 0) {
$abook_my_perms += $v;
}
}
$new_friend = false;
if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) {
$new_friend = true;
}
$r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d
where abook_id = %d AND abook_channel = %d",
dbesc($profile_id),
intval($abook_my_perms),
intval($closeness),
intval(1 - intval($new_friend)),
intval($contact_id),
intval(local_channel())
);
if($r)
info( t('Connection updated.') . EOL);
else
notice( t('Failed to update connection record.') . EOL);
if((x($a->data,'abook')) && $a->data['abook']['abook_my_perms'] != $abook_my_perms
&& (! intval($a->data['abook']['abook_self']))) {
proc_run('php', 'include/notifier.php', 'permission_update', $contact_id);
}
if($new_friend) {
$channel = $a->get_channel();
$default_group = $channel['channel_default_group'];
if($default_group) {
require_once('include/group.php');
$g = group_rec_byhash(local_channel(),$default_group);
if($g)
group_add_member(local_channel(),'',$a->data['abook_xchan'],$g['id']);
}
// Check if settings permit ("post new friend activity" is allowed, and
// friends in general or this friend in particular aren't hidden)
// and send out a new friend activity
// TODO
// pull in a bit of content if there is any to pull in
proc_run('php','include/onepoll.php',$contact_id);
}
// Refresh the structure in memory with the new data
$r = q("SELECT abook.*, xchan.*
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d and abook_id = %d LIMIT 1",
intval(local_channel()),
intval($contact_id)
);
if($r) {
$a->data['abook'] = $r[0];
}
if($new_friend) {
$arr = array('channel_id' => local_channel(), 'abook' => $a->data['abook']);
call_hooks('accept_follow', $arr);
}
connections_clone($a);
return;
}
function connections_clone(&$a) {
if(! array_key_exists('abook',$a->data))
return;
$clone = $a->data['abook'];
unset($clone['abook_id']);
unset($clone['abook_account']);
unset($clone['abook_channel']);
build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
}
function connections_content(&$a) {
$sort_type = 0;

View file

@ -314,6 +314,17 @@ function connedit_clone(&$a) {
if(! $a->poi)
return;
$r = q("SELECT abook.*, xchan.*
FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d and abook_id = %d LIMIT 1",
intval(local_channel()),
intval($a->poi['abook_id'])
);
if($r) {
$a->poi = $r[0];
}
$clone = $a->poi;
unset($clone['abook_id']);

View file

@ -132,6 +132,10 @@ function events_post(&$a) {
}
return;
}
$created = $x[0]['created'];
$edited = datetime_convert();
if($x[0]['allow_cid'] === '<' . $channel['channel_hash'] . '>'
&& $x[0]['allow_gid'] === '' && $x[0]['deny_cid'] === '' && $x[0]['deny_gid'] === '') {
$share = false;
@ -150,6 +154,7 @@ function events_post(&$a) {
}
}
else {
$created = $edited = datetime_convert();
if($share) {
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);

View file

@ -257,7 +257,6 @@ function import_post(&$a) {
$profile['photo'] = z_root() . '/photo/profile/l/' . $channel['channel_id'];
$profile['thumb'] = z_root() . '/photo/profile/m/' . $channel['channel_id'];
dbesc_array($profile);
$r = dbq("INSERT INTO profile (`"
. implode("`, `", array_keys($profile))
@ -277,7 +276,13 @@ function import_post(&$a) {
if($hublocs) {
foreach($hublocs as $hubloc) {
if(! array_key_exists('hubloc_primary',$hublocs)) {
$hash = make_xchan_hash($hubloc['hubloc_guid'],$hubloc['hubloc_guid_sig']);
if($hubloc['hubloc_network'] === 'zot' && $hash !== $hubloc['hubloc_hash']) {
logger('forged hubloc: ' . print_r($hubloc,true));
continue;
}
if(! array_key_exists('hubloc_primary',$hubloc)) {
$hubloc['hubloc_primary'] = (($hubloc['hubloc_flags'] & 0x0001) ? 1 : 0);
$hubloc['hubloc_orphancheck'] = (($hubloc['hubloc_flags'] & 0x0004) ? 1 : 0);
$hubloc['hubloc_error'] = (($hubloc['hubloc_status'] & 0x0003) ? 1 : 0);
@ -286,7 +291,7 @@ function import_post(&$a) {
$arr = array(
'guid' => $hubloc['hubloc_guid'],
'guid_sig' => $hubloc['guid_sig'],
'guid_sig' => $hubloc['hubloc_guid_sig'],
'url' => $hubloc['hubloc_url'],
'url_sig' => $hubloc['hubloc_url_sig']
);
@ -384,6 +389,13 @@ function import_post(&$a) {
$xchans = $data['xchan'];
if($xchans) {
foreach($xchans as $xchan) {
$hash = make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_guid_sig']);
if($xchan['xchan_network'] === 'zot' && $hash !== $xchan['xchan_hash']) {
logger('forged xchan: ' . print_r($xchan,true));
continue;
}
if(! array_key_exists('xchan_hidden',$xchan)) {
$xchan['xchan_hidden'] = (($xchan['xchan_flags'] & 0x0001) ? 1 : 0);
$xchan['xchan_orphan'] = (($xchan['xchan_flags'] & 0x0002) ? 1 : 0);

View file

@ -1,29 +1,180 @@
<?php
require_once('include/oembed.php');
/* To-Do
https://developers.google.com/+/plugins/snippet/
function arr_add_hashes(&$item,$k) {
$item = '#' . $item;
}
<meta itemprop="name" content="Toller Titel">
<meta itemprop="description" content="Eine tolle Beschreibung">
<meta itemprop="image" content="http://maple.libertreeproject.org/images/tree-icon.png">
<body itemscope itemtype="http://schema.org/Product">
<h1 itemprop="name">Shiny Trinket</h1>
<img itemprop="image" src="{image-url}" />
<p itemprop="description">Shiny trinkets are shiny.</p>
</body>
*/
if(!function_exists('deletenode')) {
function deletenode(&$doc, $node)
{
function linkinfo_content(&$a) {
logger('linkinfo: ' . print_r($_REQUEST,true));
$text = null;
$str_tags = '';
$br = "\n";
if(x($_GET,'binurl'))
$url = trim(hex2bin($_GET['binurl']));
else
$url = trim($_GET['url']);
if((substr($url,0,1) != '/') && (substr($url,0,4) != 'http'))
$url = 'http://' . $url;
if($_GET['title'])
$title = strip_tags(trim($_GET['title']));
if($_GET['description'])
$text = strip_tags(trim($_GET['description']));
if($_GET['tags']) {
$arr_tags = str_getcsv($_GET['tags']);
if(count($arr_tags)) {
array_walk($arr_tags,'arr_add_hashes');
$str_tags = $br . implode(' ',$arr_tags) . $br;
}
}
logger('linkinfo: ' . $url);
$result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true));
if($result['success']) {
$hdrs=array();
$h = explode("\n",$result['header']);
foreach ($h as $l) {
list($k,$v) = array_map("trim", explode(":", trim($l), 2));
$hdrs[$k] = $v;
}
if (array_key_exists('Content-Type', $hdrs))
$type = $hdrs['Content-Type'];
if($type) {
$zrl = is_matrix_url($url);
if(stripos($type,'image/') !== false) {
if($zrl)
echo $br . '[zmg]' . $url . '[/zmg]' . $br;
else
echo $br . '[img]' . $url . '[/img]' . $br;
killme();
}
if(stripos($type,'video/') !== false) {
if($zrl)
echo $br . '[zvideo]' . $url . '[/zvideo]' . $br;
else
echo $br . '[video]' . $url . '[/video]' . $br;
killme();
}
if(stripos($type,'audio/') !== false) {
if($zrl)
echo $br . '[zaudio]' . $url . '[/zaudio]' . $br;
else
echo $br . '[audio]' . $url . '[/audio]' . $br;
killme();
}
}
}
$template = $br . '#^[url=%s]%s[/url]%s' . $br;
$arr = array('url' => $url, 'text' => '');
call_hooks('parse_link', $arr);
if(strlen($arr['text'])) {
echo $arr['text'];
killme();
}
$x = oembed_process($url);
if($x) {
echo $x;
killme();
}
if($url && $title && $text) {
$text = $br . '[quote]' . trim($text) . '[/quote]' . $br;
$title = str_replace(array("\r","\n"),array('',''),$title);
$result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
logger('linkinfo (unparsed): returns: ' . $result);
echo $result;
killme();
}
$siteinfo = parseurl_getsiteinfo($url);
// If this is a Red site, use zrl rather than url so they get zids sent to them by default
if( x($siteinfo,'generator') && (strpos($siteinfo['generator'],PLATFORM_NAME . ' ') === 0))
$template = str_replace('url','zrl',$template);
if($siteinfo["title"] == "") {
echo sprintf($template,$url,$url,'') . $str_tags;
killme();
} else {
$text = $siteinfo["text"];
$title = $siteinfo["title"];
}
$image = "";
if(sizeof($siteinfo["images"]) > 0){
/* Execute below code only if image is present in siteinfo */
$total_images = 0;
$max_images = get_config('system','max_bookmark_images');
if($max_images === false)
$max_images = 2;
else
$max_images = intval($max_images);
foreach ($siteinfo["images"] as $imagedata) {
if ($url) {
$image .= sprintf('[url=%s]', $url);
}
$image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]';
if ($url) {
$image .= '[/url]';
}
$image .= "\n";
$total_images ++;
if($max_images && $max_images >= $total_images)
break;
}
}
if(strlen($text)) {
$text = $br.'[quote]'.trim($text).'[/quote]'.$br ;
}
if($image) {
$text = $br.$br.$image.$text;
}
$title = str_replace(array("\r","\n"),array('',''),$title);
$result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
logger('linkinfo: returns: ' . $result, LOGGER_DEBUG);
echo trim($result);
killme();
}
function deletexnode(&$doc, $node) {
$xpath = new DomXPath($doc);
$list = $xpath->query("//".$node);
foreach ($list as $child)
$child->parentNode->removeChild($child);
}
}
function completeurl($url, $scheme) {
@ -53,6 +204,7 @@ function completeurl($url, $scheme) {
return($complete);
}
function parseurl_getsiteinfo($url) {
$siteinfo = array();
@ -70,17 +222,17 @@ function parseurl_getsiteinfo($url) {
$doc = new DOMDocument();
@$doc->loadHTML($body);
deletenode($doc, 'style');
deletenode($doc, 'script');
deletenode($doc, 'option');
deletenode($doc, 'h1');
deletenode($doc, 'h2');
deletenode($doc, 'h3');
deletenode($doc, 'h4');
deletenode($doc, 'h5');
deletenode($doc, 'h6');
deletenode($doc, 'ol');
deletenode($doc, 'ul');
deletexnode($doc, 'style');
deletexnode($doc, 'script');
deletexnode($doc, 'option');
deletexnode($doc, 'h1');
deletexnode($doc, 'h2');
deletexnode($doc, 'h3');
deletexnode($doc, 'h4');
deletexnode($doc, 'h5');
deletexnode($doc, 'h6');
deletexnode($doc, 'ol');
deletexnode($doc, 'ul');
$xpath = new DomXPath($doc);
@ -215,169 +367,3 @@ function parseurl_getsiteinfo($url) {
return($siteinfo);
}
function arr_add_hashes(&$item,$k) {
$item = '#' . $item;
}
function urlinfo_content(&$a) {
logger('urlinfo: ' . print_r($_REQUEST,true));
$text = null;
$str_tags = '';
$br = "\n";
if(x($_GET,'binurl'))
$url = trim(hex2bin($_GET['binurl']));
else
$url = trim($_GET['url']);
if((substr($url,0,1) != '/') && (substr($url,0,4) != 'http'))
$url = 'http://' . $url;
if($_GET['title'])
$title = strip_tags(trim($_GET['title']));
if($_GET['description'])
$text = strip_tags(trim($_GET['description']));
if($_GET['tags']) {
$arr_tags = str_getcsv($_GET['tags']);
if(count($arr_tags)) {
array_walk($arr_tags,'arr_add_hashes');
$str_tags = $br . implode(' ',$arr_tags) . $br;
}
}
logger('urlinfo: ' . $url);
$result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true));
if($result['success']) {
$hdrs=array();
$h = explode("\n",$result['header']);
foreach ($h as $l) {
list($k,$v) = array_map("trim", explode(":", trim($l), 2));
$hdrs[$k] = $v;
}
if (array_key_exists('Content-Type', $hdrs))
$type = $hdrs['Content-Type'];
if($type) {
$zrl = is_matrix_url($url);
if(stripos($type,'image/') !== false) {
if($zrl)
echo $br . '[zmg]' . $url . '[/zmg]' . $br;
else
echo $br . '[img]' . $url . '[/img]' . $br;
killme();
}
if(stripos($type,'video/') !== false) {
if($zrl)
echo $br . '[zvideo]' . $url . '[/zvideo]' . $br;
else
echo $br . '[video]' . $url . '[/video]' . $br;
killme();
}
if(stripos($type,'audio/') !== false) {
if($zrl)
echo $br . '[zaudio]' . $url . '[/zaudio]' . $br;
else
echo $br . '[audio]' . $url . '[/audio]' . $br;
killme();
}
}
}
$template = $br . '#^[url=%s]%s[/url]%s' . $br;
$arr = array('url' => $url, 'text' => '');
call_hooks('parse_link', $arr);
if(strlen($arr['text'])) {
echo $arr['text'];
killme();
}
$x = oembed_process($url);
if($x) {
echo $x;
killme();
}
if($url && $title && $text) {
$text = $br . '[quote]' . trim($text) . '[/quote]' . $br;
$title = str_replace(array("\r","\n"),array('',''),$title);
$result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
logger('urlinfo (unparsed): returns: ' . $result);
echo $result;
killme();
}
$siteinfo = parseurl_getsiteinfo($url);
// If this is a Red site, use zrl rather than url so they get zids sent to them by default
if( x($siteinfo,'generator') && (strpos($siteinfo['generator'],PLATFORM_NAME . ' ') === 0))
$template = str_replace('url','zrl',$template);
if($siteinfo["title"] == "") {
echo sprintf($template,$url,$url,'') . $str_tags;
killme();
} else {
$text = $siteinfo["text"];
$title = $siteinfo["title"];
}
$image = "";
if(sizeof($siteinfo["images"]) > 0){
/* Execute below code only if image is present in siteinfo */
$total_images = 0;
$max_images = get_config('system','max_bookmark_images');
if($max_images === false)
$max_images = 2;
else
$max_images = intval($max_images);
foreach ($siteinfo["images"] as $imagedata) {
if ($url) {
$image .= sprintf('[url=%s]', $url);
}
$image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]';
if ($url) {
$image .= '[/url]';
}
$image .= "\n";
$total_images ++;
if($max_images && $max_images >= $total_images)
break;
}
}
if(strlen($text)) {
$text = $br.'[quote]'.trim($text).'[/quote]'.$br ;
}
if($image) {
$text = $br.$br.$image.$text;
}
$title = str_replace(array("\r","\n"),array('',''),$title);
$result = sprintf($template,$url,($title) ? $title : $url,$text) . $str_tags;
logger('urlinfo: returns: ' . $result, LOGGER_DEBUG);
echo trim($result);
killme();
}

View file

@ -24,7 +24,7 @@ function xrd_init(&$a) {
$dspr = replace_macros(get_markup_template('xrd_diaspora.tpl'),array(
'$baseurl' => $a->get_baseurl(),
'$dspr_guid' => $r[0]['channel_guid'],
'$dspr_guid' => $r[0]['channel_guid'] . str_replace('.','',$a->get_hostname()),
'$dspr_key' => base64_encode(pemtorsa($r[0]['channel_pubkey']))
));

View file

@ -108,7 +108,7 @@ function zfinger_init(&$a) {
$public_forum = false;
$role = get_pconfig($e['channel_id'],'system','permissions_role');
if($role === 'forum') {
if($role === 'forum' || $role === 'repository') {
$public_forum = true;
}
else {

View file

@ -1 +1 @@
2015-08-20.1130
2015-08-26.1136

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -135,7 +135,7 @@ function insertCommentURL(comment, id) {
if(reply && reply.length) {
reply = bin2hex(reply);
$('body').css('cursor', 'wait');
$.get('urlinfo?f=&binurl=' + reply, function(data) {
$.get('linkinfo?f=&binurl=' + reply, function(data) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == comment) {
tmpStr = "";

View file

@ -191,7 +191,7 @@ function enableOnUser(){
if(reply && reply.length) {
reply = bin2hex(reply);
$('#profile-rotator').spin('tiny');
$.get('{{$baseurl}}/urlinfo?f=&binurl=' + reply, function(data) {
$.get('{{$baseurl}}/linkinfo?f=&binurl=' + reply, function(data) {
addeditortext(data);
$('#profile-rotator').spin(false);
});
@ -258,7 +258,7 @@ function enableOnUser(){
if(reply && reply.length) {
reply = bin2hex(reply);
$('#profile-rotator').spin('tiny');
$.get('{{$baseurl}}/urlinfo?f=&binurl=' + reply, function(data) {
$.get('{{$baseurl}}/linkinfo?f=&binurl=' + reply, function(data) {
if (!editor) $("#profile-jot-text").val("");
initEditor(function(){
addeditortext(data);

View file

@ -78,7 +78,7 @@ else
reply = prompt("{{$linkurl}}");
if(reply && reply.length) {
$('#prvmail-rotator').spin('tiny');
$.get('urlinfo?f=&url=' + reply, function(data) {
$.get('linkinfo?f=&url=' + reply, function(data) {
addmailtext(data);
$('#prvmail-rotator').spin(false);
});
@ -104,7 +104,7 @@ else
event.preventDefault();
if(reply && reply.length) {
$('#prvmail-rotator').spin('tiny');
$.get('urlinfo?f=&url=' + reply, function(data) {
$.get('linkinfo?f=&url=' + reply, function(data) {
addmailtext(data);
$('#prvmail-rotator').spin(false);
});