"; }
elseif(ereg("\pard", $tags)){ $html .= "
"; }
// Remove pard from the tags so it does
// n't get confused with par.
$tags = ereg_replace("\pard", "", $tags);
// Convert line breaks.
if(ereg("\par", $tags)){ $html .= "
"; }
// Use the color table to capture the fo
// nt color changes.
if(ereg("\cf[0-9]", $tags)) {
global $fcolor;
$numcolors = count($fcolor);
for($i = 0; $i $test = "\cf" . ($i + 1);
if(ereg($test, $tags)) {
$color = $fcolor[$i];
}
}
}
// Capture font size changes.
if(ereg("\s[0-9][0-9]", $tags, $temp)) {
$size = ereg_replace("\s", "", $temp[0]);
$size /= 2;
if($size elseif($size elseif($size elseif($size elseif($size elseif($size elseif($size else{ $size = 8; }
}
// If there was a font color or size cha
// nge, change the font tag now.
if(ereg("(\cf[0-9])||(\s[0-9][0-9])", $tags)) {
$html .= "";
}
// Replace ab with alternating spaces
// and nonbreakingwhitespaces.
if(ereg("\(tab)", $tags)) { $html .= " "; }
return $html;
}
function ProcessWord($word) {
// Replace \ with
$word = ereg_replace("[\]{2,}", "\", $word);
// Replace { with {
$word = ereg_replace("[\][{]", "{", $word);
// Replace } with }
$word = ereg_replace("[\][}]", "}", $word);
// Replace 2 spaces with one space.
$word = ereg_replace(" ", " ", $word);
return $word;
}
$color = "000000";
$size = 1;
$bullets = 0;
// Read the uploaded file into an array.
//
$rtfile = file($userfile);
$fileLength = count($rtfile);
// Loop through the rest of the array
for($i = 1; $i /*
** If the line contains "colortbl" then we found the color table.
** We'll have to split it up into each individual red, green, and blue
** Convert it to hex and then put the red, green, and blue back together.
** Then store each into an array called fcolor.
*/
if(ereg("^{\colortbl", $rtfile[$i])) {
// Split the line by the backslash.
$colors = explode("\", $rtfile[$i]);
$numOfColors = count($colors);
for($k = 2; $k // Find out how many different colors th
// ere are.
if(ereg("[0-9]+", $colors[$k], $matches)) {
$match[] = $matches[0];
}
}
// For each color, convert it to hex.
$numOfColors = count($match);
for($k = 0; $k $red = dechex($match[$k]);
$red = $match[$k] $green = dechex($match[$k + 1]);
$green = $match[$k +1] $blue = dechex($match[$k + 2]);
$blue = $match[$k + 2] $fcolor[] = "$red$green$blue";
}
$numOfColors = count($fcolor);
}
// Or else, we parse the line, pulling o
// ff words and tags.
else {
$token = "";
$start = 0;
$lineLength = strlen($rtfile[$i]);
for($k = 0; $k if($rtfile[$i][$start] == "\" && $rtfile[$i][$start + 1] != "\") {
// We are now dealing with a tag.
$token .= $rtfile[$i][$k];
if($rtfile[$i][$k] == " ") {
$newFile[$i] .= ProcessTags($token, $i);
$token = "";
$start = $k + 1;
}
elseif($rtfile[$i][$k] == "
") {
$newFile[$i] .= ProcessTags($token, $i);
$token = "";
}
}
elseif($rtfile[$i][$start] == "{") {
// We are now dealing with a tag.
$token .= $rtfile[$i][$k];
if($rtfile[$i][$k] == "}") {
$newFile[$i] .= ProcessTags($token, $i);
$token = "";
$start = $k + 1;
}
}
else {
// We are now dealing with a word.
if($rtfile[$i][$k] == "\" && $rtfile[$i][$k + 1] != "\" && $rtfile[$i][$k - 1] != "\") {
$newFile[$i] .= ProcessWord($token);
$token = $rtfile[$i][$k];
$start = $k;
}
else {
$token .= $rtfile[$i][$k];
}
}
}
}
}
$limit = sizeof($newFile);
for($i = 0; $i print("$newFile[$i]
");
}
?>