Commit b3232b70 authored by Mario's avatar Mario

Merge branch '2.8RC'

parents 82529526 986bdd57
This diff is collapsed.
......@@ -69,12 +69,12 @@
top: 2px;
left: 2px;
}
/*
label {
width: 200px;
border-radius: 3px;
border: 1px solid #D1D3D4
}
}*/
/* hide input */
input.radio:empty {
......@@ -133,4 +133,35 @@ input.radio:checked ~ label {
/* radio focus */
input.radio:focus ~ label:before {
box-shadow: 0 0 0 3px #999;
}
#chess-games-owner > li,
#chess-controls-history-collapse,
#chess-controls-game-collapse {
margin-left: 10px;
}
.settings-label {
border: none;
}
#chess-revert {
margin-bottom: 10px;
}
#chess-controls .section-subtitle-wrapper {
background-color: #F0D9B5;
}
#chess-games-owner a {
color: gray;
}
#chess-new-form input {
margin-left: 10px;
}
#chess-new-form button {
margin-left: 20px;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<script>
$("#chess-verify-move").hide();
$("#chess-revert").hide();
$("#chess-verify-move").hide();
$("#chess-revert").hide();
</script>
<div class="generic-content-wrapper-styled">
<h1>New Game</h1>
<hr>
<form id="chess-new-form" action="chess/{{$channel}}/new/" method="post" class="acl-form" data-form_id="chess-new-form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'>
<div>
<input type="radio" name="color" id='id_chess_color1' value="white" class="radio" checked/>
<label for="id_chess_color1" style="color: black; background-color: white;">White</label>
</div>
<div class="clear"></div>
<div>
<input type="radio" name="color" id='id_chess_color2' value="black" class="radio"/>
<label for="id_chess_color2" style="color: white; background-color: black;">Black</label>
</div>
<h1>New Game</h1>
<div class="clear"></div>
<hr>
<form id="chess-new-form" action="chess/{{$channel}}/new/" method="post" class="acl-form" data-form_id="chess-new-form" data-allow_cid='{{$allow_cid}}' data-allow_gid='{{$allow_gid}}' data-deny_cid='{{$deny_cid}}' data-deny_gid='{{$deny_gid}}'>
<hr>
<button id="dbtn-acl" class="btn btn-default pull-left" data-toggle="modal" data-target="#aclModal" onclick="return false;" >Permissions</button>
<input class="pull-right" id="dbtn-submit" type="submit" name="submit" value="Create Game" />
</form>
{{$acl}}
<h4>Choose your color. White takes the first turn. </h4>
<div class="form-check form-check">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="color" id="id_chess_color1" value="white"> White
</label>
</div>
<div class="form-check form-check">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="color" id="id_chess_color2" value="black"> Black
</label>
</div>
<br>
<h4>Do you want to enforce legal moves? Leave unchecked to allow free play.</h4>
<div class="form-check form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="playmode" id="id_chess_play_mode" value="0"> Enforce legal moves
</label>
</div>
<br>
<h4>Select your opponent by choosing "Custom selection" in the "Permissions" dialog.</h4>
<div>
<button id="dbtn-acl" class="btn btn-sm btn-success" data-toggle="modal" data-target="#aclModal" onclick="return false;" >Choose opponent</button>
</div>
<hr>
<input class="btn btn-primary" id="dbtn-submit" type="submit" name="submit" value="Create Game" />
</form>
{{$acl}}
</div>
......@@ -321,6 +321,35 @@ class Diaspora_Receiver {
}
}
$cnt = preg_match_all('/\!\[url=(.*?)\](.*?)\[\/url\]/ism',$body,$matches,PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
$datarray['term'][] = [
'uid' => $this->importer['channel_id'],
'ttype' => TERM_FORUM,
'otype' => TERM_OBJ_POST,
'term' => $mtch[2],
'url' => $mtch[1]
];
}
}
$cnt = preg_match_all('/\!\[zrl=(.*?)\](.*?)\[\/zrl\]/ism',$body,$matches,PREG_SET_ORDER);
if($cnt) {
foreach($matches as $mtch) {
// don't include plustags in the term
$term = ((substr($mtch[2],-1,1) === '+') ? substr($mtch[2],0,-1) : $mtch[2]);
$datarray['term'][] = [
'uid' => $this->importer['channel_id'],
'ttype' => TERM_FORUM,
'otype' => TERM_OBJ_POST,
'term' => $term,
'url' => $mtch[1]
];
}
}
$plink = service_plink($xchan,$guid);
if(is_array($raw_location)) {
......@@ -402,6 +431,8 @@ class Diaspora_Receiver {
$guid = notags($this->get_property('guid'));
$diaspora_handle = notags($this->get_author());
$text = notags($this->get_property('text'));
if($diaspora_handle != $this->msg['author']) {
logger('Potential forgery. Message handle is not the same as envelope sender.');
return 202;
......@@ -426,6 +457,12 @@ class Diaspora_Receiver {
$source_url = 'https://' . substr($orig_author,strpos($orig_author,'@')+1) . '/fetch/post/' . $orig_guid ;
$orig_url = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
if($text)
$text = markdown_to_bb($text) . "\n";
else
$text = '';
$source_xml = get_diaspora_reshare_xml($source_url);
if($source_xml['status_message']) {
......@@ -525,7 +562,7 @@ class Diaspora_Receiver {
}
}
$newbody = "[share author='" . urlencode($orig_author_name)
$newbody = $text . "[share author='" . urlencode($orig_author_name)
. "' profile='" . $orig_author_link
. "' avatar='" . $orig_author_photo
. "' link='" . $orig_url
......@@ -1265,9 +1302,6 @@ class Diaspora_Receiver {
$parent_author_signature = $this->get_property('parent_author_signature');
// likes on comments not supported here and likes on photos not supported by Diaspora
$contact = diaspora_get_contact_by_handle($this->importer['channel_id'],$this->msg['author']);
if(! $contact) {
logger('diaspora_like: cannot find contact: ' . $this->msg['author'] . ' for channel ' . $this->importer['channel_name']);
......@@ -1280,7 +1314,7 @@ class Diaspora_Receiver {
return 202;
}
$r = q("SELECT * FROM item WHERE uid = %d AND mid = '%s' LIMIT 1",
$r = q("SELECT * FROM item WHERE uid = %d AND mid = '%s' and parent_mid = mid LIMIT 1",
intval($this->importer['channel_id']),
dbesc($parent_guid)
);
......@@ -1423,7 +1457,12 @@ class Diaspora_Receiver {
$arr['uid'] = $this->importer['channel_id'];
$arr['aid'] = $this->importer['channel_account_id'];
$arr['mid'] = $guid;
$arr['parent_mid'] = $parent_item['mid'];
if($parent_item['mid'] !== $parent_guid)
$arr['thr_parent'] = $parent_guid;
$arr['owner_xchan'] = $parent_item['owner_xchan'];
$arr['author_xchan'] = $person['xchan_hash'];
......
......@@ -46,7 +46,9 @@ function diaspora_load() {
'personal_xrd' => 'diaspora_personal_xrd',
'author_is_pmable' => 'diaspora_author_is_pmable',
'can_comment_on_post' => 'diaspora_can_comment_on_post',
'queue_deliver' => 'diaspora_queue_deliver'
'queue_deliver' => 'diaspora_queue_deliver',
'webfinger' => 'diaspora_webfinger',
'channel_protocols' => 'diaspora_channel_protocols'
]);
diaspora_init_relay();
......@@ -120,6 +122,13 @@ function diaspora_well_known(&$b) {
}
function diaspora_channel_protocols(&$b) {
if(intval(get_pconfig($b['channel_id'],'system','diaspora_allowed')))
$b['protocols'][] = 'diaspora';
}
function diaspora_personal_xrd(&$b) {
if(! intval(get_pconfig($b['user']['channel_id'],'system','diaspora_allowed')))
......@@ -138,6 +147,31 @@ function diaspora_personal_xrd(&$b) {
}
function diaspora_webfinger(&$b) {
if(! $b['channel'])
return;
if(! intval(get_pconfig($b['channel']['channel_id'],'system','diaspora_allowed')))
return;
$b['result']['links'][] = [
'rel' => 'http://joindiaspora.com/seed_location',
'type' => 'text/html',
'href' => z_root()
];
// Diaspora requires a salmon link.
// Use this *only* if the gnusoc plugin is not installed and enabled
if((! in_array('gnusoc',\App::$plugins)) || (! intval(get_pconfig($b['channel']['channel_id'],'system','gnusoc_allowed')))) {
$b['result']['links'][] = [
'rel' => 'salmon',
'href' => z_root() . '/receive/users/' . $b['channel']['channel_guid'] . str_replace('.','',App::get_hostname())
];
}
}
function diaspora_permissions_create(&$b) {
......@@ -215,6 +249,8 @@ function diaspora_process_outbound(&$arr) {
// logger('notifier_array: ' . print_r($arr,true), LOGGER_ALL, LOG_INFO);
// allow this to be set per message
// allow this to be set per message
if(($arr['mail']) && intval($arr['item']['raw'])) {
......@@ -263,15 +299,23 @@ function diaspora_process_outbound(&$arr) {
$prv_recips = $arr['env_recips'];
// The Diaspora profile message is unusual in that it is sent privately.
// The Diaspora profile message is unusual and must be handled independently
$is_profile = false;
if($arr['cmd'] === 'refresh_all' && $arr['recipients']) {
$prv_recips = array();
foreach($arr['recipients'] as $r) {
$prv_recips[] = array('hash' => trim($r,"'"));
$is_profile = true;
$profile_visible = perm_is_allowed($arr['channel']['channel_id'],'','view_profile');
if(! $profile_visible) {
$prv_recips = array();
foreach($arr['recipients'] as $r) {
$prv_recips[] = array('hash' => trim($r,"'"));
}
}
}
if($prv_recips) {
$hashes = array();
......@@ -297,7 +341,8 @@ function diaspora_process_outbound(&$arr) {
$single = deliverable_singleton($arr['channel']['channel_id'],$contact);
if($arr['packet_type'] == 'refresh' && $single) {
$qi = diaspora_profile_change($arr['channel'],$contact);
// This packet is sent privately to contacts, so we can always send the full profile (the last argument)
$qi = diaspora_profile_change($arr['channel'],$contact,false,true);
if($qi)
$arr['queued'][] = $qi;
return;
......@@ -368,10 +413,18 @@ function diaspora_process_outbound(&$arr) {
}
}
else {
// public message
$contact = $arr['hub'];
if($arr['packet_type'] === 'keychange') {
$target_item = get_pconfig($arr['channel']['channel_id'],'system','keychange');
$qi = diaspora_send_migration($target_item,$arr['channel'],$contact,true);
if($qi)
$arr['queued'][] = $qi;
return;
}
if(intval($target_item['item_deleted'])
&& ($target_item['mid'] === $target_item['parent_mid'])) {
// top-level retraction
......@@ -401,6 +454,24 @@ function diaspora_process_outbound(&$arr) {
}
}
}
if($is_profile) {
// with either a public or private profile, send a profile message to the public endpoint of
// each hub. $profile_visible indicates if the recipients can see all the data or a limited subset.
// @todo also find any other Diaspora pods who should get this message.
$contact = $arr['hub'];
$single = deliverable_singleton($arr['channel']['channel_id'],$contact);
if($arr['packet_type'] == 'refresh' && $single) {
$qi = diaspora_profile_change($arr['channel'],$contact,true,$profile_visible);
if($qi)
$arr['queued'][] = $qi;
return;
}
}
}
......@@ -479,6 +550,11 @@ function diaspora_discover(&$b) {
$webbie = $b['address'];
$protocol = $b['protocol'];
if($protocol && strtolower($protocol) !== 'diaspora')
return;
$result = array();
$network = null;
$diaspora = false;
......@@ -523,7 +599,7 @@ function diaspora_discover(&$b) {
}
}
if($diaspora && $diaspora_base) {
if(! ($diaspora && $diaspora_base)) {
$x = false;
}
......@@ -590,6 +666,15 @@ function diaspora_discover(&$b) {
$vcard['fn'] = $webbie;
if(($vcard['uid']) && (! $diaspora_guid))
$diaspora_guid = $guid = $vcard['uid'];
if($vcard['public_key']) {
$diaspora_key = $vcard['public_key'];
if(strstr($diaspora_key,'RSA '))
$pubkey = rsatopem($diaspora_key);
else
$pubkey = $diaspora_key;
}
}
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
......@@ -606,10 +691,11 @@ function diaspora_discover(&$b) {
*/
if($r) {
$r = q("update xchan set xchan_name = '%s', xchan_network = '%s', xchan_name_date = '%s' where xchan_hash = '%s'",
$r = q("update xchan set xchan_name = '%s', xchan_network = '%s', xchan_name_date = '%s', xchan_pubkey = '%s' where xchan_hash = '%s'",
dbesc($vcard['fn']),
dbesc($network),
dbesc(datetime_convert()),
dbesc($pubkey),
dbesc($addr)
);
}
......@@ -756,20 +842,21 @@ function diaspora_post_local(&$item) {
$handle = channel_reddress($author);
$meta = null;
if($item['verb'] === ACTIVITY_LIKE || $item['verb'] === ACTIVITY_DISLIKE) {
if($item['thr_parent'] === $item['parent_mid'] && $item['obj_type'] == ACTIVITY_OBJ_NOTE) {
if(activity_match($item['verb'], [ ACTIVITY_LIKE, ACTIVITY_DISLIKE ])) {
if(activity_match($item['obj_type'], [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_ACTIVITY, ACTIVITY_OBJ_COMMENT ])){
$meta = [
'positive' => (($item['verb'] === ACTIVITY_LIKE) ? 'true' : 'false'),
'guid' => $item['mid'],
'parent_guid' => $item['parent_mid'],
];
if(defined('DIASPORA_V2')) {
$meta['author'] = $handle;
$meta['parent_type'] = 'Post';
$meta['parent_type'] = (($item['thr_parent'] === $item['parent_mid']) ? 'Post' : 'Comment');
$meta['parent_guid'] = $item['thr_parent'];
}
else {
$meta['diaspora_handle'] = $handle;
$meta['target_type'] = 'Post';
$meta['parent_guid'] = $item['parent_mid'];
}
}
}
......@@ -962,9 +1049,13 @@ function diaspora_markdown_to_bb_init(&$s) {
$s = preg_replace_callback('/\@\{(.+?)\@(.+?)\}\+/','diaspora_md_mention_callback2',$s);
$s = preg_replace_callback('/\@\{(.+?)\@(.+?)\}/','diaspora_md_mention_callback2',$s);
// replace diaspora://$author_handle/$post_type/$guid with a local representation.
// Ideally we should eventually pass the author_handle and post_type to mod_display and from a hook
// fetch the post from the source if it isn't already available locally.
}
$s = preg_replace('#diaspora://(.*?)/(.*?)/([^\s\]]*)#ism', z_root() . '/display/$3', $s);
}
function diaspora_bb_to_markdown_bb(&$x) {
......@@ -1080,6 +1171,14 @@ function diaspora_queue_deliver(&$b) {
}
}
if($piled_up) {
// add a pre-deliver interval, this should not be necessary
$interval = ((get_config('system','delivery_interval') !== false)
? intval(get_config('system','delivery_interval')) : 2 );
if($interval)
@time_sleep_until(microtime(true) + (float) $interval);
do_delivery($piled_up);
}
}
......
......@@ -175,6 +175,11 @@ function diaspora_is_blacklisted($s) {
return true;
}
if(! check_channelallowed($s)) {
logger('blacklisted channel: ' . $s);
return true;
}
return false;
}
......@@ -232,7 +237,12 @@ function diaspora_decode($importer,$xml,$format) {
if($format !== 'legacy') {
$children = $basedom->children('http://salmon-protocol.org/ns/magic-env');
$public = true;
$author_link = str_replace('acct:','',base64url_decode($children->sig[0]->attributes()->key_id[0]));
if($children->sig && $children->sig[0]->attributes() && $children->sig[0]->attributes()->key_id) {
$author_link = str_replace('acct:','',base64url_decode($children->sig[0]->attributes()->key_id[0]));
}
else {
$author_link = '';
}
/**
SimpleXMLElement Object
......@@ -292,6 +302,10 @@ function diaspora_decode($importer,$xml,$format) {
logger('decrypted: ' . $decrypted, LOGGER_DATA);
$idom = parse_xml_string($decrypted,false);
if($idom === false) {
logger('failed to parse decrypted content');
http_status_exit(400);
}
$inner_iv = base64_decode($idom->iv);
$inner_aes_key = base64_decode($idom->aes_key);
......
This diff is collapsed.
......@@ -50,7 +50,7 @@ function find_diaspora_person_by_handle($handle) {
if($r) {
$person = $r[0];
logger('find_diaspora_person_by handle: in cache ' . print_r($r,true), LOGGER_DATA, LOG_DEBUG);
if($person['xchan_name_date'] < datetime_convert('UTC','UTC', 'now - 1 month')) {
if(($person['xchan_name_date'] < datetime_convert('UTC','UTC', 'now - 1 month')) || $person['xchan_pubkey'] === '') {
logger('Updating Diaspora cached record for ' . $handle);
$refresh = true;
}
......@@ -381,7 +381,7 @@ function get_diaspora_reshare_xml($url,$recurse = 0) {
}
else {
// fetch the old-style xml
$url = str_replace('/fetch/post/','p',$url) . '.xml';
$url = str_replace('/fetch/post/','/p/',$url) . '.xml';
$x = z_fetch_url($url);
if(! $x['success'])
......
......@@ -6,12 +6,14 @@
<image_url>{{$large}}</image_url>
<image_url_medium>{{$medium}}</image_url_medium>
<image_url_small>{{$small}}</image_url_small>
{{if $dob}}<birthday>{{$dob}}</birthday>{{/if}}
<gender>{{$gender}}</gender>
<bio>{{$about}}</bio>
<location>{{$location}}</location>
<searchable>{{$searchable}}</searchable>
<nsfw>{{$nsfw}}</nsfw>
<tag_string>{{$tags}}</tag_string>
{{if $profile_visible}}
{{if $dob}}<birthday>{{$dob}}</birthday>{{/if}}
<gender>{{$gender}}</gender>
<bio>{{$about}}</bio>
<location>{{$location}}</location>
{{/if}}
</profile></post>
</XML>
This diff is collapsed.
......@@ -34,16 +34,14 @@ function salmon_post(&$a) {
logger('mod-salmon: new salmon ' . $xml, LOGGER_DATA);
$nick = ((argc() > 1) ? trim(argv(1)) : '');
// $mentions = ((App::$argc > 2 && App::$argv[2] === 'mention') ? true : false);
$importer = channelx_by_nick($nick);
if(! $importer)
http_status_exit(500);
// @fixme check that this channel has the GNU-Social protocol enabled
if(! get_pconfig($importer['channel_id'],'system','gnusoc_allowed'))
http_status_exit(500);
// parse the xml
......@@ -194,6 +192,11 @@ function salmon_post(&$a) {
$xchan = $r[0];
if(! (check_siteallowed($xchan['xchan_guid']) && check_channelallowed($xchan['xchan_hash']))) {
logger('site or channel is blocked.');
http_status_exit(403);
}
/*
*
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment