error_reporting(0);
include "ads.inc.php";
require("/home/mibbit/include/accesssearchdb.inc.php");
function topic_format_html($topicin, $maxlength = -1, $dourl = -1, $dochan = -1) {
$count = 0;
$topicout = "";
$lcount = 0;
$flags['c']['b'] = false;
$flags['c']['k'] = false;
$flags['c']['u'] = false;
$flags['c']['r'] = false;
$flags['p']['b'] = false;
$flags['p']['k'] = false;
$flags['p']['u'] = false;
$flags['p']['r'] = false;
$colours['cf'] = "#000000";
$colours['cb'] = "";
$colours['pf'] = "#000000";
$colours['pb'] = "";
$colours['s'] = "";
$colourcode[0] = "#FFFFFF";
$colourcode[1] = "#000000";
$colourcode[2] = "#000080";
$colourcode[3] = "#008000";
$colourcode[4] = "#FF0000";
$colourcode[5] = "#800000";
$colourcode[6] = "#800080";
$colourcode[7] = "#FF8000";
$colourcode[8] = "#FFFF00";
$colourcode[9] = "#00FF00";
$colourcode[10] = "#008080";
$colourcode[11] = "#00FFFF";
$colourcode[12] = "#0000FF";
$colourcode[13] = "#FF00FF";
$colourcode[14] = "#808080";
$colourcode[15] = "#C0C0C0";
$colourcode[16] = "#000000";
$colourcode[17] = "#000000";
$colourcode[18] = "#000000";
$colourcode[19] = "#000000";
$topicin = htmlspecialchars($topicin, ENT_COMPAT, "UTF-8");
$topiclen = strlen($topicin);
$topicout .= "";
for ($count=0; $count<$topiclen; $count++) {
$chr = substr($topicin, $count, 1);
$cparam = substr($topicin, $count + 1, 5);
if ( ord($chr) == 2 ) {
if ( $flags['c']['b'] ) {
$flags['c']['b'] = false;
} else {
$flags['c']['b'] = true;
}
}
if ( ord($chr) == 31 ) {
if ( $flags['c']['u'] ) {
$flags['c']['u'] = false;
} else {
$flags['c']['u'] = true;
}
}
if ( ord($chr) == 22 ) {
if ( $flags['c']['r'] ) {
$flags['c']['r'] = false;
} else {
$flags['c']['r'] = true;
$flags['c']['k'] = false;
}
}
if ( ord($chr) == 3 ) {
if ( $flags['c']['k'] ) {
$flags['c']['k'] = false;
} else {
$flags['c']['k'] = true;
$flags['c']['r'] = false;
}
preg_match_all("/^([0-1]?[0-9])?(,([0-1]?[0-9]))?/", $cparam, $matched);
if ( $matched[0][0] != "" ) {
$flags['c']['k'] = true;
$flags['c']['r'] = false;
if ( $matched[1][0] != "" ) {
$colours['cf'] = $colourcode[(integer) $matched[1][0]];
}
if ( $matched[3][0] != "" ) {
$colours['cb'] = $colourcode[(integer) $matched[3][0]];
}
$count += strlen($matched[0][0]);
}
if ( $flags['c']['k'] == false ) {
$colours['cf'] = "#000000";
$colours['cb'] = "";
}
}
if ( ord($chr) == 15 ) {
$flags['c']['b'] = false;
$flags['c']['u'] = false;
$flags['c']['r'] = false;
$flags['c']['k'] = false;
$colours['cf'] = "#000000";
$colours['cb'] = "";
$colours['pf'] = "#000000";
$colours['pb'] = "";
}
$cstyle = "";
if ( ( $flags['c']['b'] != $flags['p']['b'] ) or ( $flags['c']['u'] != $flags['p']['u'] ) or ( $flags['c']['r'] != $flags['p']['r'] ) or ( $flags['c']['k'] != $flags['p']['k'] ) or ( $colours['cf'] != $colours['pf'] ) or ( $colours['cb'] != $colours['pb'] ) ) {
if ( $flags['c']['b'] != $flags['p']['b'] ) {
$flags['p']['b'] = $flags['c']['b'];
}
if ( $flags['c']['u'] != $flags['p']['u'] ) {
$flags['p']['u'] = $flags['c']['u'];
}
if ( $flags['c']['r'] != $flags['p']['r'] ) {
$flags['p']['r'] = $flags['c']['r'];
}
if ( $flags['c']['k'] != $flags['p']['k'] ) {
$flags['p']['k'] = $flags['c']['k'];
}
if ( $flags['c']['b'] ) {
$cstyle .= "font-weight: bold; ";
}
if ( $flags['c']['u'] ) {
$cstyle .= "text-decoration: underline; ";
}
if ( $flags['c']['r'] ) {
if ( $colours['cb'] == "" ) {
$cstyle .= "color:#FFFFFF; background-color:".$colours['cf']."; ";
} else {
$cstyle .= "color:".$colours['cb']."; background-color:".$colours['cf']."; ";
}
$colours['pf'] = $colours['pf'];
$colours['cb'] = $colours['cb'];
}
if ( $colours['cb'] == "" ) {
$cstyle .= "color:".$colours['cf']."; ";
} else {
$cstyle .= "color:".$colours['cf']."; background-color:".$colours['cb']."; ";
}
$colours['pf'] = $colours['cf'];
$colours['pb'] = $colours['cb'];
$topicout .= "";
} else {
if ( $maxlength != -1 ) {
if ( $maxlength > $lcount ) {
$topicout .= $chr;
}
} else {
$topicout .= $chr;
}
$lcount++;
}
//$topicout .= "";
}
if ( $flags['c']['b'] ) {
$flags['c']['b'] = false;
}
if ( $flags['c']['u'] ) {
$flags['c']['u'] = false;
}
if ( $flags['c']['k'] ) {
$flags['c']['k'] = false;
}
if ( $flags['c']['r'] ) {
$flags['c']['r'] = false;
}
$topicout .= "";
if ( $dourl ) {
$topicout = preg_replace("/(style=\"([^\"]*)\"[^<]*?)?(http:\/\/[^\s<]*)/i", "$1$3", $topicout);
$topicout = preg_replace("/(style=\"([^\"]*)\"[^<]*?)?(https:\/\/[^\s<]*)/i", "$1$3", $topicout);
$topicout = preg_replace("/(style=\"([^\"]*)\"[^<]*?)?(ftp:\/\/[^\s<]*)/i", "$1$3", $topicout);
$topicout = preg_replace("/(style=\"([^\"]*)\"[^<]*?)?(irc:\/\/[^\s<]*)/i", "$1$3", $topicout);
}
$topicout = str_replace(" | ", "
", $topicout); // | ", $topicout);
$topicout = str_replace(" || ", "
", $topicout); // || ", $topicout);
if ( $maxlength == -1 ) {
return $topicout;
} else {
if ( $topiclen < $maxlength ) {
return $topicout;
} else {
return $topicout."...";
}
}
}
?>
Channel information
|