Hy all,
The next peace of code gives me a filename back i a certain format. This format provides a game, ingame colors.
if (!$client->query('GetChallengeList', 50, 0)) {
trigger_error("[".$client->getErrorCode()."] ".$client->getErrorMessage());
}
else
{
$ChallengeList = $client->getResponse($fname);
echo "<TABLE cellspacing=5>";
foreach ($ChallengeList as $challenge) {
$fname = $challenge['FileName'];
echo <<<END
<TR><TD><font color='White'>$fname</TD></TR>
END;
}
}
$client->Terminate();
I want to show these filenames on the internet but with the right format with the following code but is dont know how to merge these 2 files. i'm still a noob.
could soemone please help me/????
this is the code that must convert the output of the above code:
function format_name($name) {
$buf = preg_replace('/(\$s)/i', '', $name);
$buf = preg_replace('/(\$\$)/i', '$', $buf);
$buf = preg_split('/(\$z)|(\$[0-9a-f]{1}[[:alnum:]\s]{2})|(\$i)|(\$g)|(\$w)|(\$n)|(\$m)/i', $buf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$st_color = '';
$st_italic = '';
$st_spacing = '';
$st_end = '';
foreach($buf as $tnum=>$tok) {
if($buf[$tnum] == '$z' || $buf[$tnum] == '$Z') {
$buf[$tnum] = $st_end;
$st_color = '';
$st_italic = '';
$st_spacing = '';
$st_end = '';
}
if ($buf[$tnum] == '$g' || $buf[$tnum] == '$G') {
if($st_color !== '') {
$st_color = '';
if ($st_italic !== '' || $st_spacing !== '') {
$buf[$tnum] = "$st_end<span style=\"$st_italic$st_spacing\">";
}
else {
$buf[$tnum] = $st_end;
$st_end = '';
}
}
else
$buf[$tnum] = '';
}
else if ($buf[$tnum] == '$m' || $buf[$tnum] == '$M') {
if($st_spacing !== '') {
$st_spacing = '';
if ($st_color !== '' || $st_italic !== '') {
$buf[$tnum] = "$st_end<span style=\"$st_color$st_italic\">";
}
else {
$buf[$tnum] = $st_end;
$st_end = '';
}
}
else
$buf[$tnum] = '';
}
else if ($buf[$tnum] == '$i' || $buf[$tnum] == '$I') {
if($st_italic !== '') {
$st_italic = '';
if ($st_color !== '' || $st_spacing !== '') {
$buf[$tnum] = "$st_end<span style=\"$st_color$st_spacing\">";
}
else {
$buf[$tnum] = $st_end;
$st_end = '';
}
}
else {
$st_italic = "font-style:italic;";
$buf[$tnum] = "$st_end<span style=\"$st_color$st_italic$st_spacing\">";
$st_end = "</span>";
}
}
else if ($buf[$tnum] == '$w' || $buf[$tnum] == '$W') {
$st_spacing = "letter-spacing:2;";
$buf[$tnum] = "$st_end<span style=\"$st_color$st_italic$st_spacing\">";
$st_end = "</span>";
}
else if ($buf[$tnum] == '$n' || $buf[$tnum] == '$N') {
$st_spacing = "letter-spacing:-2;";
$buf[$tnum] = "$st_end<span style=\"$st_color$st_italic$st_spacing\">";
$st_end = "</span>";
}
else if(preg_match('/(\$[0-9a-f])/i', $buf[$tnum])) {
$patterns = array ('/(\$)/', '/([0-9a-f])/i', '/([^0-9a-f])/i');
$replace = array ("", "\${1}0", "00");
$st_color = "color:#".preg_replace($patterns, $replace, $buf[$tnum]).";";
$buf[$tnum] = "$st_end<span style=\"$st_color$st_italic$st_spacing\">";
$st_end = "</span>";
}
}
$fname = '';
foreach($buf as $tnum=>$tok)
if($buf[$tnum] !== '') $fname = $fname.$buf[$tnum];
$fname = $fname.$st_end;
return $fname;