PHP help #1

Hello CF.
I got some problems with PHP.
Here is an function:
Quote
function fixOSPColors($str, $std = "white") {
$str = ereg_replace("(\^)?$", "", $str);
$str = ereg_replace("\^\^", "^", $str);
$str = "<FONT COLOR=\"" . $std . "\">" . $str . "</FONT>";

$color = array (
0 => "black", 1 => "red", 2 => "lime", 3 => "yellow", 4 => "blue",
5 => "cyan", 6 => "magenta", 7 => "white", 8 => "orange", 9 => "gray",

10 => "#CC9966", 11 => "teal", 12 => "purple", 13 => "#0066CC", 14 => "#6600CC",
15 => "#3399CC", 16 => "#CCFFCC", 17 => "#006633", 18 => "#990033", 19 => "#993333",
20 => "#993300", 21 => "#CC9966", 22 => "#999966", 23 => "#CCCC99", 24 => "#CCCC66",

"black" => array (0 => "0", 1 => "p", 2 => "P" ),
"red" => array (0 => "1", 1 => "q", 2 => "Q" ),
"lime" => array (0 => "2", 1 => "r", 2 => "R" ),
"yellow" => array (0 => "3", 1 => "s", 2 => "S" ),
"blue" => array (0 => "4", 1 => "t", 2 => "T", 3 => ">" ),
"cyan" => array (0 => "5", 1 => "u", 2 => "U" ),
"magenta" => array (0 => "6", 1 => "v", 2 => "V" ),
"white" => array (0 => "7", 1 => "w", 2 => "W", 3 => "z", 4 => "Z", 5 => "{", 6 => "[" ),
"orange" => array (0 => "8", 1 => "x", 2 => "X" ),
"gray" => array (0 => "9", 1 => "y", 2 => "Y", 3 => ":" ),

"#CC9966" => array (0 => "a", 1 => "A", 2 => "!", 3 => "," ),
"teal" => array (0 => "b", 1 => "B" ),
"purple" => array (0 => "c", 1 => "C", 2 => "#" ),
"#0066CC" => array (0 => "d", 1 => "D", 2 => "&", 3 => "$" ),
"#6600CC" => array (0 => "e", 1 => "E" ),
"#3399CC" => array (0 => "f", 1 => "F" ),
"#CCFFCC" => array (0 => "g", 1 => "G", 2 => "'" ),
"#006633" => array (0 => "h", 1 => "H", 2 => "(", 3 => "\\", 4 => "|", 5 => "<", ),
"#990033" => array (0 => "i", 1 => "I", 2 => ")" ),
"#993333" => array (0 => "j", 1 => "J", 2 => "?", 3 => "*", 4 => "_" ),
"#993300" => array (0 => "k", 1 => "K", 2 => '"', 3 => "@" ),
"#CC9966" => array (0 => "l", 1 => "L", 2 => "-" ),
"#999966" => array (0 => "m", 1 => "M", 2 => "=", 3 => "]", 4 => "}" ),
"#CCCC99" => array (0 => "n", 1 => "N", 2 => "¤", 3 => "%", 4 => "." ),
"#CCCC66" => array (0 => "o", 1 => "O", 2 => "/", ),
);

for ($i = 0; $i < count($color) / 2; $i++) {
for ($j = 0; $j < count($color[$color[$i]]); $j++) {
$str = str_replace("^". $color[$color[$i]][$j], "</FONT><FONT COLOR=\"" . $color[$i] . "\">", $str);
}
}
return $str;
}

What it does,it replaces ^5 tag to Cyan color.
Example: ^4CF ^wSLAC server ^4#1 ,the function replaces it with CF SLAC server with blue and white color.
Here you can see it: http://genert.impact.pri.ee/sfsf/server.php?ip=88.198.69.3:27960
As you can see Nexus in colors.
Now the problem is,take a look at title: Server info of ^skkskg^gs^ss
How to make function to get of ^ tags with colors?My brain stucked at this point.

Other problem is:
You see its "No SLAC protection" but where is the picture?
Quote
<? $slac=getValue("sl_sv_version");
if($slac=="v0.14")
echo '<img src="'.$snippet_theme.'img_privi/sv_slac.gif" title="SLAC Protected" alt="SLAC Protected" />';
elseif($slac=="v0.13")
echo '<img src="'.$snippet_theme.'img_privi/sv_slac.gif" title="SLAC Protected" alt="SLAC Protected" />';
elseif($slac=="v0.15")
echo '<img src="'.$snippet_theme.'img_privi/sv_slac.gif" title="SLAC Protected" alt="SLAC Protected" />';
elseif($slac=="0")
'<img src="'.$snippet_theme.'img_privi/sv_slac_off.gif" title="No SLAC protection" alt="No SLAC protection" />';
?>

I tried with else,still nothing:p

Check this user lol,askes password to continue http://www.crossfire.nu/?x=user&mode=view&id=35549

Random music:

Queens
Comments
18
this looks so nerdy
for the ^ you can use the preg_replace function of php:
dont click!

and the other problem, i dont know.
I tried with,problem is that you cant replace ^[$colors] with nothing:p
It gives error,why "" is empty..
Parent
why ask on here? just because people nerd out on ET all day does not mean they are programmers. Best place to ask is www.stackoverflow.com :D
Quite a few coders/devs on here
Parent
ask skooli
Nop,thats not what I think,I dont wanna add colors.
I wanna get off them.
Like:
^o[ ^1N e X u S ^0] ET - ^103 ^0- [ETPro 3.2.6]
Goes to:
[ N e X u S ] ET - 03 - [ETPro 3.2.6] without colors,just text
Parent
http://paste.entirely.pro/phpsyntax.php?file=eu56m

A quick edit for you, I have not tested it though
Parent
alterntive was to use str_replace with regex looking for ^(+a any char max of 1) which should take it down to just one line instead of the 8 line function
Parent
True, but if you look above, it was a 20second edit rather than working out the regex. As far as efficiency goes, it isn't going to be much different, especially as it is only called 1 time per page.
Parent
Anyway since you are here,then:D
http://genert.impact.pri.ee/sfsf/server.php?ip=188.165.209.117:29000 if you look at team,then you see there is ALLIES stuff.
Its in HTMl,now,I wanna add team.
The system core is: http://paste.entirely.pro/phpsyntax.php?file=eaaih
Now I wanna add team get:
http://paste.entirely.pro/phpsyntax.php?file=0o2kl
and in server.php
Quote <td><? echo $players[$i][team']; ?>&nbsp;</td>

Didnt work,maybe you can help me?
Parent
I don't think you can get this data from the getstatus query
Parent
Ah right, the data isn't in with the players, it is another value called P, the raw command will output
QuoteP\12212312122-3--1-1-2


So you will need to compare IDs with the position in that sting I think
Parent
Ou,yeah,I was thinking wtf is is P,Im getting understand of splatterladder system.
Well,thank you,I really didnt know that P/12213 means players team positsion,I thank you for that:9
Parent
it's time to ditch php and use a j2ee framework
Back to top