X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Ftext.php;h=1f5d4a3e12ae035a094f9129eb3a4007095a391e;hb=e11b51aca14ea36b514fdd4348443f4fae79b2ca;hp=29e53c663512961aad71cd6df60a8ff21e0e43ce;hpb=c8d5274ceea95bdf9df5ca2ab698fa9860319e31;p=friendica.git diff --git a/include/text.php b/include/text.php old mode 100644 new mode 100755 index 29e53c6635..1f5d4a3e12 --- 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'); @@ -534,8 +540,10 @@ 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; @@ -635,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,43 +675,136 @@ function linkify($s) { * @Parameter: string $s * * Returns string + * + * It is expected that this function will be called using HTML text. + * We will escape text between HTML pre and code blocks from being + * processed. + * + * At a higher level, the bbcode [nosmile] tag can be used to prevent this + * function from being executed by the prepare_text() routine when preparing + * bbcode source for HTML display + * */ 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', '~friendica', 'Diaspora*' ), - array( + $s = preg_replace_callback('/
(.*?)<\/pre>/ism','smile_encode',$s);
+ $s = preg_replace_callback('/(.*?)<\/code>/ism','smile_encode',$s);
+
+ $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(
'
',
'
',
'
',
'
',
- '
',
+// '
',
'
',
+// '
',
'
',
- '
',
+// '
',
'
',
- '
',
+// '
',
+ '
',
'
',
'
',
'
',
'
',
+// '
',
'
',
'
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
+ '
',
'~friendika
',
- '~friendica
',
+ '~friendica
',
'Diaspora
',
- ), $s);
+ );
+
+ $params = array('texts' => $texts, 'icons' => $icons, 'string' => $s);
+ call_hooks('smilie', $params);
+
+ 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']);
+ }
+
+ $s = preg_replace_callback('/(.*?)<\/pre>/ism','smile_decode',$s);
+ $s = preg_replace_callback('/(.*?)<\/code>/ism','smile_decode',$s);
- call_hooks('smilie', $s);
return $s;
}}
+function smile_encode($m) {
+ return(str_replace($m[1],base64url_encode($m[1]),$m[0]));
+}
+
+function smile_decode($m) {
+ return(str_replace($m[1],base64url_decode($m[1]),$m[0]));
+}
+
+
if(! function_exists('day_translate')) {
@@ -776,10 +877,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]));
@@ -805,7 +906,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;
}}
@@ -892,7 +996,7 @@ function lang_selector() {
}
$ll = substr($l,5);
$ll = substr($ll,0,strrpos($ll,'/'));
- $selected = (($ll === $lang && (x($_SESSION['language']))) ? ' selected="selected" ' : '');
+ $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? ' selected="selected" ' : '');
$o .= '';
}
}
@@ -939,6 +1043,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
@@ -1058,3 +1167,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 = "]*) href=\"(?!http|https)([^\"]*)\"/";
+ $replace = "]*) src=\"(?!http|https|\/)([^\"]*)\"/";
+ $replace = "
]*) src=\"(?!http|https)([^\"]*)\"/";
+ $replace = "![](\"")