BoonKiong.com2026™

人气 12

Discuz! 实现点击随机访问一个帖子,每次都不一样! [复制链接]

boonkiong 昨天 21:25

创建一个文件,如:rand.php

写入如下代码:

  1. <?php

  2. define('APPTYPEID', 127);

  3. define('CURSCRIPT', 'rand');

  4. require './source/class/class_core.php';

  5. $discuz = & discuz_core::instance();$discuz->cachelist = $cachelist;$discuz->init();

  6. $tid=DB::result_first("select tid from ".DB::table('forum_thread')." where displayorder>=0 order by rand()");

  7. $url=$_G['siteurl'].'forum.php?mod=viewthread&tid='.$tid;

  8. dheader("location: $url");



  9. ?>
复制代码


然后将 rand.php 上传至您的论坛根目录(即与 forum.php、home.php 相同的目录),将 https://你的域名/rand.php 设置到你要放置的菜单位置!

就能实现上述的功能了!


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

您还未登录

随手拍~~:

置顶文章~~:

热度会员~~:

boonkiongadminJustinIroms

手机版|小黑屋|网站地图|文强阁

GMT+8, 2026-7-12 05:09 , Processed in 0.041515 second(s), 23 queries .

Powered by Discuz! X3.5  © 2001-2017 Discuz Team.