X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Ftext.php;h=6662ac8028f34d40e246f502508d23b8c19a37d9;hb=39d8fec290613cac87c2821b9f7b20fa94d319ca;hp=1d74d9cf5c4bc19df856707acf6f30cd1bd0adc6;hpb=e05725fb4473be7ec3ee6fcea80f3f2e7c52a434;p=friendica.git diff --git a/include/text.php b/include/text.php index 1d74d9cf5c..6662ac8028 100644 --- a/include/text.php +++ b/include/text.php @@ -23,7 +23,6 @@ function replace_macros($s,$r) { if(gettype($s) === 'string') { $template = $s; $s = new FriendicaSmarty(); - $s->error_reporting = E_ALL & ~E_NOTICE; } foreach($r as $key=>$value) { if($key[0] === '$') { @@ -174,10 +173,11 @@ function autoname($len) { if(! function_exists('xmlify')) { function xmlify($str) { - $buffer = ''; +/* $buffer = ''; - for($x = 0; $x < mb_strlen($str); $x ++) { - $char = $str[$x]; + $len = mb_strlen($str); + for($x = 0; $x < $len; $x ++) { + $char = mb_substr($str,$x,1); switch( $char ) { @@ -205,7 +205,14 @@ function xmlify($str) { $buffer .= $char; break; } - } + }*/ + + $buffer = mb_ereg_replace("&", "&", $str); + $buffer = mb_ereg_replace("'", "'", $buffer); + $buffer = mb_ereg_replace("\"", """, $buffer); + $buffer = mb_ereg_replace("<", "<", $buffer); + $buffer = mb_ereg_replace(">", ">", $buffer); + $buffer = trim($buffer); return($buffer); }} @@ -215,8 +222,13 @@ function xmlify($str) { if(! function_exists('unxmlify')) { function unxmlify($s) { - $ret = str_replace('&','&', $s); - $ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret); +// $ret = str_replace('&','&', $s); +// $ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret); + $ret = mb_ereg_replace('&', '&', $s); + $ret = mb_ereg_replace(''', "'", $ret); + $ret = mb_ereg_replace('"', '"', $ret); + $ret = mb_ereg_replace('<', "<", $ret); + $ret = mb_ereg_replace('>', ">", $ret); return $ret; }} @@ -490,12 +502,12 @@ function get_template_file($a, $filename, $root = '') { if($root !== '' && $root[strlen($root)-1] !== '/') $root = $root . '/'; - if(file_exists($root . "view/theme/$theme/$filename")) - $template_file = $root . "view/theme/$theme/$filename"; - elseif (x($a->theme_info,"extends") && file_exists($root . "view/theme/".$a->theme_info["extends"]."/$filename")) - $template_file = $root . "view/theme/".$a->theme_info["extends"]."/$filename"; + if(file_exists("{$root}view/theme/$theme/$filename")) + $template_file = "{$root}view/theme/$theme/$filename"; + elseif (x($a->theme_info,"extends") && file_exists("{$root}view/theme/{$a->theme_info["extends"]}/$filename")) + $template_file = "{$root}view/theme/{$a->theme_info["extends"]}/$filename"; else - $template_file = $root . "view/$filename"; + $template_file = "{$root}view/$filename"; return $template_file; }} @@ -1042,16 +1054,27 @@ function prepare_body($item,$attach = false) { return $s; } - $arr = explode(',',$item['attach']); + $arr = explode('[/attach],',$item['attach']); if(count($arr)) { $s .= '
'; foreach($arr as $r) { $matches = false; $icon = ''; - $cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches, PREG_SET_ORDER); + $cnt = preg_match_all('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"|',$r,$matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { - $icontype = strtolower(substr($mtch[3],0,strpos($mtch[3],'/'))); + $filetype = strtolower(substr( $mtch[3], 0, strpos($mtch[3],'/') )); + if($filetype) { + $filesubtype = strtolower(substr( $mtch[3], strpos($mtch[3],'/') + 1 )); + $filesubtype = str_replace('.', '-', $filesubtype); + } + else { + $filetype = 'unkn'; + $filesubtype = 'unkn'; + } + + $icon = '
'; + /*$icontype = strtolower(substr($mtch[3],0,strpos($mtch[3],'/'))); switch($icontype) { case 'video': case 'audio': @@ -1062,7 +1085,8 @@ function prepare_body($item,$attach = false) { default: $icon = '
'; break; - } + }*/ + $title = ((strlen(trim($mtch[4]))) ? escape_tags(trim($mtch[4])) : escape_tags($mtch[1])); $title .= ' ' . $mtch[2] . ' ' . t('bytes'); if((local_user() == $item['uid']) && ($item['contact-id'] != $a->contact['id']) && ($item['network'] == NETWORK_DFRN))