将RTF格式的文件转成HTML并在网页中显示的代码
将RTF格式的文件转成HTML并在网页中显示的代码,将RTF格式的文件转成HTML并在网页中显示的代码
它是这样工作的,将一个RTF文件上传,然后转成HTML显示出来,代码有点复杂,teaman还要好好研究,好象中文版有点问题。
<html
<body
<?
if(!($userfile)) {
?
<form enctype="multipart/form-data" action="<?print($PHP_SELF);?" method=post
<input type=hidden name="max_file_size" value=2000
Send this file: <input name=userfile type=file
<input type=submit value=Upload
</form
</body
</html
<?
exit;
}
function ProcessTags($tags, $line) {
$html = "";
global $color;
global $size;
global $bullets;
// Remove spaces.
$tags = trim($tags);
// Found the beginning of the bulleted l
// ist.
if(ereg("\pnindent", $tags)) {
$html .= "<ul<li";
$bullets += $line;
$tags = ereg_replace("\par", "", $tags);
$tags = ereg_replace("\(tab)", "", $tags);
}
if($line - $bullets == 0) {
$tags = ereg_replace("\par", "", $tags);
}
elseif($line - $bullets == 1) {
if(ereg("\pntext", $tags)) {
$html .= "<li";
$tags = ereg_replace("\par", "", $tags);
$tags = ereg_replace("\(tab)", "", $tags);
$bullets++;
}
else {
$html .= "</ul";
$bullets = 0;
}
}
// Convert Bold.
if(ereg("\b0", $tags)){ $html .= "</b"; }
elseif(ereg("\b", $tags)) { $html .= "<b"; }
// Convert Italic.
if(ereg("\i0", $tags)){ $html .= "</i"; }
elseif(ereg("\i", $tags)) { $html .= "<i"; }
// Convert Underline.
if(ereg("\ulnone", $tags)){ $html .= "</u"; }
elseif(ereg("\ul", $tags)){ $html .= "<u"; }
// Convert Alignments.
if(ereg("\pard\qc", $tags)) { $html .= "<div align=center"; }
elseif(ereg("\pard\qr", $tags)) { $html .= "<div align=right"; }
elseif(ereg("\pard", $tags)){ $html .= "<div align=left"; }
// Remove pard from the tags so it does
// n't get confused with par.
$tags = ereg_replace("\pard", "", $tags);
&n