I had problems with playernames correctly displayed in worldmap,
it seems special chars have to be handled twice.. our Community has the tag, |>B<| and the worldmap does cut the name after the B. After lots of experimenting I thought it might be needed to encode it twice.. and well that worked.
in lib/worldmap/playergeodata.php
$playername = htmlspecialchars(htmlspecialchars(utf2iso($client -> name)));
And I add colors for ET.. although it needed more changes to the code, as the background from the players which are currently on is not defined by CSS, or I missed it.
function ColorizeName($cname)
{
$pattern = array('^^' => '#@^',
'^0' => '#000000', '^1' => '#FF0000', '^2' => '#00FF00',
'^3' => '#FFFF00', '^4' => '#0000FF', '^5' => '#00FFFF',
'^6' => '#FF00FF', '^7' => '#FFFFFF', '^8' => '#FF6600',
'^9' => '#666666', '^a' => '#FF9933', '^b' => '#006666',
'^c' => '#660066', '^d' => '#0066FF', '^e' => '#6600FF',
'^f' => '#3399CC', '^g' => '#CCFFCC', '^h' => '#006633',
'^i' => '#FF0033', '^j' => '#990000', '^k' => '#993300',
'^l' => '#CC9933', '^m' => '#999933', '^n' => '#FFFFCC',
'^o' => '#FFFF66', '^p' => '#000000', '^q' => '#FF0000',
'^r' => '#00FF00', '^s' => '#FFFF00', '^t' => '#0000FF',
'^u' => '#00FFFF', '^v' => '#FF00FF', '^w' => '#FFFFFF',
'^x' => '#FF6600', '^y' => '#666666', '^z' => '#9999CC',
'^A' => '#FF9933', '^B' => '#006666', '^C' => '#660066',
'^D' => '#0066FF', '^E' => '#6600FF', '^F' => '#3399CC',
'^G' => '#CCFFCC', '^H' => '#006633', '^I' => '#FF0033',
'^J' => '#990000', '^K' => '#993300', '^L' => '#CC9933',
'^M' => '#999933', '^N' => '#FFFFCC', '^O' => '#FFFF66',
'^P' => '#000000', '^Q' => '#FF0000', '^R' => '#00FF00',
'^S' => '#FFFF00', '^T' => '#0000FF', '^U' => '#00FFFF',
'^V' => '#FF00FF', '^W' => '#FFFFFF', '^X' => '#FF6600',
'^Y' => '#666666', '^Z' => '#9999CC', '^!' => '#FF9933',
'^#' => '#660066', '^$' => '#0066FF', '^%' => '#6600FF',
'^&' => '#3399CC', '^(' => '#006633', '^)' => '#FF0033',
'^*' => '#990033', '^+' => '#993300', '^-' => '#999933',
'^,' => '#CC9933', '^.' => '#FFFFCC', '^\\' => '#006600',
'^/' => '#FFFF99', '^<' => '#006600', '^>' => '#000066',
'^[' => '#CCCCCC', '^]' => '#666600', '^{' => '#CCCCCC',
'^}' => '#666600', '^:' => '#CCCCCC', '^=' => '#666600',
'^?' => '#660000', '^@' => '#663300', '^_' => '#660000',
'^\'' => '#CCFFCC', '^|' => '#006600', '^~' => '#000066',
'^`' => '#663300'
);
$final = '';
$cnl = strlen($cname);
for ( $i=0; $i < $cnl; $i++ ) {
if ( substr($cname, $i, 1 ) == '^' ) {
if ( $i < $cnl ) {
if ( substr( $cname, $i+1, 1 ) != '^' ) {
$final .= '</font><font color="'.$pattern['^'.substr($cname,$i+1,1)].'">';
if ($i+1 < $cnl) $i++;
} else {
$final .= htmlspecialchars(substr($cname,$i,1));
}
} else {
$final .= htmlspecialchars(substr($cname,$i,1));
}
} else {
$final .= htmlspecialchars(substr($cname,$i,1));
}
}
return '<font>' . $final . '</font>';
}
well I suppose this can be optimized.. but uhrm.. this function did work in all cases I tested a while ago, and those ^^ combinations are evil..
This function does escape the special chars of the name, but the hole needs to be escaped as well, if used for worldmap..
$playername = htmlspecialchars((ColorizeName($client -> colorname)));
I wanted to add this to the stats list aswell, but seems that is more complicated. Also different games use different colors,
so this color array should be somewhere else..
Also it would make sense todo this conversion to html only once, and store in db.. But I have yet no idea how todo all this correctly.
Thanks to Anubis
post, it gave me the idea and good hints.. I don't know what some parts of his function do, but I think it won't catch all situations of ^ combinations, but I don't know COD at all.. might be very different to ET.