aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php67
1 files changed, 54 insertions, 13 deletions
diff --git a/include/text.php b/include/text.php
index c2a45814c..d6b196f1e 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1801,7 +1801,7 @@ function prepare_body(&$item,$attach = false,$opts = false) {
$tags = format_hashtags($item);
- if($item['resource_type'])
+ if($item['resource_type'] == 'photo')
$mentions = format_mentions($item);
$categories = format_categories($item,$writeable);
@@ -2795,7 +2795,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
$termtype = ((strpos($tag,'#') === 0) ? TERM_HASHTAG : TERM_UNKNOWN);
$termtype = ((strpos($tag,'@') === 0) ? TERM_MENTION : $termtype);
- $termtype = ((strpos($tag,'!') === 0) ? TERM_FORUM : $termtype);
+// $termtype = ((strpos($tag,'!') === 0) ? TERM_FORUM : $termtype);
$termtype = ((strpos($tag,'#^[') === 0) ? TERM_BOOKMARK : $termtype);
// Is it a hashtag of some kind?
@@ -2864,7 +2864,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
if ( in_array($termtype, [ TERM_MENTION, TERM_FORUM ] )) {
- // The @! tag and !! tag will alter permissions
+ // The @! tag will alter permissions
// $in_network is set to false to avoid false positives on posts originating
// on a network which does not implement privacy tags or implements them differently.
@@ -2966,12 +2966,13 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
//create profile link
$profile = str_replace(',','%2c',$profile);
$url = $profile;
+/*
if($termtype === TERM_FORUM) {
$newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
$body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
}
- else {
- // ( $termtype === TERM_MENTION )
+*/
+ if ($termtype === TERM_MENTION) {
$newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
$body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
}
@@ -2983,7 +2984,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
$str_tags .= $newtag;
}
}
-
+
$fn_results[] = [
'replaced' => $replaced,
@@ -3032,12 +3033,13 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
//create profile link
$profile = str_replace(',','%2c',$profile);
$url = $profile;
+/*
if($termtype === TERM_FORUM) {
$newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
$body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
}
- else {
- // ( $termtype === TERM_MENTION )
+*/
+ if ($termtype === TERM_MENTION) {
$newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]';
$body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
}
@@ -3060,7 +3062,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true)
];
}
}
-
+
return $fn_results;
}
@@ -3098,7 +3100,7 @@ function linkify_tags(&$body, $uid, $in_network = true) {
function getIconFromType($type) {
$iconMap = array(
//Folder
- t('Collection') => 'fa-folder-o',
+ 'Collection' => 'fa-folder-o',
'multipart/mixed' => 'fa-folder-o', //dirs in attach use this mime type
//Common file
'application/octet-stream' => 'fa-file-o',
@@ -3242,7 +3244,7 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') {
if($oldnick)
json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['target']);
}
-
+
$item['body'] = preg_replace("/(\[zrl=".preg_quote($old,'/')."\/(photo|photos|gallery)\/".$channel['channel_address'].".+\]\[zmg=\d+x\d+\])".preg_quote($old,'/')."\/(.+\[\/zmg\])/", '${1}'.$new.'/${3}', $item['body']);
$item['body'] = preg_replace("/".preg_quote($old,'/')."\/(search|\w+\/".$channel['channel_address'].")/", $new.'/${1}', $item['body']);
@@ -3575,7 +3577,7 @@ function cleanup_bbcode($body) {
$body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','\red_unescape_codeblock',$body);
$body = preg_replace_callback('/\[\$b64code(.*?)\[\/(code)\]/ism','\red_unescape_codeblock',$body);
$body = preg_replace_callback('/\[\$b64svg(.*?)\[\/(svg)\]/ism','\red_unescape_codeblock',$body);
-
+
// fix any img tags that should be zmg
$body = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','\red_zrlify_img_callback',$body);
@@ -3690,6 +3692,11 @@ function get_forum_channels($uid) {
);
if($x1) {
+
+ $x2 = [];
+ $x3 = [];
+ $x4 = [];
+
$xc = ids_to_querystr($x1,'xchan',true);
$x2 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'tag_deliver' and v = '1' and xchan in (" . $xc . ") ",
@@ -3706,6 +3713,15 @@ function get_forum_channels($uid) {
if($x3) {
$xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true);
}
+
+ // public forums with no permission to post
+ $x4 = q("select xchan from abconfig left join xchan on xchan = xchan_hash where chan = %d and cat = 'their_perms' and k in ('post_wall', 'tag_deliver') and v = '0' and xchan in (" . $xc . ") and xchan_pubforum = 1 $sql_extra ",
+ intval(local_channel())
+ );
+ if($x4) {
+ $xf = ids_to_querystr(array_merge($x2,$x3,$x4),'xchan',true);
+ }
+
}
$sql_extra_1 = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 ");
@@ -3722,6 +3738,15 @@ function get_forum_channels($uid) {
}
}
}
+
+ if($x4) {
+ foreach($x4 as $xx) {
+ if($r[$x]['xchan_hash'] == $xx['xchan']) {
+ $r[$x]['no_post_perms'] = 1;
+ }
+ }
+ }
+
}
App::$data['forum_channels'] = $r;
@@ -3791,7 +3816,7 @@ function array_path_exists($str,$arr) {
/**
- * @brief Generate a unique ID.
+ * @brief Generate a random v4 UUID.
*
* @return string
*/
@@ -3807,6 +3832,22 @@ function new_uuid() {
}
+/**
+ * @brief Generate a name-based v5 UUID in the URL namespace
+ *
+ * @param string $url
+ * @return string
+ */
+function uuid_from_url($url) {
+
+ try {
+ $hash = Uuid::uuid5(Uuid::NAMESPACE_URL, $url)->toString();
+ } catch (UnsatisfiedDependencyException $e) {
+ $hash = md5($url);
+ }
+ return $hash;
+}
+
function svg2bb($s) {
$s = preg_replace("/\<text (.*?)\>(.*?)\<(.*?)\<\/text\>/", '<text $1>$2&lt;$3</text>', $s);