diff options
Diffstat (limited to 'include/text.php')
-rw-r--r-- | include/text.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/include/text.php b/include/text.php index 6a2a9e427..54ad9ec7a 100644 --- a/include/text.php +++ b/include/text.php @@ -1572,7 +1572,9 @@ function format_hashtags(&$item) { $term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ; if(! trim($term)) continue; - if($t['url'] && strpos($item['body'], $t['url'])) + if(empty($t['url'])) + continue; + if(strpos($item['body'], $t['url']) || stripos($item['body'], '#' . $t['term'])) continue; if($s) $s .= ' '; @@ -2456,8 +2458,8 @@ function magic_link($s) { * @param boolean $escape (optional) default false */ function stringify_array_elms(&$arr, $escape = false) { - for($x = 0; $x < count($arr); $x ++) - $arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'"; + foreach($arr as $k => $v) + $arr[$k] = "'" . (($escape) ? dbesc($v) : $v) . "'"; } @@ -3091,7 +3093,7 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') { json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['target']); } - $item['body'] = preg_replace("/(\[zrl=".preg_quote($old,'/')."\/(photos|gallery)\/".$channel['channel_address'].".+\]\[zmg=\d+x\d+\])".preg_quote($old,'/')."\/(.+\[\/zmg\])/", '${1}'.$new.'/${3}', $item['body']); + $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']); $item['sig'] = base64url_encode(rsa_sign($item['body'],$channel['channel_prvkey'])); @@ -3105,6 +3107,15 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') { if($oldnick) $item['llink'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['llink']); + if($item['term']) { + for($x = 0; $x < count($item['term']); $x ++) { + $item['term'][$x]['url'] = str_replace($old,$new,$item['term'][$x]['url']); + if ($oldnick) { + $item['term'][$x]['url'] = str_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['term'][$x]['url']); + } + } + } + } |