建个php文件 命名为 makehtml_daily.inc.php 在里面写上以下代码

<?php
/*
调用论坛的10个最新帖子,输出为html格式,通过计划任务更新,更新时间可以在计划任务中设置
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$newhtml = '';
$query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid=f.fid and f.fid IN('8','2','38','50') ORDER BY t.dateline DESC LIMIT 0, 10");
while($new = $db->fetch_array($query)) {
$newsubject = cutstr($new['subject'],42);
$newurl = 'http://www.seowhy.com/bbs/thread-'.$new['tid'].'-1-1.html';
$newhtml .= '<li><a target="_blank" href="'.$newurl.'">'.$newsubject.'</a></li>';
}
$newhtml = convert_data($newhtml);

writehtml(‘newhtml.htm’, $newhtml);
//写入html文件
function writehtml($file, $html) {
global $timestamp, $_DCACHE;
$yearmonth = gmdate(‘Ym’, $timestamp + $_DCACHE[‘settings’][‘timeoffset’] * 3600);
$logdir = DISCUZ_ROOT.’./forumdata/cache/’;
$logfile = $logdir.$file;
if($fp = @fopen($logfile, ‘w’)) {
@flock($fp, 2);
fwrite($fp, “$html”);
fclose($fp);
}
}
function convert_data($data) {

include DISCUZ_ROOT.’include/chinese.class.php’;
$c = new Chinese(‘gbk’, ‘utf8’);

$data = $c->Convert($data);
return $data;
}
?>

将php文件上传到 通过ftp上传到./include/crons/ 目录中

在论坛的后台,其他->计划任务—>增添一个任务,然后点击这个任务的“编辑”,在“任务脚本:”的输入框里输入:makehtml_daily.inc.php
其他更新时间设置,可以自己选择。

然后,通过这个地址:http://www.yourdomain.com/bbs/forumdata/cache/newhtml.htm  可以获得HTML格式的论坛帖子。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。