它是這樣工作的,將一個RTF文件上傳,然后轉成HTML顯示出來,代碼有點復雜,teaman還要好好研究,好象中文版有點問題。

<html>
<body>
<?
if(!($userfil " /> 乌克兰成人性色生活片,无码毛片内射白浆视频,婷婷亚洲五月色综合久久

天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

將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);
    // Convert line breaks.
    if(ereg("///par", $tags)){ $html .= "<br>"; }
    // 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 < $numcolors; $i++) {
    $test = "///cf" . ($i + 1);
    if(ereg($test, $tags)) {
    $color = $fcolor[$i];
    }
    }
    }
    // Capture font size changes.
    if(ereg("///fs[0-9][0-9]", $tags, $temp)) {
    $size = ereg_replace("///fs", "", $temp[0]);
    $size /= 2;
    if($size <= 10) { $size = 1; }
    elseif($size <= 12) { $size = 2; }
    elseif($size <= 14) { $size = 3; }
    elseif($size <= 16) { $size = 4; }
    elseif($size <= 18) { $size = 5; }
    elseif($size <= 20) { $size = 6; }
    elseif($size <= 22) { $size = 7; }
    else{ $size = 8; }
    }
    // If there was a font color or size cha
    //     nge, change the font tag now.
    if(ereg("(///cf[0-9])||(///fs[0-9][0-9])", $tags)) {
    $html .= "</font><font size=$size color=$color>";
    }
    // Replace /tab 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 < $fileLength; $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 < $numOfColors; $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 < $numOfColors; $k += 3) {
    $red = dechex($match[$k]);
    $red = $match[$k] < 16 ? "0$red" : $red;
    $green = dechex($match[$k + 1]);
    $green = $match[$k +1] < 16 ? "0$green" : $green;
    $blue = dechex($match[$k + 2]);
    $blue = $match[$k + 2] < 16 ? "0$blue" : $blue;
    $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 < $lineLength; $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] == "/n") {
    $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 < $limit; $i++) {
    print("$newFile[$i]/n");
    }
    ?>
    </body>
    </html>

                 
  

php技術將RTF格式的文件轉成HTML并在網頁中顯示的代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产AV天堂亚洲AV麻豆 | 神马电影dy888午夜我不卡 | 亚洲色图在线视频 | 狼好色有你好看 | 美女被爆羞羞天美传媒 | 日本xxxx裸体xxxx | 99久在线国内在线播放免费观看 | 亚洲国产系列一区二区三区 | 久久这里只精品国产99re66 | 99精品在线观看 | 国产亚洲视频精彩在线播放 | 十次啦中文网 | 高清欧美性猛交xxxx黑人猛交 | 久久精品动漫网一区二区 | 在线观看亚洲免费视频 | 国内精品视频一区二区在线观看 | 亚洲成人免费在线观看 | 亚洲精品美女久久777777 | 欧美高跟镣铐bdsm视频 | 国产日韩欧美另类 | 双手绑在床头调教乳尖 | 天美传媒色情原创精品 | 成人区精品一区二区不卡AV免费 | 一本之道高清在线观看免费 | 精品无码三级在线观看视频 | AV精品爆乳纯肉H漫网站 | www黄色com| 国产日韩精品一区二区三区在线 | JAVAPARSER丰满白老师 | 九九免费高清在线观看视频 | 久久精品伊人 | 99久久香蕉国产线看观看 | 国产美女视频一区二区二三区 | 国产成人无码视频一区二区三区 | 全彩无翼污之邪恶女教师 | 九色PORNY真实丨国产免费 | 日日色在线影院 | 成人片在线播放 | 亚洲AV噜噜狠狠网址蜜桃尤物 | 色AV色婷婷96人妻久久久 | 国产精品亚洲AV毛片一区二区三区 |