X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Ftext.php;h=4ec59a66589c05ec8509d53da9e37ec46741fc79;hb=572678fef95816deaa1ecafe5cbcfb8cc65963c9;hp=199460d2cf12104841d27085a3d8db9a14c34559;hpb=531201f2a141e6a8dd606b9d1844de0806566294;p=friendica.git diff --git a/include/text.php b/include/text.php index 199460d2cf..4ec59a6658 100644 --- a/include/text.php +++ b/include/text.php @@ -20,7 +20,7 @@ function replace_macros($s,$r) { //$a = get_app(); //$a->page['debug'] .= "$tt
\n"; - return $r; + return template_unescape($r); }} @@ -80,6 +80,9 @@ function escape_tags($string) { if(! function_exists('autoname')) { function autoname($len) { + if($len <= 0) + return ''; + $vowels = array('a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u'); if(mt_rand(0,5) == 4) $vowels[] = 'y'; @@ -205,7 +208,6 @@ function hex2bin($s) { return ''; if(! ctype_xdigit($s)) { - logger('hex2bin: illegal input: ' . print_r(debug_backtrace(), true)); return($s); } @@ -226,6 +228,9 @@ if(! function_exists('paginate')) { function paginate(&$a) { $o = ''; $stripped = preg_replace('/(&page=[0-9]*)/','',$a->query_string); + +// $stripped = preg_replace('/&zrl=(.*?)([\?&]|$)/ism','',$stripped); + $stripped = str_replace('q=','',$stripped); $stripped = trim($stripped,'/'); $pagenum = $a->pager['page']; @@ -610,6 +615,8 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) { $url = $redirect_url; $sparkle = ' sparkle'; } + else + $url = zrl($url); } $click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : ''); if($click) @@ -638,7 +645,7 @@ if(! function_exists('search')) { function search($s,$id='search-box',$url='/search',$save = false) { $a = get_app(); $o = '
'; - $o .= '
'; + $o .= ''; $o .= ''; $o .= ''; if($save) @@ -694,8 +701,13 @@ function linkify($s) { if(! function_exists('smilies')) { function smilies($s, $sample = false) { + $a = get_app(); + if(intval(get_config('system','no_smilies')) + || (local_user() && intval(get_pconfig(local_user(),'system','no_smilies')))) + return $s; + $s = preg_replace_callback('/
(.*?)<\/pre>/ism','smile_encode',$s);
 	$s = preg_replace_callback('/(.*?)<\/code>/ism','smile_encode',$s);
 
@@ -704,27 +716,23 @@ function smilies($s, $sample = false) {
 		'</3', 
 		'<\\3', 
 		':-)', 
-//		':)', 
 		';-)', 
-//		';)', 
 		':-(', 
-//		':(', 
 		':-P', 
-//		':P', 
+		':-p', 
 		':-"', 
 		':-"', 
 		':-x', 
 		':-X', 
 		':-D', 
-//		':D', 
 		'8-|', 
 		'8-O', 
 		':-O', 
 		'\\o/', 
 		'o.O', 
 		'O.o', 
-		'\\.../', 
-		'\\ooo/', 
+		'o_O', 
+		'O_o', 
 		":'(", 
 		":-!", 
 		":-/", 
@@ -734,12 +742,8 @@ function smilies($s, $sample = false) {
 		':homebrew', 
 		':coffee', 
 		':facepalm',
-		':headdesk',
 		'~friendika', 
-		'~friendica', 
-//		'Diaspora*' 
-		':beard',
-		':whitebeard'
+		'~friendica'
 
 	);
 
@@ -748,27 +752,23 @@ function smilies($s, $sample = false) {
 		'</3',
 		'<\\3',
 		':-)',
-//		':)',
 		';-)',
-//		';)',                
 		':-(',
-//		':(',
 		':-P',
-//		':P',
+		':-p',
 		':-\',
 		':-\',
 		':-x',
 		':-X',
 		':-D',
-//		':D',                
 		'8-|',
 		'8-O',
 		':-O',                
 		'\\o/',
 		'o.O',
 		'O.o',
-		'\\.../',
-		'\\ooo/',
+		'o_O',
+		'O_o',
 		':\'(',
 		':-!',
 		':-/',
@@ -778,12 +778,8 @@ function smilies($s, $sample = false) {
 		':homebrew',
 		':coffee',
 		':facepalm',
-		':headdesk',
 		'~friendika ~friendika',
-		'~friendica ~friendica',
-//		'DiasporaDiaspora*',
-		':beard',
-		':whitebeard'
+		'~friendica ~friendica'
 	);
 
 	$params = array('texts' => $texts, 'icons' => $icons, 'string' => $s);
@@ -877,14 +873,27 @@ function prepare_body($item,$attach = false) {
 	$a = get_app();
 	call_hooks('prepare_body_init', $item); 
 
-	$s = prepare_text($item['body']);
+	$cache = get_config('system','itemcache');
+
+	if (($cache != '')) {
+		$cachefile = $cache."/".$item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']);
+
+		if (file_exists($cachefile))
+			$s = file_get_contents($cachefile);
+		else {
+			$s = prepare_text($item['body']);
+			file_put_contents($cachefile, $s);
+		}
+	} else
+		$s = prepare_text($item['body']);
 
 	$prep_arr = array('item' => $item, 'html' => $s);
 	call_hooks('prepare_body', $prep_arr);
 	$s = $prep_arr['html'];
 
-	if(! $attach)
+	if(! $attach) {
 		return $s;
+	}
 
 	$arr = explode(',',$item['attach']);
 	if(count($arr)) {
@@ -921,7 +930,7 @@ function prepare_body($item,$attach = false) {
 		foreach($matches as $mtch) {
 			if(strlen($x))
 				$x .= ',';
-			$x .= file_tag_decode($mtch[1]);
+			$x .= xmlify(file_tag_decode($mtch[1]));
 		}
 		if(strlen($x))
 			$s .= '
' . t('Categories:') . ' ' . $x . '
'; @@ -936,15 +945,45 @@ function prepare_body($item,$attach = false) { foreach($matches as $mtch) { if(strlen($x)) $x .= '   '; - $x .= file_tag_decode($mtch[1]). ' ' . t('[remove]') . ''; + $x .= xmlify(file_tag_decode($mtch[1])) . ' ' . t('[remove]') . ''; } if(strlen($x) && (local_user() == $item['uid'])) $s .= '
' . t('Filed under:') . ' ' . $x . '
'; } + // Look for spoiler + $spoilersearch = '
'; + + // Remove line breaks before the spoiler + while ((strpos($s, "\n".$spoilersearch) !== false)) + $s = str_replace("\n".$spoilersearch, $spoilersearch, $s); + while ((strpos($s, "
".$spoilersearch) !== false)) + $s = str_replace("
".$spoilersearch, $spoilersearch, $s); + + while ((strpos($s, $spoilersearch) !== false)) { + + $pos = strpos($s, $spoilersearch); + $rnd = random_string(8); + $spoilerreplace = '
'.sprintf(t('Click to open/close')).''. + '