主題: 非外掛程式 -- pLog 內容輸出成為 HTML (二) 作者: WhiteCloud 於 九月 09, 2005, 08:44:34 下午 內容檔案輸出程式如下(說明請參考上一篇):
※ 2005.10.02 有做小修正,說明請看回覆文章 http://forum.lifetype.org.tw/index.php?topic=1124.from1128256464;topicseen#msg7135 ※ 2006.03.30 修正兩行程式 程式碼: <?php if (!defined( "PLOG_CLASS_PATH" )) { define( "PLOG_CLASS_PATH", dirname(__FILE__)."/"); } include_once( PLOG_CLASS_PATH."config/config.properties.php" ); include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" ); // plog 的資料表字首 $strPlogPrefix = $config["db_prefix"]; // 輸出路徑,最後面要加斜線(目錄要設定為可讀寫,例如777) $strArticleIndexPath = PLOG_CLASS_PATH."html/"; // 輸出備份檔名 //$strOutput = "article.htm"; // 網誌名稱 $strBlogName = "White Cloud's Blog"; // 網誌編號 $strBlogNumber = "1"; // 放文章的變數 $strFileContent1 = <<<EOT <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh_TW" lang="zh_TW" dir="ltr"> <head> <title>$strBlogName</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> </head> <body><center> EOT; // $query = "SELECT * FROM plog_articles As a, plog_articles_text As at WHERE a.id=at.article_id AND a.blog_id = 1 ORDER BY a.date DESC"; $strTableArticleText = $strPlogPrefix."articles_text"; $strTableArticle = $strPlogPrefix."articles"; $strTableUsers = $strPlogPrefix."users"; $sql = "select * from $strTableArticleText,$strTableArticle "; $sql = $sql."where $strTableArticleText.article_id = $strTableArticle.id "; $sql = $sql."and $strTableArticle.blog_id = $strBlogNumber "; $sql = $sql."and $strTableArticle.status = 1 "; if ($NUM != "") { $sql = $sql."and $strTableArticle.id > $NUM"; } $articles = new Articles(); $result = $articles->getBlogArticlesByQuery( $sql ); foreach( $result as $article ) { $strId = $article->getId(); $strTopic = $article->getTopic(); $strText = $article->getText(); //$strAuthor = $article->getUser(); $strDate = $article->getDate(); // 由於改用 MySQL 4.1 的關係,取消此行 //$strDate = substr($strDate,0,4)."/".substr($strDate,4,2)."/".substr($strDate,6,2)." ".substr($strDate,8,2).":".substr($strDate,10,2).":".substr($strDate,12,2); $strFileContent = $strFileContent1.'<font size=6 color=green>'.$strTopic.'</font><br><br>'; $strFileContent = $strFileContent.'<table width="80%" border="1" cellpadding="15"><tr><td>'; $strFileContent = $strFileContent.$strText; $strFileContent = $strFileContent."<br><br>"; $strFileContent = $strFileContent."文章日期:".$strDate; $strFileContent = $strFileContent."</td></tr></table>"; $strFileContent = $strFileContent."<br>這是備份頁面,歡迎存檔慢慢欣賞 :-)<br><br>"; // 2006.03.30 修正兩行程式 $strFileContent = $strFileContent."All content copyright (c) 2004 $strBlogName"; $strFileContent = $strFileContent."</center></body></html>"; // 輸出成為 HTML //echo $strFileContent; $strOutput = $strId.".html"; $fp = fopen($strArticleIndexPath.$strOutput, "w"); fputs($fp, $strFileContent); fclose($fp); $strFileContent = $strFileContent1; } header("Location: plog_index.php"); //echo "OK"; ?> |