" . $eilute . ""; } if (preg_match("/Nick change: /", $eilute, $regs) || preg_match("/ mode change /", $eilute, $regs)) { $eilute = "" . $eilute . ""; } $joinregep = '/(\[.+\])\s(.*?)\s(.*?joined\s)(.*)/i'; $partregep = '/^(\[.+\])\s(.+?)\s(.*?)(left irc.*?\s.*?)$/i'; if (preg_match($joinregep, $eilute, $match)) { $eilute = "{$match[1]} --> {$match[2]} joined {$match[4]}\n"; } else if (preg_match($partregep, $eilute, $match)) { $eilute = "{$match[1]} <-- {$match[2]} {$match[4]}\n"; } else { $regep = '/(\[.+\])\s(.*?)\s(.*)/i'; if (preg_match($regep, $eilute, $match)) { $eilute = "{$match[1]} {$match[2]} {$match[3]}\n"; } } return irc_color_decode($eilute) . "
"; } /////////////////////////////////////////////////////////////////////////////// // // function irc_get_color_idx($text, $pos) // /////////////////////////////////////////////////////////////////////////////// // // Tool function for irc_color_decode(): // // Returns the color index at a given position in the specified string. If no // color index is present at that position, it returns an empty string. // // This function has originally been created by Jirka Kysela (aceman@qwerty.cz) // and has been adapted for phpIRC by Till Gerken. // /////////////////////////////////////////////////////////////////////////////// // // Parameters: // $text - string to search in // $pos - position to start searching at // /////////////////////////////////////////////////////////////////////////////// // // Return value: // color code as string // /////////////////////////////////////////////////////////////////////////////// function irc_get_color_idx($text, $pos) { // determine the length of the color code if ((ord($text[$pos]) >= 48) && (ord($text[$pos]) <= 57)) { $cchars = 1; if (($pos + 1) < strlen($text)) { if ((ord($text[$pos + 1]) >= 48) && (ord($text[$pos + 1]) <= 57)) { $cchars = 2; } } } else { // no color code present at given position $cchars = 0; } return (substr($text, $pos, $cchars)); } /////////////////////////////////////////////////////////////////////////////// // // function irc_color_decode($text, $usebgcolor = 0) // /////////////////////////////////////////////////////////////////////////////// // // Decodes IRC color codes (as used by mIRC, Pirch and various other IRC // clients) to valid HTML // // This function has originally been created by Jirka Kysela (aceman@qwerty.cz) // and has been adapted for phpIRC by Till Gerken. // /////////////////////////////////////////////////////////////////////////////// // // Parameters: // $text - string to decode // $usebgcolor - 1=display background color [optional] // /////////////////////////////////////////////////////////////////////////////// // // Return value: // Decoded colored string as HTML // /////////////////////////////////////////////////////////////////////////////// function irc_color_decode($text, $usebgcolor = 0) { // this colors palette is equal to mirc colors palette $color[0] = "#ffffff"; // white $color[1] = "#000000"; // black $color[2] = "#00007f"; // blue $color[3] = "#007f00"; // green $color[4] = "#ff0000"; // light red $color[5] = "#7f0000"; // red $color[6] = "#9f009f"; // magenta $color[7] = "#ff7f00"; // orange $color[8] = "#ffff00"; // yellow $color[9] = "#00ff00"; // light green (lime) $color[10] = "#006464"; // cyan $color[11] = "#00ffff"; // light cyan (aqua) $color[12] = "#0000ff"; // light blue $color[13] = "#c200c2"; // light magenta (pink) $color[14] = "#7a7a7a"; // grey $color[15] = "#a6a6a6"; // light grey (silver) $text = explode("\3", $text); $ctext = $text[0]; if (count($text) > 1) { for ($i = 1; $i < count($text); $i++) { if ($text[$i]) { $ccharslen = strlen($showfgcolor = irc_get_color_idx($text[$i], 0)); if (($ccharslen == 0) || (($showfgcolor = (integer) $showfgcolor) > (count($color) - 1))) { $showfgcolor = -1; } if (($text[$i][$ccharslen] == ",") && ($usebgcolor)) { if (strlen($showbgcolor = irc_get_color_idx($text[$i], $ccharslen + 1))) { $ccharslen += 1 + strlen($showbgcolor); if (($showbgcolor = (integer) $showbgcolor) > (count($color) - 1)) { $showbgcolor = -1; } } else { $showbgcolor = -1; } } else { $showbgcolor = -1; } if ($showfgcolor != -1) { $ctext .= ""; } $ctext .= substr($text[$i], $ccharslen, strlen($text[$i]) - $ccharslen); if ($showfgcolor != -1) { $ctext .= ""; } } } } // bold text $text = explode("\2", $ctext); $ctext = $text[0]; if (count($text) > 1) { for ($i = 1; $i < count($text); $i++) { if ($text[$i]) { $ctext .= "$text[$i]"; } } } // text underlining $text = explode("\37", $ctext); $ctext = $text[0]; if (count($text) > 1) { for ($i = 1; $i < count($text); $i++) { if ($text[$i]) { $ctext .= "$text[$i]"; } } } // italics $text = explode("\26", $ctext); $ctext = $text[0]; if (count($text) > 1) { for ($i = 1; $i < count($text); $i++) { if ($text[$i]) { $ctext .= "$text[$i]"; } } } // symbol $text = explode("\22", $ctext); $ctext = $text[0]; if (count($text) > 1) { for ($i = 1; $i < count($text); $i++) { if ($text[$i]) { $ctext .= "$text[$i]"; } } } // fixed $text = explode("\21", $ctext); $ctext = $text[0]; if (count($text) > 1) { for ($i = 1; $i < count($text); $i++) { if ($text[$i]) { $ctext .= "$text[$i]"; } } } return ("" . $ctext . ""); }