setHeader ('Content-Type: text/html; charset=UTF-8'); $s = $xslt->process (); $s = '<'.'?xml version="1.0" encoding="UTF-8"?'.'>' . $s; $i1 = strpos ($s, '') + 2; echo substr ($s, 0, $i1); echo substr ($s, $i2); } else { echo $s; } } else { header ('Content-Type: application/xml; charset=UTF-8'); echo '<' . '?xml version="1.0" encoding="UTF-8"?' . '>'; if ('client' == $gConf['xsl_mode'] && $xsl) { echo '<' . '?xml-stylesheet type="text/xsl" href="'.str_replace($gConf['dir']['xsl'],$gConf['url']['xsl'],$xsl).'"?'.'>'; } echo $xml; } } /** * Convert array to XML format * * @param $arr array with data * @param $tag main tag
XML data
* @return XML presentation of data */ function array2xml($arr, $tag = false) { $res = ''; foreach($arr as $k=>$v) { if(is_array($v)) { if(!is_numeric($k) && trim($k))// $res .= count($v) ? '<'.$k.'>'.array2xml($v).'' : '<'.$k.'/>'; elseif($tag) $res .= '<'.$tag.'>'.array2xml($v).''; else $res .= array2xml($v); } else { if(!is_numeric($k) && trim($k))// $res .= strlen(trim($v)) ? '<'.$k.'>'.$v.'' : '<'.$k.'/>';//'<'.$k.'>'.$v.''; elseif($tag) $res .= '<'.$tag.'>'.$v.'';//trim($v) ? '<'.$tag.'>'.$v.'' : '<'.$tag.'/>'; else { echo 'Error: array without tag'; exit; } } } return $res; } /** * check if magick quotes is disables */ function checkMagicQuotes () { if (0 == get_magic_quotes_gpc()) { addSlashesArray ($_COOKIE); addSlashesArray ($_GET); addSlashesArray ($_POST); } } /** * add slashes to every value of array */ function addSlashesArray (&$a) { for ( reset ($a); list ($k, $v) = each ($a); ) { if (is_array($v)) addSlashesArray ($v); else $a[$k] = addslashes ($v); } } function prepare_to_db(&$s, $iAllowHTML = 1) { if ($iAllowHTML) cleanPost($s); } /** * check html message, remove unknown tags, chech for xhtml errors */ function cleanPost (&$s) { /*function makeStyle ($s) { global $gConf; if ($s == ">") return ''; $style = ''; $ret = ''; if (preg_match("/\bbold\b/", $s)) $style .= "font-weight:bold;"; if (preg_match("/\bunderline\b/", $s)) $style .= "text-decoration:underline;"; if (preg_match("/\bitalic\b/", $s)) $style .= "font-style:italic;"; if (preg_match("/\bmargin-left[:\s]+([0-9a-z]+)/", $s, $m)) $style .= "margin-left:{$m[1]};"; if (preg_match("/\bhref=\\\\\\\\\"([0-9A-Za-z:@_\.\/?=&;-]+)/", $s, $m)) $ret = " " . (preg_match ('#^' . $gConf['url']['base'] . '#', $m[1]) ? "" : "target=\"_blank\"") . " href=\"{$m[1]}\""; if (preg_match("/\bsrc=\\\\\\\\\"([0-9A-Za-z:@_\.\/?=&;-]+)/", $s, $m)) $ret = " src=\"{$m[1]}\" /"; if ($style) $ret .= " style=\"$style\""; return $ret; }*/ $s = str_replace (" ", " ", $s); $s = strip_tags ($s, '