From: cajus Date: Mon, 10 Mar 2008 16:47:59 +0000 (+0000) Subject: Added xmlentities X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fd2a37e792095cf32ab8ab8e0d9ab9203800bb8a;p=gosa.git Added xmlentities git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9623 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index d9f4661eb..f37347fd3 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -2702,5 +2702,27 @@ function send_binary_content($data,$name,$type = "application/octet-stream") exit(); } + +function xmlentities($str) +{ + static $asc2uni= array(); + + if (!count($asc2uni)){ + for($i=128;$i<256;$i++){ + $asc2uni[chr($i)] = "&#x".dechex($i).";"; + } + } + + $str = str_replace("&", "&", $str); + $str = str_replace("<", "<", $str); + $str = str_replace(">", ">", $str); + $str = str_replace("'", "'", $str); + $str = str_replace("\"", """, $str); + $str = str_replace("\r", "", $str); + $str = strtr($str,$asc2uni); + + return $str; +} + // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?>