📄 advanced_whatsnew.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Discuz! 用户使用说明书 - 高级应用</title><link rel="stylesheet" href="discuz_guide.css">
<base target="_blank">
</head>
<body leftmargin="0" rightmargin="0" topmargin="0">
<script language="JavaScript" src="header.js"></script>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td class="title">本栏目下相关链接</td></tr>
<tr><td><br><ul><script language="JavaScript" src="advanced.js"></script></ul><br></td></tr>
<tr><td class="title">页面新帖调用工具</td></tr>
<tr><td><br>
<p class="subtitle">新帖调用功能简介<ul>
<p>Discuz! 随软件包提供了 html 页面新帖调用的工具 whatsnew.php,位于 ./upload 目录下。这是一个可以用被普通 html 页面通过
JavaScript 调用的在页面中显示论坛新帖子的程序。您可以通过给定不同的参数,在不需要编程的情况下,实现在 html 页面显示所需的论坛
帖子。同时该工具已经应用了动态缓存技术,相对直接数据库读取的方式更为快速和稳定。
</ul><p class="subtitle">基本设置<ul>
<p>使用之前需对 whatsnew.php 进行参数修改,打开该程序可以看到以下内容:
<br><br><table width="80%" cellpadding="0" cellspacing="0" border="0" class="code">
<tr><td><pre>
$enabled = 1; // Whether to enable what's new feature, 1=yes, 0=no
// 是否启用 what's new 功能, 1=是, 0=否
$reflimit = 0; // Only permit same site pages to include this script, 1=yes, 0=no
// 只允许本域名下的页面调用本程序, 1=是, 0=否
$cachelife = 1800; // Cache life span(sec.)
// 缓存更新时间(秒),通常不需要更改
$num = 10; // Default amount of new threads
// 默认显示新贴数量
$length = 50; // Max. length of title(bytes)
// 默认标题最大字节数
$pre = '<li>'; // Prefix of title
// 标题显示前缀
</pre></td></tr></table>
<p><b>如果您需要使用新帖调用功能,请务必将 $enabled 设置为 1,否则将显示错误信息。</b>其他参数,请根据旁边的注释设置相应的值,
在大多数情况下默认的配置是不需要改动的。
</ul><p class="subtitle">动态参数<ul>
<p>除了上述在程序中设定的固定参数外,还可以通过 URL 的 GET 方式指定其他的动态参数:
<p><ul>
<li>num:显示新帖数量,如果指定此参数,可不按照默认设置(whatsnew.php 中的 $num)显示
<li>length:标题最大字节数,如果指定此参数,可不按照默认设置(whatsnew.php 中的 $length)显示
<li>finin:读取某些指定论坛的新帖,多个论坛 id 之间,以“_”分隔
<li>finout:不读取某些指定论坛的新帖,多个论坛 id 之间,以“_”分隔
</ul>
</ul><p class="subtitle">调用实例<ul>
<p>在您的主页中需要放置论坛新贴的地方加入如下代码(地址需改动):
<br><br><table width="80%" cellpadding="0" cellspacing="0" border="0" class="code">
<tr><td><pre>
<script src="http://your.com/discuz/whatsnew.php?动态参数"></script>
</pre></td></tr></table>
<p>地址中“动态参数”为条件查询所设置。目前提供可选读取论坛和可选不读取论坛功能,即可以显示出某一个(或几个)论坛的新贴,或
排除/不显示某一个(或几个)论坛新帖。要用此功能的朋友需先得到论坛的 fid。Discuz! 首页论坛链接为 forumdisplay.php?fid=x 格式,
其中 x 就是论坛的 fid 号码。
<p>例如: <b>需要显示 fid 为 2 的论坛的新帖</b>,代码为:
<br><br><table width="80%" cellpadding="0" cellspacing="0" border="0" class="code">
<tr><td><pre>
<script src="http://your.com/discuz/whatsnew.php?fidin=2"></script>
</pre></td></tr></table>
<p>再如: <b>显示 fid 为 2 和 10 两个论坛的新帖</b>,代码为:
<br><br><table width="80%" cellpadding="0" cellspacing="0" border="0" class="code">
<tr><td><pre>
<script src="http://your.com/discuz/whatsnew.php?fidin=2_10"></script>
</pre></td></tr></table>
<p>fid 之间用下划线(_)分割即可。
<p>再如:<b>显示除了 fid 为 2 和 10 以外所有论坛的新帖,且条目数为 100</b>,代码为:
<br><br><table width="80%" cellpadding="0" cellspacing="0" border="0" class="code">
<tr><td><pre>
<script src="http://yourhost。com/cdb/whatsnew。php?fidout=2_10&num=100"></script>
</pre></td></tr></table>
<p>或:<b>显示全部论坛新帖,条目数为 50,标题最大长度为 100</b>,代码为:
<br><br><table width="80%" cellpadding="0" cellspacing="0" border="0" class="code">
<tr><td><pre>
<script src="http://yourhost。com/cdb/whatsnew。php?num=50&length=100"></script>
</pre></td></tr></table>
<p>这样就可以在 html 页面里显示论坛的新帖和链接了。
</ul><p class="subtitle">注意事项<ul>
<p>从 Discuz! 3.1.2 开始,whatsnew。php 被重新编写,可支持使用文件 cache,每 100 秒自动更新。效率上比以往提高非常多,同时需要
./forumdata 目录属性为 777(可读写),并且可以正常使用 unlink() 函数删除过期的 cache 文件。不满足以上条件将无法使用 whatsnew.php
调用新帖。
</ul><br></td></tr><tr><td class="title">新帖调用常见错误提示</td></tr>
<tr><td><br>
<p class="subtitle">功能未启用或来路检查错误<ul>
<table width="80%" cellpadding="0" cellspacing="0" border="0" class="code">
<tr><td><pre>
Access denied. The webmaster did not enable this feature or referer restriction is taking effect.
</pre></td></tr></table>
<p>请将 whatsnew.php 中 $enabled 变为设置为 1 以启用新帖调用功能。如果仍然出现该提示,可能是打开了来路检查($reflimit),此
选项能防止其他网站非法调用您的新帖,但同时也要求调用新帖的 html 页面必须与调用程序(whatsnew.php)在同一个域名下才可即可。
遇有这种情况,可关闭 $reflimit 来路检查,或将页面与 whatsnew.php 放置在同一域名下。
</ul><p class="subtitle">缓存写入错误<ul>
<table width="80%" cellpadding="0" cellspacing="0" border="0" class="code">
<tr><td><pre>
Unable to write to whatsnew's cache file!
Please chmod ./forumdata to 777, delete all
"whatsnew_xxx.php" files and try again.
</pre></td></tr></table>
<p>./forumdata 无法写入或不存在,请将该目录属性设置为 777,并删除其中所有的 whatsnew_xxx。php 文件后再试。
</ul></td></tr></table>
<script language="JavaScript" src="footer.js"></script>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -