diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 4 | ||||
-rw-r--r-- | include/channel.php | 16 | ||||
-rw-r--r-- | include/conversation.php | 6 | ||||
-rw-r--r-- | include/event.php | 124 | ||||
-rw-r--r-- | include/help.php | 9 | ||||
-rw-r--r-- | include/items.php | 3 | ||||
-rw-r--r-- | include/language.php | 62 | ||||
-rw-r--r-- | include/nav.php | 29 | ||||
-rw-r--r-- | include/network.php | 15 | ||||
-rw-r--r-- | include/plugin.php | 16 | ||||
-rw-r--r-- | include/text.php | 17 |
11 files changed, 189 insertions, 112 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 735f267c3..e0a0fe9a1 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1446,14 +1446,14 @@ function bbcode($Text, $options = []) { ((strpos($Text, "[/ul]") !== false) && (strpos($Text, "[ul]") !== false)) || ((strpos($Text, "[/dl]") !== false) && (strpos($Text, "[dl") !== false)) || ((strpos($Text, "[/li]") !== false) && (strpos($Text, "[li]") !== false))) && (++$endlessloop < 20)) { - $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>', $Text); + $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet">$1</ul>', $Text); $Text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '<ul class="listnone" style="list-style-type: none;">$1</ul>', $Text); $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>', $Text); $Text = preg_replace("/\[list=((?-i)i)\](.*?)\[\/list\]/ism",'<ul class="listlowerroman" style="list-style-type: lower-roman;">$2</ul>', $Text); $Text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '<ul class="listupperroman" style="list-style-type: upper-roman;">$2</ul>', $Text); $Text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '<ul class="listloweralpha" style="list-style-type: lower-alpha;">$2</ul>', $Text); $Text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '<ul class="listupperalpha" style="list-style-type: upper-alpha;">$2</ul>', $Text); - $Text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '<ul class="listbullet" style="list-style-type: circle;">$1</ul>', $Text); + $Text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '<ul class="listbullet">$1</ul>', $Text); $Text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '<ul class="listdecimal" style="list-style-type: decimal;">$1</ul>', $Text); $Text = preg_replace("/\[\/li\]<br \/>\[li\]/ism",'[/li][li]',$Text); $Text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '<li>$1</li>', $Text); diff --git a/include/channel.php b/include/channel.php index 2e8aefaaa..640274348 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1937,7 +1937,7 @@ function zid_init() { call_hooks('zid_init', $arr); if(! local_channel()) { - $r = q("select hubloc_url, hubloc_hash, hubloc_network from hubloc where hubloc_addr = '%s' order by hubloc_connected desc", + $r = q("select hubloc_url, hubloc_hash, hubloc_network from hubloc where hubloc_addr = '%s' and hubloc_deleted = 0 order by hubloc_id desc", dbesc($tmp_str) ); if(! $r) { @@ -2397,8 +2397,11 @@ function get_zcard($channel, $observer_hash = '', $args = array()) { // $scale = (float) $maxwidth / $width; // $translate = intval(($scale / 1.0) * 100); - $channel['channel_addr'] = channel_reddress($channel); - $zcard = array('chan' => $channel); + $zcard['chan'] = [ + 'xchan_name' => $channel['xchan_name'], + 'xchan_url' => $channel['xchan_url'], + 'xchan_addr' => $channel['xchan_addr'] + ]; $r = q("select height, width, resource_id, imgscale, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d", intval($channel['channel_id']), @@ -2470,8 +2473,11 @@ function get_zcard_embed($channel, $observer_hash = '', $args = array()) { $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); } - $channel['channel_addr'] = channel_reddress($channel); - $zcard = array('chan' => $channel); + $zcard['chan'] = [ + 'xchan_name' => $channel['xchan_name'], + 'xchan_url' => $channel['xchan_url'], + 'xchan_addr' => $channel['xchan_addr'] + ]; $r = q("select height, width, resource_id, imgscale, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d", intval($channel['channel_id']), diff --git a/include/conversation.php b/include/conversation.php index 5e63c4199..f8d5f7ec0 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1306,11 +1306,11 @@ function format_like($cnt, $arr, $type, $id) { /** * Wrapper to allow addons to replace the status editor if desired. */ -function status_editor($a, $x, $popup = false, $module='') { +function status_editor($x, $popup = false, $module='') { $hook_info = ['editor_html' => '', 'x' => $x, 'popup' => $popup, 'module' => $module]; call_hooks('status_editor',$hook_info); if ($hook_info['editor_html'] == '') { - return hz_status_editor($a, $x, $popup); + return hz_status_editor($x, $popup); } else { return $hook_info['editor_html']; } @@ -1322,7 +1322,7 @@ function status_editor($a, $x, $popup = false, $module='') { * They are referring to the content editor or components thereof. */ -function hz_status_editor($a, $x, $popup = false) { +function hz_status_editor($x, $popup = false) { $o = ''; diff --git a/include/event.php b/include/event.php index 894a1e4f7..745469064 100644 --- a/include/event.php +++ b/include/event.php @@ -9,6 +9,7 @@ use Sabre\VObject; use Zotlabs\Lib\Activity; use Zotlabs\Lib\Libsync; +use Zotlabs\Access\AccessList; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; @@ -718,56 +719,95 @@ function event_addtocal($item_id, $uid) { $item = $r[0]; - $ev = bbtoevent($r[0]['body']); + $ev = parse_event_object($item['obj']); - if(x($ev,'summary') && x($ev,'dtstart')) { - $ev['event_xchan'] = $item['author_xchan']; - $ev['uid'] = $channel['channel_id']; - $ev['account'] = $channel['channel_account_id']; - $ev['edited'] = $item['edited']; - $ev['mid'] = $item['mid']; - $ev['private'] = $item['item_private']; + // if we could not parse the object, parse try to parse the body bbcode + if (!$ev) { + $ev = bbtoevent($item['body']); + } - // is this an edit? + if (!$ev) { + return false; + } - if($item['resource_type'] === 'event' && (! $ev['event_hash'])) { - $ev['event_hash'] = $item['resource_id']; - } + $ev['event_xchan'] = $item['author_xchan']; + $ev['uid'] = $channel['channel_id']; + $ev['account'] = $channel['channel_account_id']; + $ev['edited'] = $item['edited']; + $ev['mid'] = $item['mid']; + $ev['private'] = $item['item_private']; - if($ev['private']) - $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>'; - else { - $acl = new Zotlabs\Access\AccessList($channel); - $x = $acl->get(); - $ev['allow_cid'] = $x['allow_cid']; - $ev['allow_gid'] = $x['allow_gid']; - $ev['deny_cid'] = $x['deny_cid']; - $ev['deny_gid'] = $x['deny_gid']; - } + if($item['resource_type'] === 'event' && (! $ev['event_hash'])) { + $ev['event_hash'] = $item['resource_id']; + } - $event = event_store_event($ev); - if($event) { - $r = q("update item set resource_id = '%s', resource_type = 'event' where id = %d and uid = %d", - dbesc($event['event_hash']), - intval($item['id']), - intval($channel['channel_id']) - ); + if($ev['private']) { + $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>'; + $ev['allow_gid'] = ''; + $ev['deny_cid'] = ''; + $ev['deny_gid'] = ''; + } + else { + $acl = new AccessList($channel); + $x = $acl->get(); + $ev['allow_cid'] = $x['allow_cid']; + $ev['allow_gid'] = $x['allow_gid']; + $ev['deny_cid'] = $x['deny_cid']; + $ev['deny_gid'] = $x['deny_gid']; + } - $item['resource_id'] = $event['event_hash']; - $item['resource_type'] = 'event'; + $event = event_store_event($ev); + if($event) { + $r = q("update item set resource_id = '%s', resource_type = 'event' where id = %d and uid = %d", + dbesc($event['event_hash']), + intval($item['id']), + intval($channel['channel_id']) + ); - $i = array($item); - xchan_query($i); - $sync_item = fetch_post_tags($i); - $z = q("select * from event where event_hash = '%s' and uid = %d limit 1", - dbesc($event['event_hash']), - intval($channel['channel_id']) - ); - if($z) { - Libsync::build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); - } - return true; + $item['resource_id'] = $event['event_hash']; + $item['resource_type'] = 'event'; + + $i = [$item]; + + xchan_query($i); + $sync_item = fetch_post_tags($i); + + $z = q("select * from event where event_hash = '%s' and uid = %d limit 1", + dbesc($event['event_hash']), + intval($channel['channel_id']) + ); + + if($z) { + libsync::build_sync_packet($channel['channel_id'], ['event_item' => [encode_item($sync_item[0], true)], 'event' => $z]); } + + return true; + } + +} + +function parse_event_object($event_object_json) { + + $object = json_decode($event_object_json, true); + + $tz = $object['timezone'] ?? 'UTC'; + + $ev['summary'] = $object['summary'] ?? $object['name'] ?? ''; + $ev['description'] = html2bbcode($content['content']) ?? ''; + $ev['dtstart'] = $object['startTime'] ? datetime_convert('UTC', 'UTC', $object['startTime']) : ''; + $ev['dtend'] = $object['endTime'] ? datetime_convert('UTC', 'UTC', $object['endTime']) : $ev['dtstart']; + $ev['location'] = $object['location']['name'] ?? ''; + $ev['event_hash'] = $object['uuid'] ?? $object['diaspora:guid'] ?? uuid_from_url($object['id']); + $ev['timezone'] = $tz; + $ev['adjust'] = (strpos($object['startTime'], 'Z') !== false || !empty($object['dfrn:adjust']) || $tz !== 'UTC'); + + $ev['nofinish'] = 0; + if($ev['dtend'] === $ev['dtstart']) { + $ev['nofinish'] = 1; + } + + if ($ev['summary'] && $ev['dtstart']) { + return $ev; } return false; diff --git a/include/help.php b/include/help.php index 8a913578a..9e4be57f9 100644 --- a/include/help.php +++ b/include/help.php @@ -1,6 +1,7 @@ <?php use \Michelf\MarkdownExtra; +use CommerceGuys\Intl\Language\LanguageRepository; require_once('include/items.php'); @@ -183,11 +184,11 @@ function preg_callback_help_include($matches) { * * \e boolean \b from_url - true if language from URL overrides browser default */ function determine_help_language() { - $lang_detect = new Text_LanguageDetect(); - // Set this mode to recognize language by the short code like "en", "ru", etc. - $lang_detect->setNameMode(2); - if($lang_detect->languageExists(argv(1))) { + $language_repository = new LanguageRepository; + $languages = $language_repository->getList(); + + if(array_key_exists(argv(1), $languages)) { $lang = argv(1); $from_url = true; } else { diff --git a/include/items.php b/include/items.php index 57e5dbb96..6cef3d2cd 100644 --- a/include/items.php +++ b/include/items.php @@ -353,12 +353,13 @@ function can_comment_on_post($observer_xchan, $item) { case 'specific': case 'contacts': case '': - if(local_channel() && get_abconfig(local_channel(),$item['owner_xchan'],'their_perms','post_comments')) { + if(local_channel() && get_abconfig(local_channel(), (($item['verb'] === ACTIVITY_SHARE) ? $item['author_xchan'] : $item['owner_xchan']), 'their_perms', 'post_comments')) { return true; } if(intval($item['item_wall']) && perm_is_allowed($item['uid'],$observer_xchan,'post_comments')) { return true; } + break; default: diff --git a/include/language.php b/include/language.php index e7363cffb..1b2e7332e 100644 --- a/include/language.php +++ b/include/language.php @@ -9,6 +9,7 @@ */ use CommerceGuys\Intl\Language\LanguageRepository; +use LanguageDetection\Language; /** * @brief Get the browser's submitted preferred languages. @@ -299,14 +300,10 @@ function string_plural_select_default($n) { /** * @brief Takes a string and tries to identify the language. * - * It uses the pear library Text_LanguageDetect and it can identify 52 human languages. - * It returns the identified languges and a confidence score for each. - * * Strings need to have a min length config['system']['language_detect_min_length'] * and you can influence the confidence that must be met before a result will get * returned through config['system']['language_detect_min_confidence']. * - * @see http://pear.php.net/package/Text_LanguageDetect * @param string $s A string to examine * @return string Language code in 2-letter ISO 639-1 (en, de, fr) format */ @@ -316,43 +313,35 @@ function detect_language($s) { return EMPTY_STR; } - $min_length = get_config('system', 'language_detect_min_length'); - if ($min_length === false) - $min_length = LANGUAGE_DETECT_MIN_LENGTH; - - $min_confidence = get_config('system', 'language_detect_min_confidence'); - if ($min_confidence === false) - $min_confidence = LANGUAGE_DETECT_MIN_CONFIDENCE; + $min_length = get_config('system', 'language_detect_min_length', LANGUAGE_DETECT_MIN_LENGTH); + $min_confidence = get_config('system', 'language_detect_min_confidence', LANGUAGE_DETECT_MIN_CONFIDENCE); // embedded apps have long base64 strings which will trip up the detector. $naked_body = preg_replace('/\[app\](.*?)\[\/app\]/', '', $s); + // strip off bbcode $naked_body = preg_replace('/\[(.+?)\]/', '', $naked_body); + + // strip any links + $naked_body = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $naked_body); + if (mb_strlen($naked_body) < intval($min_length)) { logger('string length less than ' . intval($min_length), LOGGER_DATA); - return ''; + return EMPTY_STR; } - $l = new Text_LanguageDetect; - try { - // return 2-letter ISO 639-1 (en) language code - $l->setNameMode(2); - $lng = $l->detectConfidence($naked_body); - logger('detect language: ' . print_r($lng, true) . $naked_body, LOGGER_DATA); - } catch (Text_LanguageDetect_Exception $e) { - logger('detect language exception: ' . $e->getMessage(), LOGGER_DATA); - } + $lang = new Language; + $lang_arr = $lang->detect($naked_body)->limit(0, 1)->close(); - if ((! $lng) || (! (x($lng,'language')))) { - return ''; + $confidence = reset($lang_arr); + if ($confidence >= intval($min_confidence)) { + logger('detect language: ' . print_r($lang_arr, true) . $naked_body, LOGGER_DATA); + return key($lang_arr); } - if ($lng['confidence'] < (float) $min_confidence) { - logger('detect language: confidence less than ' . (float) $min_confidence, LOGGER_DATA); - return ''; - } + logger('detect language: confidence less than ' . $min_confidence, LOGGER_DATA); - return($lng['language']); + return EMPTY_STR; } /** @@ -451,3 +440,20 @@ function lang_selector() { return $o; } +function rtl_languages() { + return [ + 'ar', + 'arc', + 'ckb', + 'dv', + 'fa', + 'ha', + 'he', + 'khw', + 'ks', + 'ps', + 'sd', + 'ur', + 'yi' + ]; +} diff --git a/include/nav.php b/include/nav.php index 31a447a84..e4df7e4e5 100644 --- a/include/nav.php +++ b/include/nav.php @@ -21,7 +21,7 @@ function nav($template = 'default') { $is_owner = (((local_channel()) && ((App::$profile_uid == local_channel()) || (App::$profile_uid == 0))) ? true : false); $observer = App::get_observer(); $chans = []; - + $channel = []; if (local_channel()) { $channel = App::get_channel(); @@ -84,11 +84,23 @@ function nav($template = 'default') { $userinfo = []; if ($observer) { - $userinfo = [ - 'icon' => $observer['xchan_photo_m'] . '?rev=' . strtotime($observer['xchan_photo_date']), - 'addr' => $observer['xchan_addr'], - 'name' => $observer['xchan_name'], - ]; + $userinfo['icon'] = $observer['xchan_photo_s'] . '?rev=' . strtotime($observer['xchan_photo_date']); + $userinfo['icon_m'] = $observer['xchan_photo_m'] . '?rev=' . strtotime($observer['xchan_photo_date']); + $userinfo['icon_l'] = $observer['xchan_photo_l'] . '?rev=' . strtotime($observer['xchan_photo_date']); + $userinfo['icon_mime_type'] = $observer['xchan_photo_mimetype']; + $userinfo['addr'] = $observer['xchan_addr']; + $userinfo['url'] = $observer['xchan_url']; + $userinfo['forum'] = $observer['xchan_pubforum']; + $userinfo['name'] = $observer['xchan_name']; + } + + if ($channel) { + $userinfo['id'] = $channel['channel_id']; + $userinfo['nick'] = $channel['channel_address']; + $userinfo['location'] = $channel['channel_location']; + $userinfo['theme'] = $channel['channel_theme']; + $userinfo['timezone'] = $channel['channel_timezone']; + $userinfo['startpage'] = $channel['channel_startpage']; } elseif (empty($_SESSION['authenticated'])) { @@ -201,7 +213,10 @@ function nav($template = 'default') { $nav['admin'] = ['admin/', t('Admin'), "", t('Site Setup and Configuration'), 'admin_nav_btn']; } - $theme_switch_icon = ((App::$page['color_mode'] === 'dark') ? 'sun' : 'moon'); + $theme_switch_icon = ''; + if (isset(App::$page['color_mode'])) { + $theme_switch_icon = ((App::$page['color_mode'] === 'dark') ? 'sun' : 'moon'); + } $x = ['nav' => $nav, 'usermenu' => $userinfo]; diff --git a/include/network.php b/include/network.php index b8570d4f4..13339eccd 100644 --- a/include/network.php +++ b/include/network.php @@ -456,13 +456,14 @@ function as_return_and_die($obj,$channel) { * @param string $msg * optional message */ -function http_status($val, $msg = '') { +function http_status($val, $msg = '',$skiplog = 0) { if ($val >= 400) $msg = (($msg) ? $msg : 'Error'); if ($val >= 200 && $val < 300) $msg = (($msg) ? $msg : 'OK'); - logger(\App::$query_string . ':' . $val . ' ' . $msg); + if (!$skiplog) + logger(\App::$query_string . ':' . $val . ' ' . $msg); header($_SERVER['SERVER_PROTOCOL'] . ' ' . $val . ' ' . $msg); } @@ -476,8 +477,8 @@ function http_status($val, $msg = '') { * optional message * @return void does not return, process is terminated */ -function http_status_exit($val, $msg = '') { - http_status($val, $msg); +function http_status_exit($val, $msg = '',$skiplog = 0) { + http_status($val, $msg, $skiplog); killme(); } @@ -2083,7 +2084,7 @@ function jsonld_document_loader($url) { } } - $cachepath = 'store/[data]/ldcache'; + $cachepath = 'store/[data]/[jsonld]'; if(!is_dir($cachepath)) { os_mkdir($cachepath, STORAGE_DEFAULT_PERMISSIONS, true); } @@ -2092,7 +2093,7 @@ function jsonld_document_loader($url) { if (file_exists($filename) && filemtime($filename) > time() - (12 * 60 * 60)) { logger('loading ' . $filename . ' from recent cache'); - return file_get_contents($filename); + return json_decode(file_get_contents($filename)); } $r = jsonld_default_document_loader($url); @@ -2109,7 +2110,7 @@ function jsonld_document_loader($url) { if (file_exists($filename)) { logger('loading ' . $filename . ' from longterm cache'); - return file_get_contents($filename); + return json_decode(file_get_contents($filename)); } else { logger($filename . ' does not exist and cannot be loaded'); diff --git a/include/plugin.php b/include/plugin.php index ae73a847c..f1d501001 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -459,8 +459,6 @@ function insert_hook($hook, $fn, $version = 0, $priority = 0) { * @param[in,out] string|array &$data to transmit to the callback handler */ function call_hooks($name, &$data = null) { - $a = 0; - if (isset(App::$hooks[$name])) { foreach(App::$hooks[$name] as $hook) { @@ -482,9 +480,13 @@ function call_hooks($name, &$data = null) { } $data = $checkhook['data']; } + $origfn = $hook[1]; - if($hook[0]) + + if($hook[0]) { @include_once($hook[0]); + } + if(preg_match('|^a:[0-9]+:{.*}$|s', $hook[1])) { $hook[1] = unserialize($hook[1]); } @@ -496,15 +498,12 @@ function call_hooks($name, &$data = null) { $hook[1] = explode('::',$hook[1]); } + if(is_callable($hook[1])) { $func = $hook[1]; - if($hook[3]) - $func($data); - else - $func($a, $data); + $func($data); } else { - // Don't do any DB write calls if we're currently logging a possibly failed DB call. if(! DBA::$logging) { // The hook should be removed so we don't process it. @@ -1074,6 +1073,7 @@ function theme_include($file, $root = '') { $paths = array( "{$root}view/theme/$thname/$ext/$file", + "{$root}view/theme/$thname/widget/$file", "{$root}view/theme/$parent/$ext/$file", "{$root}view/site/$ext/$file", "{$root}view/$ext/$file", diff --git a/include/text.php b/include/text.php index 6ab8fc1ce..27dd94bc5 100644 --- a/include/text.php +++ b/include/text.php @@ -528,9 +528,8 @@ function unxmlify($s) { * will limit the results to the correct items for the current page. * The actual page handling is then accomplished at the application layer. * - * @param App &$a */ -function paginate(&$a) { +function paginate() { $o = ''; $stripped = preg_replace('/(&page=[0-9]*)/','',App::$query_string); @@ -895,6 +894,7 @@ function get_tags($s) { // ignore anything in [style= ] $s = preg_replace('/\[style=(.*?)\]/sm','',$s); + // ignore anything in [color= ], because it may contain color codes which are mistaken for tags $s = preg_replace('/\[color=(.*?)\]/sm','',$s); @@ -3062,7 +3062,10 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $bb_tag = (($xc['xchan_network'] === 'zot6') ? 'zrl' : 'url'); $newtag = '@' . (($exclusive) ? '!' : '') . '[' . $bb_tag . '=' . $profile . ']' . $newname . '[/' . $bb_tag . ']'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + + // Replace tag but make sure to not replace something in the middle of a word + $body = preg_replace('/(?<![a-zA-Z0-9=\/])' . preg_quote($tag, '/') . '/', $newtag, $body); + // $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); // append tag to str_tags if(! stristr($str_tags,$newtag)) { @@ -3105,7 +3108,9 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $channel = App::get_channel(); if($channel) { $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . z_root() . '/channel/' . $channel['channel_address'] . ']' . $newname . '[/zrl]'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + // Replace tag but make sure to not replace something in the middle of a word + $body = preg_replace('/(?<![a-zA-Z0-9=\/])' . preg_quote($tag, '/') . '/', $newtag, $body); + // $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); } } } @@ -3126,7 +3131,9 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) */ if ($termtype === TERM_MENTION) { $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + // Replace tag but make sure to not replace something in the middle of a word + $body = preg_replace('/(?<![a-zA-Z0-9=\/])' . preg_quote($tag, '/') . '/', $newtag, $body); + // $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); } // append tag to str_tags |