X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Ftext.php;h=044ee4e085a9cd2dd5045b4793c1d0ddf9c66814;hb=1cfff8fdd11e0e67e2bdb7ae85b9caf8106a734b;hp=8ada179dc404bfe74ebefc0aab6ab9b387be2cc3;hpb=abe96155b42f0f824d05d08126d0ced0d3c5ab38;p=friendica.git diff --git a/include/text.php b/include/text.php old mode 100644 new mode 100755 index 8ada179dc4..044ee4e085 --- a/include/text.php +++ b/include/text.php @@ -426,6 +426,12 @@ function attribute_contains($attr,$s) { if(! function_exists('logger')) { function logger($msg,$level = 0) { + // turn off logger in install mode + global $a; + global $db; + + if(($a->module == 'install') || (! ($db && $db->connected))) return; + $debugging = get_config('system','debugging'); $loglevel = intval(get_config('system','loglevel')); $logfile = get_config('system','logfile'); @@ -465,7 +471,7 @@ function get_tags($s) { // Match full names against @tags including the space between first and last // We will look these up afterward to see if they are full names or not recognisable. - if(preg_match_all('/(@[^ \x0D\x0A,:?]+ [^ \x0D\x0A,:?]+)([ \x0D\x0A,:?]|$)/',$s,$match)) { + if(preg_match_all('/(@[^ \x0D\x0A,:?]+ [^ \x0D\x0A@,:?]+)([ \x0D\x0A@,:?]|$)/',$s,$match)) { foreach($match[1] as $mtch) { if(strstr($mtch,"]")) { // we might be inside a bbcode color tag - leave it alone @@ -492,6 +498,9 @@ function get_tags($s) { // ignore strictly numeric tags like #1 if((strpos($mtch,'#') === 0) && ctype_digit(substr($mtch,1))) continue; + // try not to catch url fragments + if(strpos($s,$mtch) && preg_match('/[a-zA-z0-9\/]/',substr($s,strpos($s,$mtch)-1,1))) + continue; $ret[] = $mtch; } } @@ -531,12 +540,14 @@ function contact_block() { $a = get_app(); $shown = get_pconfig($a->profile['uid'],'system','display_friend_count'); - if(! $shown) + if($shown === false) $shown = 24; + if($shown == 0) + return; if((! is_array($a->profile)) || ($a->profile['hide-friends'])) return $o; - $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0", + $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0", intval($a->profile['uid']) ); if(count($r)) { @@ -547,7 +558,7 @@ function contact_block() { $micropro = Null; } else { - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 ORDER BY RAND() LIMIT %d", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 ORDER BY RAND() LIMIT %d", intval($a->profile['uid']), intval($shown) ); @@ -632,7 +643,7 @@ function search($s,$id='search-box',$url='/search',$save = false) { if(! function_exists('valid_email')) { function valid_email($x){ - if(preg_match('/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) + if(preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/',$x)) return true; return false; }} @@ -667,35 +678,105 @@ function linkify($s) { */ if(! function_exists('smilies')) { -function smilies($s) { +function smilies($s, $sample = false) { $a = get_app(); - $s = str_replace( - array( '<3', '</3', '<\\3', ':-)', ':)', ';-)', ':-(', ':(', ':-P', ':P', ':-"', ':-x', ':-X', ':-D', '8-|', '8-O', - '~friendika', 'Diaspora*' ), - array( + $texts = array( + '<3', + '</3', + '<\\3', + ':-)', +// ':)', + ';-)', +// ';)', + ':-(', +// ':(', + ':-P', +// ':P', + ':-"', + ':-"', + ':-x', + ':-X', + ':-D', +// ':D', + '8-|', + '8-O', + ':-O', + '\\o/', + 'o.O', + 'O.o', + '\\.../', + '\\ooo/', + ":'(", + ":-!", + ":-/", + ":-[", + "8-)", + ':beer', + ':homebrew', + ':coffee', + ':facepalm', + ':headdesk', + '~friendika', + '~friendica', + 'Diaspora*' + ); + + $icons = array( '<3', '</3', '<\\3', ':-)', - ':)', +// ':)', ';-)', +// ';)', ':-(', - ':(', +// ':(', ':-P', - ':P', +// ':P', + ':-\', ':-\', ':-x', ':-X', ':-D', +// ':D', '8-|', '8-O', + ':-O', + '\\o/', + 'o.O', + 'O.o', + '\\.../', + '\\ooo/', + ':\'(', + ':-!', + ':-/', + ':-[', + '8-)', + ':beer', + ':homebrew', + ':coffee', + ':facepalm', + ':headdesk', '~friendika ~friendika', + '~friendica ~friendica', 'DiasporaDiaspora*', - ), $s); + ); + + $params = array('texts' => $texts, 'icons' => $icons, 'string' => $s); + call_hooks('smilie', $params); - call_hooks('smilie', $s); + if($sample) { + $s = '
'; + for($x = 0; $x < count($params['texts']); $x ++) { + $s .= '
' . $params['texts'][$x] . '
' . $params['icons'][$x] . '
'; + } + } + else { + $s = str_replace($params['texts'],$params['icons'],$params['string']); + } + return $s; }} @@ -772,10 +853,10 @@ function prepare_body($item,$attach = false) { case 'audio': case 'image': case 'text': - $icon = '
'; + $icon = '
'; break; default: - $icon = '
'; + $icon = '
'; break; } $title = ((strlen(trim($matches[4]))) ? escape_tags(trim($matches[4])) : escape_tags($matches[1])); @@ -787,14 +868,6 @@ function prepare_body($item,$attach = false) { $s .= '
'; } - $arr = explode(',',$item['tag']); - if(count($arr)) { - $s .= '
'; - foreach($arr as $r) { - $s .= bbcode($r) . ' '; - } - $s .= '
'; - } $prep_arr = array('item' => $item, 'html' => $s); call_hooks('prepare_body_final', $prep_arr); @@ -809,7 +882,10 @@ function prepare_text($text) { require_once('include/bbcode.php'); - $s = smilies(bbcode($text)); + if(stristr($text,'[nosmile]')) + $s = bbcode($text); + else + $s = smilies(bbcode($text)); return $s; }} @@ -943,6 +1019,11 @@ function base64url_encode($s, $strip_padding = false) { function base64url_decode($s) { + if(is_array($s)) { + logger('base64url_decode: illegal input: ' . print_r(debug_backtrace(), true)); + return $s; + } + /* * // Placeholder for new rev of salmon which strips base64 padding. * // PHP base64_decode handles the un-padded input without requiring this step @@ -1062,3 +1143,37 @@ function array_xmlify($val){ if (is_array($val)) return array_map('array_xmlify', $val); return xmlify((string) $val); } + + +function reltoabs($text, $base) +{ + if (empty($base)) + return $text; + + $base = rtrim($base,'/'); + + $base2 = $base . "/"; + + // Replace links + $pattern = "/]*) href=\"(?!http|https|\/)([^\"]*)\"/"; + $replace = "