aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php9
-rw-r--r--include/ItemObject.php4
-rw-r--r--include/activities.php2
-rw-r--r--include/bbcode.php1
-rw-r--r--include/comanche.php117
-rw-r--r--include/contact_widgets.php4
-rw-r--r--include/conversation.php50
-rwxr-xr-xinclude/dba/dba_mysqli.php2
-rw-r--r--include/features.php3
-rw-r--r--include/follow.php7
-rwxr-xr-xinclude/friendica_smarty.php2
-rw-r--r--include/identity.php5
-rwxr-xr-xinclude/items.php53
-rw-r--r--include/menu.php1
-rw-r--r--include/notifier.php4
-rw-r--r--include/onepoll.php9
-rw-r--r--include/poller.php2
-rwxr-xr-xinclude/text.php60
-rw-r--r--include/zot.php73
19 files changed, 352 insertions, 56 deletions
diff --git a/include/Contact.php b/include/Contact.php
index bf536ccd5..46d356f3f 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -15,13 +15,20 @@ function rconnect_url($channel_id,$xchan) {
if($r)
return '';
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($xchan)
+ );
+
+ if(($r) && ($r[0]['xchan_follow']))
+ return $r[0]['xchan_follow'];
+
$r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) limit 1",
dbesc($xchan),
intval(HUBLOC_FLAGS_PRIMARY)
);
if($r)
- return $r[0]['hubloc_url'];
+ return $r[0]['hubloc_url'] . '/follow?f=&url=%s';
return '';
}
diff --git a/include/ItemObject.php b/include/ItemObject.php
index 8c8c0ee2a..22b191e79 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -39,10 +39,10 @@ class Item extends BaseObject {
foreach($data['children'] as $item) {
/*
- * Only add thos that will be displayed
+ * Only add those that will be displayed
*/
- if(! visible_activity($item)) {
+ if((! visible_activity($item)) || array_key_exists('author_blocked',$item)) {
continue;
}
diff --git a/include/activities.php b/include/activities.php
index 10a01792f..7ef26abeb 100644
--- a/include/activities.php
+++ b/include/activities.php
@@ -45,6 +45,8 @@ function profile_activity($changed, $value) {
$prof = '[url=' . z_root() . '/profile/' . $self['channel_address'] . ']' . t('public profile') . '[/url]';
if($t == 1 && strlen($value)) {
+ // if it's a url, the HTML quotes will mess it up, so link it and don't try and zidify it because we don't know what it points to.
+ $value = linkify($value);
$message = sprintf( t('%1$s changed %2$s to “%3$s”'), $A, $changes, $value);
$message .= "\n\n" . sprintf( t('Visit %1$s\'s %2$s'), $A, $prof);
}
diff --git a/include/bbcode.php b/include/bbcode.php
index a0a53a310..4647b8567 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -259,6 +259,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = str_replace(array("\n","\r"), array('',''),$Text);
+ $Text = str_replace(array("\t"," "),array("    ","  "),$Text);
// Set up the parameters for a URL search string
$URLSearchString = "^\[\]";
diff --git a/include/comanche.php b/include/comanche.php
new file mode 100644
index 000000000..bdce0c5e2
--- /dev/null
+++ b/include/comanche.php
@@ -0,0 +1,117 @@
+<?php /** @file */
+
+require_once('include/security.php');
+
+// When editing a webpage - a dropdown is needed to select a page layout
+// On submit, the pdl_select value (which is the mid of an item with item_restrict = ITEM_PDL) is stored in
+// the webpage's resource_id, with resource_type 'pdl'.
+
+// Then when displaying a webpage, we can see if it has a pdl attached. If not we'll
+// use the default site/page layout.
+
+// If it has a pdl we'll load it as we know the mid and pass the body through comanche_parser() which will generate the
+// page layout from the given description
+
+
+function pdl_selector($uid,$current="") {
+
+ $o = '';
+
+ $sql_extra = item_permissions_sql($uid);
+
+ $r = q("select item_id.*, mid from item_id left join item on iid = item.id where item_id.uid = %d and item_id.uid = item.uid and service = 'PDL' order by sid asc",
+ intval($owner)
+ );
+
+ $arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r);
+ call_hooks('pdl_selector',$arr);
+
+ $entries = $arr['entries'];
+ $current = $arr['current'];
+
+ $o .= "<select name=\"pdl_select\" id=\"pdl_select\" size=\"1\" >";
+ $entries[] = array('title' => t('Default'), 'mid' => '');
+ foreach($entries as $selection) {
+ $selected = (($selection == $current) ? ' selected="selected" ' : '');
+ $o .= "<option value=\"{$selection['mid']}\" $selected >{$selection['sid']}</option>";
+ }
+
+ $o .= '</select>';
+ return $o;
+}
+
+
+
+function comanche_parser(&$a,$s) {
+
+
+ $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $matches, $s);
+ if($cnt)
+ $a->page['template'] = trim($matches[1]);
+
+ $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $matches, $s);
+ if($cnt)
+ $a->layout['theme'] = trim($matches[1]);
+
+ $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $matches, $s, PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]);
+ }
+ }
+
+}
+
+
+function comanche_menu($name) {
+ $a = get_app();
+ $m = menu_fetch($name,$a->profile['profile_uid'],get_observer_hash());
+ return render_menu($m);
+}
+
+function comanche_replace_region($match) {
+ $a = get_app();
+ if(array_key_exists($match[1],$a->page))
+ return $a->page[$match[1]];
+}
+
+// Widgets will have to get any operational arguments from the session,
+// the global app environment, or config storage until we implement argument passing
+
+
+function comanche_widget($name,$args = null) {
+ $a = get_app();
+ $func = 'widget_' . trim($name);
+ if(function_exists($func))
+ return $func($args);
+}
+
+
+function comanche_region(&$a,$s) {
+
+
+ $cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $matches, $s, PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s);
+ }
+ }
+
+ // need to modify this to accept parameters
+
+ $cnt = preg_match_all("/\[widget\](.*?)\[\/widget\]/ism", $matches, $s, PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $s = str_replace($mtch[0],comanche_widget(trim($mtch[1])),$s);
+ }
+ }
+
+ return $s;
+}
+
+
+function widget_profile($args) {
+ $a = get_app();
+ $block = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
+ return profile_sidebar($a->profile, $block, true);
+}
diff --git a/include/contact_widgets.php b/include/contact_widgets.php
index ca212796f..e5f778e49 100644
--- a/include/contact_widgets.php
+++ b/include/contact_widgets.php
@@ -70,11 +70,11 @@ function fileas_widget($baseurl,$selected = '') {
function categories_widget($baseurl,$selected = '') {
+ $a = get_app();
+
if(! feature_enabled($a->profile['profile_uid'],'categories'))
return '';
- $a = get_app();
-
$terms = array();
$r = q("select distinct(term) from term where uid = %d and type = %d order by term asc",
intval($a->profile['profile_uid']),
diff --git a/include/conversation.php b/include/conversation.php
index aade06b8a..a357e1480 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -92,8 +92,14 @@ function item_redir_and_replace_images($body, $images, $cid) {
function localize_item(&$item){
if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){
-
+
+ if(! $item['object'])
+ return;
+
$obj = json_decode_plus($item['object']);
+ if((! $obj) && ($item['object'])) {
+ logger('localize_item: failed to decode object: ' . print_r($item['object'],true));
+ }
if($obj['author'] && $obj['author']['link'])
$author_link = get_rel_link($obj['author']['link'],'alternate');
@@ -162,6 +168,9 @@ function localize_item(&$item){
$item['body'] .= "\n\n\n" . '[zrl=' . chanlink_url($author_link) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]';
}
+ else {
+ logger('localize_item like failed: link ' . $author_link . ' name ' . $author_name . ' url ' . $item_url);
+ }
}
@@ -391,6 +400,9 @@ function visible_activity($item) {
function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
$tstart = dba_timer();
+ $t0 = $t1 = $t2 = $t3 = $t4 = $t5 = $t6 = null;
+ $content_html = '';
+ $o = '';
require_once('bbcode.php');
@@ -488,10 +500,16 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
}
- else if($mode === 'search') {
+ elseif($mode === 'search') {
$live_update_div = '<div id="live-search"></div>' . "\r\n";
}
-
+ elseif($mode === 'photos') {
+ $profile_onwer = $a->profile['profile_uid'];
+ $page_writeable = ($profile_owner == local_user());
+ $live_update_div = '<div id="live-photos"></div>' . "\r\n";
+ // for photos we've already formatted the top-level item (the photo)
+ $content_html = $a->data['photo_html'];
+ }
$page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false);
@@ -712,6 +730,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
$threads = array();
foreach($items as $item) {
+ // Check for any blocked authors
+
if($arr_blocked) {
$blocked = false;
foreach($arr_blocked as $b) {
@@ -724,6 +744,18 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
continue;
}
+ // Check all the kids too
+
+ if($arr_blocked && $item['children']) {
+ for($d = 0; $d < count($item['children']); $d ++) {
+ foreach($arr_blocked as $b) {
+ if(($b) && ($item['children'][$d]['author_xchan'] == $b))
+ $item['children'][$d]['author_blocked'] = true;
+ }
+ }
+ }
+
+
// Can we put this after the visibility check?
like_puller($a,$item,$alike,'like');
@@ -781,8 +813,9 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
// logger('nouveau: ' . print_r($threads,true));
- $o = replace_macros($page_template, array(
+ $o .= replace_macros($page_template, array(
'$baseurl' => $a->get_baseurl($ssl_state),
+ '$photo_item' => $content_html,
'$live_update' => $live_update_div,
'$remove' => t('remove'),
'$mode' => $mode,
@@ -976,9 +1009,16 @@ function status_editor($a,$x,$popup=false) {
$geotag = (($x['allow_location']) ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '');
$plaintext = true;
+
if(feature_enabled(local_user(),'richtext'))
$plaintext = false;
+ if(intval($x['plaintext']))
+ $plaintext = true;
+
+ if(intval($x['mimeselect']))
+ $mimeselect = mimetype_select($x['profile_uid']);
+
$tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array(
@@ -1046,6 +1086,7 @@ function status_editor($a,$x,$popup=false) {
'$emtitle' => t('Example: bob@example.com, mary@example.com'),
'$lockstate' => $x['lockstate'],
'$acl' => $x['acl'],
+ '$mimeselect' => $mimeselect,
'$showacl' => ((array_key_exists('showacl',$x)) ? $x['showacl'] : 'yes'),
'$bang' => $x['bang'],
'$profile_uid' => $x['profile_uid'],
@@ -1125,6 +1166,7 @@ function conv_sort($arr,$order) {
elseif(stristr($order,'ascending'))
usort($parents,'sort_thr_created_rev');
+
if(count($parents))
foreach($parents as $i=>$_x)
$parents[$i]['children'] = get_item_children($arr, $_x);
diff --git a/include/dba/dba_mysqli.php b/include/dba/dba_mysqli.php
index f1a50cc3f..19907705b 100755
--- a/include/dba/dba_mysqli.php
+++ b/include/dba/dba_mysqli.php
@@ -70,7 +70,7 @@ class dba_mysqli extends dba_driver {
function close() {
if($this->db)
$this->db->close();
- $this->connected = flase;
+ $this->connected = false;
}
} \ No newline at end of file
diff --git a/include/features.php b/include/features.php
index 757f719df..6272b33ea 100644
--- a/include/features.php
+++ b/include/features.php
@@ -27,8 +27,7 @@ function get_features() {
//FIXME - needs a description, but how the hell do we explain this to normals?
array('sendzid', t('Extended Identity Sharing'), t(' ')),
array('expert', t('Expert Mode'), t('Enable Expert Mode to provide advanced configuration options')),
-
-
+ array('premium_channel', t('Premium Channel'), t('Allows you to set restrictions and terms on those that connect with your channel')),
),
// Post composition
diff --git a/include/follow.php b/include/follow.php
index ce550b07f..10bcddf2b 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -11,7 +11,7 @@
require_once('include/zot.php');
-function new_contact($uid,$url,$channel,$interactive = false) {
+function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) {
$result = array('success' => false,'message' => '');
@@ -60,6 +60,11 @@ function new_contact($uid,$url,$channel,$interactive = false) {
return $result;
}
+ // Premium channel, set confirm before callback to avoid recursion
+
+ if(array_key_exists('connect_url',$j) && (! $confirm))
+ goaway(zid($j['connect_url']));
+
// check service class limits
diff --git a/include/friendica_smarty.php b/include/friendica_smarty.php
index 1e8ef5406..12a789c9a 100755
--- a/include/friendica_smarty.php
+++ b/include/friendica_smarty.php
@@ -49,7 +49,7 @@ class FriendicaSmartyEngine implements ITemplateEngine {
public function __construct(){
$a = get_app();
- $basecompiledir = $a->config['system']['smarty3_folder'];
+ $basecompiledir = ((array_key_exists('smarty3_folder',$a->config['system'])) ? $a->config['system']['smarty3_folder'] : '');
if (!$basecompiledir) $basecompiledir = dirname(__dir__)."/view/tpl/smarty3";
if (!is_dir($basecompiledir)) {
echo "<b>ERROR:</b> folder <tt>$basecompiledir</tt> does not exist."; killme();
diff --git a/include/identity.php b/include/identity.php
index 5f210c456..8db6355c0 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -81,7 +81,7 @@ function create_identity($arr) {
return $ret;
}
- $nick = trim($arr['nickname']);
+ $nick = mb_strtolower(trim($arr['nickname']));
$name = escape_tags($arr['name']);
$pageflags = ((x($arr,'pageflags')) ? intval($arr['pageflags']) : PAGE_NORMAL);
@@ -182,7 +182,7 @@ function create_identity($arr) {
$newuid = $ret['channel']['channel_id'];
- $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
+ $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
dbesc($hash),
dbesc($guid),
dbesc($sig),
@@ -192,6 +192,7 @@ function create_identity($arr) {
dbesc($a->get_baseurl() . "/photo/profile/s/{$newuid}"),
dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()),
dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']),
+ dbesc(z_root() . '/follow?f=&url=%s'),
dbesc($ret['channel']['channel_name']),
dbesc('zot'),
dbesc(datetime_convert()),
diff --git a/include/items.php b/include/items.php
index 10bdcb38f..66172ade3 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1361,6 +1361,17 @@ function item_store($arr,$allow_exec = false) {
return 0;
}
+ // If a page layout is provided, ensure it exists and belongs to us.
+
+ if(array_key_exists('layout_mid',$arr) && $arr['layout_mid']) {
+ $l = q("select item_restrict from item where mid = '%s' and uid = %d limit 1",
+ dbesc($arr['layout_mid']),
+ intval($arr['uid'])
+ );
+ if((! $l) || (! ($l[0]['item_restrict'] & ITEM_PDL)))
+ unset($arr['layout_mid']);
+ }
+
// Don't let anybody set these, either intentionally or accidentally
if(array_key_exists('id',$arr))
@@ -1386,14 +1397,10 @@ function item_store($arr,$allow_exec = false) {
$arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 );
$arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : 0 );
- // this is a bit messy - we really need an input filter chain that temporarily undoes obscuring
- if($arr['mimetype'] != 'text/html' && $arr['mimetype'] != 'application/x-php') {
- if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false))
- $arr['body'] = escape_tags($arr['body']);
- if((strpos($arr['title'],'<') !== false) || (strpos($arr['title'],'>') !== false))
- $arr['title'] = escape_tags($arr['title']);
- }
+ $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']);
+ $arr['title'] = escape_tags($arr['title']);
+
// only detect language if we have text content, and if the post is private but not yet
// obscured, make it so.
@@ -2320,21 +2327,21 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
if(! $rino_enable)
$rino = 0;
- $ssl_val = intval(get_config('system','ssl_policy'));
- $ssl_policy = '';
-
- switch($ssl_val){
- case SSL_POLICY_FULL:
- $ssl_policy = 'full';
- break;
- case SSL_POLICY_SELFSIGN:
- $ssl_policy = 'self';
- break;
- case SSL_POLICY_NONE:
- default:
- $ssl_policy = 'none';
- break;
- }
+// $ssl_val = intval(get_config('system','ssl_policy'));
+// $ssl_policy = '';
+
+// switch($ssl_val){
+// case SSL_POLICY_FULL:
+// $ssl_policy = 'full';
+// break;
+// case SSL_POLICY_SELFSIGN:
+// $ssl_policy = 'self';
+// break;
+// case SSL_POLICY_NONE:
+// default:
+// $ssl_policy = 'none';
+// break;
+// }
$url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : '');
@@ -2423,7 +2430,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
$postvars['perm'] = 'r';
}
- $postvars['ssl_policy'] = $ssl_policy;
+// $postvars['ssl_policy'] = $ssl_policy;
if($page)
$postvars['page'] = $page;
diff --git a/include/menu.php b/include/menu.php
index 8d4664385..6d614055a 100644
--- a/include/menu.php
+++ b/include/menu.php
@@ -40,6 +40,7 @@ function menu_render($menu) {
}
+
function menu_fetch_id($menu_id,$channel_id) {
$r = q("select * from menu where menu_id = %d and menu_channel_id = %d limit 1",
diff --git a/include/notifier.php b/include/notifier.php
index 2a0301357..5dcd7b58c 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -257,6 +257,10 @@ function notifier_run($argv, $argc){
return;
}
+ if($target_item['item_restrict'] & ITEM_PDL) {
+ logger('notifier: target item ITEM_PDL', LOGGER_DEBUG);
+ return;
+ }
$s = q("select * from channel where channel_id = %d limit 1",
intval($target_item['uid'])
diff --git a/include/onepoll.php b/include/onepoll.php
index a225edfd8..50c2566be 100644
--- a/include/onepoll.php
+++ b/include/onepoll.php
@@ -69,7 +69,7 @@ function onepoll_run($argv, $argc){
$last_update = (($contact['abook_updated'] === '0000-00-00 00:00:00')
? datetime_convert('UTC','UTC','now - 7 days')
- : datetime_convert('UTC','UTC',$contact['abook_updated'])
+ : datetime_convert('UTC','UTC',$contact['abook_updated'] . ' - 2 days')
);
// update permissions
@@ -98,11 +98,12 @@ function onepoll_run($argv, $argc){
return;
if($contact['xchan_connurl']) {
- $feedurl = str_replace('/poco/','/zotfeed/',$channel['xchan_connurl']);
-
- $x = z_fetch_url($feedurl . '?f=$mindate=' . $last_update);
+ $feedurl = str_replace('/poco/','/zotfeed/',$channel['xchan_connurl']);
+ $x = z_fetch_url($feedurl . '?f=&mindate=' . $last_update);
if($x['success']) {
$total = 0;
+ logger('onepoll: feed update ' . $contact['xchan_name']);
+
$j = json_decode($x['body'],true);
if($j['success'] && $j['messages']) {
foreach($j['messages'] as $message) {
diff --git a/include/poller.php b/include/poller.php
index 7a6aaeb22..bdb0388ac 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -224,7 +224,7 @@ function poller_run($argv, $argc){
$update = true;
}
}
-dbg(0);
+
if((! $update) && (! $force))
continue;
diff --git a/include/text.php b/include/text.php
index 99d5c9d78..606ef421c 100755
--- a/include/text.php
+++ b/include/text.php
@@ -81,6 +81,34 @@ function escape_tags($string) {
}
+function z_input_filter($channel_id,$s,$type = 'text/bbcode') {
+
+ if($type === 'text/bbcode')
+ return escape_tags($s);
+ if($type === 'text/markdown')
+ return escape_tags($s);
+ if($type == 'text/plain')
+ return escape_tags($s);
+ $r = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1",
+ intval($channel_id)
+ );
+ if($r && ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWEXEC)) {
+ if(local_user() && (get_account_id() == $r[0]['account_id'])) {
+ return $s;
+ }
+ }
+
+ if($type === 'text/html')
+ return purify_html($s);
+
+ return escape_tags($s);
+
+}
+
+
+
+
+
function purify_html($s) {
require_once('library/HTMLPurifier.auto.php');
require_once('include/html2bbcode.php');
@@ -1127,6 +1155,7 @@ function prepare_body(&$item,$attach = false) {
function prepare_text($text,$content_type = 'text/bbcode') {
+
switch($content_type) {
case 'text/plain':
@@ -1291,6 +1320,37 @@ function unamp($s) {
}
+function mimetype_select($channel_id, $current = 'text/bbcode') {
+
+ $x = array(
+ 'text/bbcode',
+ 'text/html',
+ 'text/markdown',
+ 'text/plain'
+ );
+
+ $r = q("select account_flags from account left join channel on account_id = channel_account_id where
+ channel_id = %d limit 1",
+ intval($channel_id)
+ );
+
+ if($r) {
+ if($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) {
+ $x[] = 'application/x-php';
+ }
+ }
+
+ $o = t('Page content type: ');
+ $o .= '<select name="mimetype" id="mimetype-select">';
+ foreach($x as $y) {
+ $select = (($y == $current) ? ' selected="selected" ' : '');
+ $o .= '<option name="' . $y . '"' . $select . '>' . $y . '</option>';
+ }
+ $o .= '</select>';
+
+ return $o;
+
+}
diff --git a/include/zot.php b/include/zot.php
index bddbc9bee..49f58c3bd 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -138,7 +138,7 @@ function zot_finger($webbie,$channel) {
$r = q("select xchan.*, hubloc.* from xchan
left join hubloc on xchan_hash = hubloc_hash
where xchan_addr = '%s' and (hubloc_flags & %d) limit 1",
- dbesc($xchan_address),
+ dbesc($xchan_addr),
intval(HUBLOC_FLAGS_PRIMARY)
);
@@ -441,6 +441,11 @@ function import_xchan($arr) {
dbesc($xchan_hash)
);
+ if(! array_key_exists('connect_url', $arr))
+ $arr['connect_url'] = '';
+
+ if(strpos($arr['address'],'/') !== false)
+ $arr['address'] = substr($arr['address'],0,strpos($arr['address'],'/'));
if($r) {
if($r[0]['xchan_photo_date'] != $arr['photo_updated'])
@@ -462,18 +467,23 @@ function import_xchan($arr) {
$new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_HIDDEN;
else
$new_flags = $r[0]['xchan_flags'];
-
-
+
+
if(($r[0]['xchan_name_date'] != $arr['name_updated'])
|| ($r[0]['xchan_connurl'] != $arr['connections_url'])
|| ($r[0]['xchan_flags'] != $new_flags)
|| ($r[0]['xchan_addr'] != $arr['address'])
+ || ($r[0]['xchan_follow'] != $arr['follow_url'])
+ || ($r[0]['xchan_connpage'] != $arr['connect_url'])
|| ($r[0]['xchan_url'] != $arr['url'])) {
- $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_flags = %d,
+ $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s',
+ xchan_connpage = '%s', xchan_flags = %d,
xchan_addr = '%s', xchan_url = '%s' where xchan_hash = '%s' limit 1",
dbesc($arr['name']),
dbesc($arr['name_updated']),
dbesc($arr['connections_url']),
+ dbesc($arr['follow_url']),
+ dbesc($arr['connect_url']),
intval($new_flags),
dbesc($arr['address']),
dbesc($arr['url']),
@@ -503,8 +513,8 @@ function import_xchan($arr) {
$new_flags = 0;
$x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype,
- xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags)
- values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ",
+ xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags)
+ values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ",
dbesc($xchan_hash),
dbesc($arr['guid']),
dbesc($arr['guid_sig']),
@@ -514,6 +524,8 @@ function import_xchan($arr) {
dbesc($arr['address']),
dbesc($arr['url']),
dbesc($arr['connections_url']),
+ dbesc($arr['follow_url']),
+ dbesc($arr['connect_url']),
dbesc($arr['name']),
dbesc('zot'),
dbesc($arr['photo_updated']),
@@ -577,10 +589,16 @@ function import_xchan($arr) {
);
if($r) {
logger('import_xchan: hub exists: ' . $location['url']);
+ // update connection timestamp
+ q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d limit 1",
+ dbesc(datetime_convert()),
+ intval($r[0]['hubloc_id'])
+ );
if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary']))
|| ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary']))) {
- $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_id = %d limit 1",
+ $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d), hubloc_updated = '%s' where hubloc_id = %d limit 1",
intval(HUBLOC_FLAGS_PRIMARY),
+ dbesc(datetime_convert()),
intval($r[0]['hubloc_id'])
);
update_modtime($xchan_hash);
@@ -594,18 +612,22 @@ function import_xchan($arr) {
continue;
}
+ if(strpos($location['address'],'/') !== false)
+ $location['address'] = substr($location['address'],0,strpos($location['address'],'/'));
+
// new hub claiming to be primary. Make it so.
if(intval($location['primary'])) {
- $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_hash = '%s' and (hubloc_flags & %d )",
+ $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d), hubloc_updated = '%s' where hubloc_hash = '%s' and (hubloc_flags & %d )",
intval(HUBLOC_FLAGS_PRIMARY),
+ dbesc(datetime_convert()),
dbesc($xchan_hash),
intval(HUBLOC_FLAGS_PRIMARY)
);
}
logger('import_xchan: new hub: ' . $location['url']);
- $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey)
- values ( '%s','%s','%s','%s', %d ,'%s','%s','%s','%s','%s')",
+ $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_updated, hubloc_connected)
+ values ( '%s','%s','%s','%s', %d ,'%s','%s','%s','%s','%s','%s','%s')",
dbesc($arr['guid']),
dbesc($arr['guid_sig']),
dbesc($xchan_hash),
@@ -615,7 +637,9 @@ function import_xchan($arr) {
dbesc($location['url_sig']),
dbesc($location['host']),
dbesc($location['callback']),
- dbesc($location['sitekey'])
+ dbesc($location['sitekey']),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert())
);
update_modtime($xchan_hash);
$changed = true;
@@ -829,6 +853,7 @@ function zot_import($arr) {
// and who are allowed to see them based on the sender's permissions
$deliveries = allowed_public_recips($i);
+
}
if(! $deliveries) {
logger('zot_import: no deliveries on this site');
@@ -901,10 +926,12 @@ function zot_import($arr) {
function public_recips($msg) {
+ $check_mentions = false;
if($msg['message']['type'] === 'activity') {
if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) {
$col = 'channel_w_stream';
$field = PERMS_W_STREAM;
+ $check_mentions = true;
}
else {
$col = 'channel_w_comment';
@@ -919,6 +946,7 @@ function public_recips($msg) {
if(! $col)
return NULL;
+
if($msg['notify']['sender']['url'] === z_root())
$sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_SITE . " )) ";
else
@@ -938,6 +966,27 @@ function public_recips($msg) {
$x = array();
$r = array_merge($r,$x);
+
+ // look for any public mentions on this site
+ // They will get filtered by tgroup_check() so we don't need to check permissions now
+
+ if($check_mentions && $msg['message']['tags']) {
+ if(is_array($msg['message']['tags']) && $msg['message']['tags']) {
+ foreach($msg['message']['tags'] as $tag) {
+ if(($tag['type'] === 'mention') && (strpos($tag['url'],z_root()) !== false)) {
+ $address = basename($tag['url']);
+ if($address) {
+ $z = q("select channel_hash as hash from channel where channel_address = '%s' limit 1",
+ dbesc($address)
+ );
+ if($z)
+ $r = array_merge($r,$z);
+ }
+ }
+ }
+ }
+ }
+
logger('public_recips: ' . print_r($r,true), LOGGER_DATA);
return $r;
}
@@ -1675,7 +1724,7 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) {
$clean = array();
foreach($arr['abook'] as $abook) {
foreach($abook as $k => $v) {
- if(in_array($k,$disallowed))
+ if(in_array($k,$disallowed) || (strpos($k,'abook') !== 0))
continue;
$clean[$k] = $v;
}