aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/channel.php2
-rw-r--r--include/follow.php8
-rw-r--r--include/nav.php4
-rw-r--r--include/network.php21
-rw-r--r--include/queue_fn.php6
-rw-r--r--include/security.php9
-rw-r--r--include/taxonomy.php75
-rw-r--r--include/text.php21
-rw-r--r--include/zot.php11
9 files changed, 127 insertions, 30 deletions
diff --git a/include/channel.php b/include/channel.php
index 5f87e587c..4bf490bf0 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -2563,7 +2563,7 @@ function channel_remove($channel_id, $local = true, $unset_session = false) {
q("DELETE FROM photo WHERE uid = %d", intval($channel_id));
q("DELETE FROM attach WHERE uid = %d", intval($channel_id));
q("DELETE FROM profile WHERE uid = %d", intval($channel_id));
- q("DELETE FROM src WHERE src_channel_id = %d", intval($channel_id));
+ q("DELETE FROM source WHERE src_channel_id = %d", intval($channel_id));
$r = q("select hash FROM attach WHERE uid = %d", intval($channel_id));
if($r) {
diff --git a/include/follow.php b/include/follow.php
index a63fe66ea..d803afa3f 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -150,9 +150,9 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
// attempt network auto-discovery
- $d = discover_by_webbie($url,$protocol);
+ $wf = discover_by_webbie($url,$protocol);
- if((! $d) && ($is_http)) {
+ if((! $wf) && ($is_http)) {
// try RSS discovery
@@ -167,9 +167,9 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false)
}
}
- if($d) {
+ if($wf || $d) {
$r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1",
- dbesc($url),
+ dbesc(($wf) ? $wf : $url),
dbesc($url)
);
}
diff --git a/include/nav.php b/include/nav.php
index df58ee96f..a443c58ff 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -176,7 +176,7 @@ EOT;
$nav['help'] = [$help_url, t('Help'), "", t('Help and documentation'), 'help_nav_btn', $context_help, $enable_context_help];
}
- $nav['search'] = ['search', t('Search'), "", t('Search site @name, #tag, ?docs, content')];
+ $nav['search'] = ['search', t('Search'), "", t('Search site @name, !forum, #tag, ?docs, content')];
/**
@@ -287,7 +287,7 @@ EOT;
'$is_owner' => $is_owner,
'$sel' => App::$nav_sel,
'$powered_by' => $powered_by,
- '$help' => t('@name, #tag, ?doc, content'),
+ '$help' => t('@name, !forum, #tag, ?doc, content'),
'$pleasewait' => t('Please wait...'),
'$nav_apps' => $nav_apps,
'$navbar_apps' => $navbar_apps,
diff --git a/include/network.php b/include/network.php
index db9a7d00a..c41d87af0 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1192,9 +1192,10 @@ function discover_by_webbie($webbie, $protocol = '') {
logger('webfinger: ' . print_r($x,true), LOGGER_DATA, LOG_INFO);
$arr = [
- 'address' => $webbie,
- 'protocol' => $protocol,
- 'success' => false,
+ 'address' => $webbie,
+ 'protocol' => $protocol,
+ 'success' => false,
+ 'xchan' => '',
'webfinger' => $x
];
/**
@@ -1207,7 +1208,7 @@ function discover_by_webbie($webbie, $protocol = '') {
*/
call_hooks('discover_channel_webfinger', $arr);
if($arr['success'])
- return true;
+ return $arr['xchan'];
return false;
}
@@ -1240,16 +1241,9 @@ function webfinger_rfc7033($webbie, $zot = false) {
}
logger('fetching url from resource: ' . $rhs . ':' . $webbie);
- // The default curl Accept: header is */*, which is incorrectly handled by Mastodon servers
- // and results in a 406 (Not Acceptable) response, and will also incorrectly produce an XML
- // document if you use 'application/jrd+json, */*'. We could set this to application/jrd+json,
- // but some test webfinger servers may not explicitly set the content type and they would be
- // blocked. The best compromise until Mastodon is fixed is to remove the Accept header which is
- // accomplished by setting it to nothing.
-
$counter = 0;
$s = z_fetch_url('https://' . $rhs . '/.well-known/webfinger?f=&resource=' . $resource . (($zot) ? '&zot=1' : ''),
- false, $counter, [ 'headers' => [ 'Accept:' ] ]);
+ false, $counter, [ 'headers' => [ 'Accept: application/jrd+json, */*' ] ]);
if($s['success']) {
$j = json_decode($s['body'], true);
@@ -1845,7 +1839,8 @@ function z_mail($params) {
$messageHeader =
$params['additionalMailHeader'] .
"From: $fromName <{$params['fromEmail']}>\n" .
- "Reply-To: $fromName <{$params['replyTo']}>";
+ "Reply-To: $fromName <{$params['replyTo']}>\n" .
+ "Content-Type: text/plain; charset=UTF-8";
// send the message
$res = mail(
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 798ac36db..f05bac5b0 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -95,6 +95,12 @@ function queue_set_delivered($id,$channel = 0) {
function queue_insert($arr) {
+ // do not queue anything with no destination
+
+ if(! (array_key_exists('posturl',$arr) && trim($arr['posturl']))) {
+ return false;
+ }
+
$x = q("insert into outq ( outq_hash, outq_account, outq_channel, outq_driver, outq_posturl, outq_async, outq_priority,
outq_created, outq_updated, outq_scheduled, outq_notify, outq_msg )
values ( '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s' )",
diff --git a/include/security.php b/include/security.php
index 8b7e7d076..19278d5cb 100644
--- a/include/security.php
+++ b/include/security.php
@@ -266,6 +266,15 @@ function change_channel($change_channel) {
$_SESSION['mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme');
$_SESSION['cloud_tiles'] = get_pconfig(local_channel(),'system', 'cloud_tiles');
date_default_timezone_set($r[0]['channel_timezone']);
+
+ // Update the active timestamp at most once a day
+
+ if(substr($r[0]['channel_active'],0,10) !== substr(datetime_convert(),0,10)) {
+ $z = q("UPDATE channel SET channel_active = '%s' WHERE channel_id = %d",
+ dbesc(datetime_convert()),
+ intval($r[0]['channel_id'])
+ );
+ }
$ret = $r[0];
}
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
diff --git a/include/taxonomy.php b/include/taxonomy.php
index d9bf3ecc4..e8d33986f 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -174,8 +174,7 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re
if(! is_array($authors))
$authors = array($authors);
- stringify_array_elms($authors,true);
- $sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
+ $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") ";
}
if($owner) {
@@ -227,8 +226,7 @@ function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0
if(! is_array($authors))
$authors = array($authors);
- stringify_array_elms($authors,true);
- $sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
+ $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") ";
}
if($owner) {
@@ -280,8 +278,7 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
if(! is_array($authors))
$authors = array($authors);
- stringify_array_elms($authors,true);
- $sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
+ $sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") ";
}
if($owner) {
@@ -312,6 +309,69 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
+function pubtagblock($net,$site,$limit,$recent = 0,$safemode = 1, $type = TERM_HASHTAG) {
+ $o = '';
+
+ $r = pub_tagadelic($net,$site,$limit,$since,$safemode,$type);
+ $link = z_root() . '/pubstream';
+
+ if($r) {
+ $o = '<div class="tagblock widget"><h3>' . (($recent) ? t('Trending') : t('Tags')) . '</h3><div class="tags" align="center">';
+ foreach($r as $rr) {
+ $o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
+ }
+ $o .= '</div></div>';
+ }
+
+ return $o;
+}
+
+function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) {
+
+
+ $item_normal = item_normal();
+ $count = intval($limit);
+
+ if($site) {
+ $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 ";
+ }
+ else {
+ $sys = get_sys_channel();
+ $uids = " and item.uid = " . intval($sys['channel_id']) . " ";
+ $sql_extra = " and item_private = 0 ";
+ }
+
+ if($recent)
+ $sql_extra .= " and item.created > '" . datetime_convert('UTC','UTC', 'now - ' . intval($recent) . ' days ') . "' ";
+
+
+ if($safemode) {
+ $unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]);
+ if($unsafetags) {
+ $sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") ";
+ }
+ }
+
+
+ // Fetch tags
+ $r = q("select term, count(term) as total from term left join item on term.oid = item.id
+ where term.ttype = %d
+ and otype = %d and item_type = %d
+ $sql_extra $uids $item_normal
+ group by term order by total desc %s",
+ intval($type),
+ intval(TERM_OBJ_POST),
+ intval(ITEM_TYPE_POST),
+ ((intval($count)) ? "limit $count" : '')
+ );
+
+ if(! $r)
+ return array();
+
+ return Zotlabs\Text\Tagadelic::calc($r);
+
+}
+
function dir_tagadelic($count = 0, $hub = '') {
@@ -557,9 +617,8 @@ function get_things($profile_hash,$uid) {
if(! in_array($rr['obj_obj'],$profile_hashes))
$profile_hashes[] = $rr['obj_obj'];
}
- stringify_array_elms($profile_hashes);
if(! $profile_hash) {
- $exp = explode(',',$profile_hashes);
+ $exp = stringify_array($profile_hashes,true);
$p = q("select profile_guid as hash, profile_name as name from profile where profile_guid in ( $exp ) ");
if($p) {
foreach($r as $rr) {
diff --git a/include/text.php b/include/text.php
index 13c4bb819..55fc49560 100644
--- a/include/text.php
+++ b/include/text.php
@@ -531,7 +531,7 @@ function paginate(&$a) {
}
-function alt_pager(&$a, $i, $more = '', $less = '') {
+function alt_pager($i, $more = '', $less = '') {
if(! $more)
$more = t('older');
@@ -2324,6 +2324,23 @@ function stringify_array_elms(&$arr, $escape = false) {
$arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'";
}
+
+/**
+ * @brief Similar to stringify_array_elms but returns a string. If $escape is true, dbesc() each element before adding quotes.
+ *
+ * @param array $arr
+ * @param boolean $escape (optional) default false
+ * @return string
+ */
+function stringify_array($arr, $escape = false) {
+ if($arr) {
+ stringify_array_elms($arr);
+ return(implode(',',$arr));
+ }
+ return EMPTY_STR;
+}
+
+
/**
* @brief Indents a flat JSON string to make it more human-readable.
*
@@ -2387,7 +2404,7 @@ function jindent($json) {
*/
function design_tools() {
- $channel = App::get_channel();
+ $channel = channelx_by_n(App::$profile['profile_uid']);
$sys = false;
if(App::$is_sys && is_site_admin()) {
diff --git a/include/zot.php b/include/zot.php
index 2ad43f0e5..c2b622277 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3208,6 +3208,9 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
$channel = $r[0];
+ // don't provide these in the export
+
+ unset($channel['channel_active']);
unset($channel['channel_password']);
unset($channel['channel_salt']);
@@ -3474,6 +3477,14 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
continue;
}
+ // if the clone is active, so are we
+
+ if(substr($channel['channel_active'],0,10) !== substr(datetime_convert(),0,10)) {
+ q("UPDATE channel set channel_active = '%s' where channel_id = %d",
+ dbesc(datetime_convert()),
+ intval($channel['channel_id'])
+ );
+ }
if(array_key_exists('config',$arr) && is_array($arr['config']) && count($arr['config'])) {
foreach($arr['config'] as $cat => $k) {