Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[插件] [3.25]帖子自动生成静态 html For D4.1

[复制链接]
魔焰男孩 发表于 2006-3-5 15:21:48 | 显示全部楼层 |阅读模式
程序信息================================
程序名称: 帖子自动生成静态 html
程序版本: 1.0.0
程序作者: 魔焰男孩
运行平台: Discuz! 4.1.0
修改文件:
修改模板:
增加文件:
增加模板:
数据升级:
安装难度: 较难
技术支持: https://discuz.dismall.com


程序功能================================
->帖子生成静态 html 文件
->主题列表的帖子地址显示为静态连接
->可以自主选择某个板块是否自动生成 html
->允许动态页面与静态页面之间切换
->自动转换标签的地址为url地址
->分类别储存生成的 html 文件
->发表帖子、回复自动更新指定帖子


其他说明================================
转帖请保留出处!
本程序对论坛文件改动较大, 请在安装前备份您的论坛文件和数据库。


安装方法================================
1. 打开论坛后台(系统设置), 依次打开 数据库 - 数据库升级, 输入以下内容并提交执行:

  1. ALTER TABLE cdb_forums ADD createhtml Tinyint(1) NOT NULL DEFAULT '0'
复制代码


2. 打开文件 ./admincp/forums.inc.php, 查找:

  1.                         showsetting('forums_edit_jammer', 'jammernew', $forum['jammer'], 'radio');
复制代码

在下面添加上:

  1.                         showsetting('forums_edit_createhtml', 'createhtmlnew', $forum['createhtml'], 'radio');
复制代码

再次查找:

  1. jammer='$jammernew',
复制代码

在后面(不是下面)添加上(注意前面有一个空格):

  1. createhtml='$createhtmlnew',
复制代码

修改完成后, 保存文件。

3. 打开文件 ./templates/default/admincp.lang.php, 查找:

  1.         'forums_edit_anonymous' => '允许匿名发贴:',
复制代码

在上面添加上:

  1.         'forums_edit_createhtml' => '允许自动生成 html 页面:',
  2.         'forums_edit_createhtml_comment' => '选择“是”将会自动生成本版帖子的 html 页面,增加对搜索引擎的友好度,减轻服务器的负担',
复制代码

修改完成后, 保存文件。

4. 下载附件, 将里面的所有文件按照存放格式上传到论坛根目录。

5. 打开 ./templates/default/ 目录, 复制里面的 viewthread.htm, 然后在这个目录里面粘贴, 将粘贴的文件“复件 viewthread.htm”重名名为:

  1. viewthread_html.htm
复制代码


6. 打开模板文件 viewthread_html.htm, 查找:

  1. {template header}
复制代码

替换为:

  1. <script language="JavaScript" src="{$boardurl}header.php"></script>
  2. <script language="JavaScript" src="{$boardurl}include/common.js"></script>
复制代码

再次查找:

  1. <td class="altbg2"><a href="redirect.php?fid=$fid&tid=$tid&goto=nextnewset" style="font-weight: normal">{lang next_thread}</a></td>
复制代码

在下面添加:

  1. <td class="altbg2"><a href="viewthread.php?tid=$tid&view=1" style="font-weight: normal">动态页面</a></td>
复制代码

修改完成后, 保存文件。

7. 打开模板文件 forumdisplay.htm, 查找:

  1.                 <a href="viewthread.php?tid=$thread[tid]&extra=$extra"$thread[highlight]>$thread[subject]</a>
复制代码

替换为:

  1.                 <!--{if file_exists('htmdata/' . $fid . '/' . $thread['tid'] . '/' . $thread['tid'] . '_1_' . $styleid . '.htm') && $forum['createhtml']}-->
  2.                 <a href="htmdata/$fid/$thread[tid]/$thread[tid]_1_$styleid.htm">$thread[subject]</a>
  3.                 <!--{else}-->
  4.                 <a href="viewthread.php?tid=$thread[tid]&extra=$extra"$thread[highlight]>$thread[subject]</a>
  5.                 <!--{/if}-->
复制代码

修改完成后, 保存文件。

8. 打开文件 ./forumdisplay.php, 查找(共2处):

  1. f.threads,
复制代码

在后面(不是下面)添加上(注意前面有一个空格):

  1. f.createhtml,
复制代码


9. 打开 ./viewthread.php, 查找:

  1. $oldtopics = isset($_DCOOKIE['oldtopics']) ? $_DCOOKIE['oldtopics'] : 'D';
复制代码

在上面添加:

  1. @$page = isset($page) ? $page : 1;
  2. $htmlfile = "./htmdata/{$thread['fid']}/{$tid}/{$tid}_{$page}_{$styleid}.htm";
  3. $phpview = 0;
  4. if(@$_GET['view']) {
  5.         setcookie('php_view', true, $timestamp + 60 * 10);
  6.         $phpview = 1;
  7. } else {
  8.         if(@$_COOKIE['php_view']) $view = 1;
  9.         if(@$_GET['view'] == 'htm') {
  10.                 setcookie('php_view', true, $timestamp - 86400);
  11.                 $phpview = 0;
  12.         }
  13. }
  14. if(!isset($phpview) && !@$phpview) {
  15.         if(file_exists($htmlfile)) {
  16.                 header('location: ' . $htmlfile);
  17.         } else {
  18.                 ob_start();
  19.         }
  20. }

复制代码

再次查找:

  1. include template('viewthread');
复制代码

替换为:

  1.         if(!$phpview && $discuz_uid && !$adminid && $forum['createhtml'] && !$thread['poll']) {
  2.                 include template('viewthread_html');
  3.                 $html = ob_get_contents();
  4.                 ob_end_clean();
  5.                 include('./include/htmdata.func.php');
  6.                 createhtml(url_tags($html), $thread['fid'], $tid, $page, $styleid);
  7.                 header('location: ' . $htmlfile);
  8.         } else {
  9.                 include template('viewthread');
  10.         }

复制代码


10. 打开文件 ./post.php, 查找:

  1. if($action == 'newthread') {
复制代码

在上面添加:

  1. include('./include/htmdata.func.php');
  2. delthread($forum['fid'], $tid);
复制代码


卸载方法================================
1. 进入后台升级数据库, 执行:

  1. ALTER TABLE cdb_forums DROP createhtml
复制代码


2. 删除所有您添加的代码和文件。

3. 删除 htmdata 目录。

[ 本帖最后由 魔焰男孩 于 2006-3-25 20:28 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

评分

1

查看全部评分

 楼主| 魔焰男孩 发表于 2006-3-5 15:22:03 | 显示全部楼层
预留
回复

使用道具 举报

scropion~ 发表于 2006-3-5 15:23:33 | 显示全部楼层
板凳啊 哈哈 顶 支持
回复

使用道具 举报

sw08 发表于 2006-3-5 15:25:04 | 显示全部楼层
我是用修改服务器配置文件做到静态的~
回复

使用道具 举报

望风的鸟 发表于 2006-3-5 15:25:25 | 显示全部楼层
哈哈
回复

使用道具 举报

望风的鸟 发表于 2006-3-5 15:28:56 | 显示全部楼层
试试去
回复

使用道具 举报

elefee 发表于 2006-3-5 15:38:21 | 显示全部楼层
占位
回复

使用道具 举报

netscope 发表于 2006-3-5 15:40:44 | 显示全部楼层
虽然思路不错,但是纯支持
回复

使用道具 举报

35ren 发表于 2006-3-5 15:41:11 | 显示全部楼层
学习下。。。
回复

使用道具 举报

hklcf 发表于 2006-3-5 15:43:06 | 显示全部楼层
占位~
MJJ
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-3 04:57 , Processed in 0.113104 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表