toplist.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: toplist.php 34314 2014-02-20 01:04:24Z nemohou $
  7. */
  8. if(!defined('IN_MOBILE_API')) {
  9. exit('Access Denied');
  10. }
  11. $_GET['mod'] = 'forumdisplay';
  12. include_once 'forum.php';
  13. class mobile_api {
  14. function common() {
  15. }
  16. function output() {
  17. global $_G;
  18. $threads = array();
  19. loadcache('mobile_toplist_'.$_G['fid']);
  20. if(!$_G['cache']['mobile_toplist_'.$_G['fid']] || TIMESTAMP - $_G['cache']['mobile_toplist_'.$_G['fid']]['expiration'] > 3600) {
  21. $query = DB::query("SELECT * FROM ".DB::table('forum_thread')." WHERE tid IN (".dimplode($GLOBALS['stickytids']).") ORDER BY lastpost DESC");
  22. while($thread = DB::fetch($query)) {
  23. $threads[] = $thread;
  24. }
  25. $query = DB::query("SELECT * FROM ".DB::table('forum_thread')." WHERE `fid`='".$_G['fid']."' AND `displayorder`='1' ORDER BY lastpost DESC");
  26. while($thread = DB::fetch($query)) {
  27. $threads[] = $thread;
  28. }
  29. savecache('mobile_toplist_'.$_G['fid'], array('variable' => $threads, 'expiration' => TIMESTAMP));
  30. } else {
  31. $threads = $_G['cache']['mobile_toplist_'.$_G['fid']]['variable'];
  32. }
  33. $variable = array(
  34. 'forum_threadlist' => mobile_core::getvalues($threads, array('/^\d+$/')),
  35. );
  36. $variable['forum']['password'] = $variable['forum']['password'] ? '1' : '0';
  37. mobile_core::result(mobile_core::variable($variable));
  38. }
  39. }
  40. ?>