dz_digest.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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: dz_digest.php 33590 2013-07-12 06:39:08Z andyzheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class dz_digest extends extends_data {
  12. function __construct() {
  13. parent::__construct();
  14. }
  15. function common() {
  16. global $_G;
  17. $this->page = intval($_GET['page']) ? intval($_GET['page']) : 1;
  18. $start = ($this->page - 1)*$this->perpage;
  19. $num = $this->perpage;
  20. loadcache('forum_guide');
  21. $dateline = 0;
  22. $maxnum = 50000;
  23. $_G['setting']['guide'] = unserialize($_G['setting']['guide']);
  24. if($_G['setting']['guide']['digestdt']) {
  25. $dateline = time() - intval($_G['setting']['guide']['digestdt']);
  26. }
  27. $maxtid = C::t('forum_thread')->fetch_max_tid();
  28. $limittid = max(0,($maxtid - $maxnum));
  29. $tids = array_slice($_G['cache']['forum_guide']['digest']['data'], $start ,$num);
  30. $query = C::t('forum_thread')->fetch_all_for_guide('digest', $limittid, $tids, $_G['setting']['heatthread']['guidelimit'], $dateline);
  31. $fids = array();
  32. loadcache('forums');
  33. foreach($_G['cache']['forums'] as $fid => $forum) {
  34. if($forum['type'] != 'group' && $forum['status'] > 0 && (!$forum['viewperm'] && $_G['group']['readaccess']) || ($forum['viewperm'] && forumperm($forum['viewperm']))) {
  35. $fids[] = $fid;
  36. }
  37. }
  38. $list = array();
  39. $n = 0;
  40. foreach($query as $thread) {
  41. if(empty($tids) && ($thread['isgroup'] || !in_array($thread['fid'], $fids))) {
  42. continue;
  43. }
  44. if($thread['displayorder'] < 0) {
  45. continue;
  46. }
  47. if($tids || ($n >= $start && $n < ($start + $num))) {
  48. $list[$thread['tid']] = $thread;
  49. }
  50. $n ++;
  51. }
  52. $threadlist = array();
  53. if($tids) {
  54. foreach($tids as $key => $tid) {
  55. if($list[$tid]) {
  56. $threadlist[$key] = $list[$tid];
  57. }
  58. }
  59. } else {
  60. $threadlist = $list;
  61. }
  62. unset($list);
  63. foreach($threadlist as $thread) {
  64. $this->field('author', '0', $thread['author']);
  65. $this->field('dateline', '0', $thread['dateline']);
  66. $this->field('replies', '1', $thread['replies']);
  67. $this->field('views', '2', $thread['views']);
  68. $this->id = $thread['tid'];
  69. $this->title = $thread['subject'];
  70. $this->image = '';
  71. $this->icon = '1';
  72. $this->poptype = '0';
  73. $this->popvalue = '';
  74. $this->clicktype = 'tid';
  75. $this->clickvalue = $thread['tid'];
  76. $this->insertrow();
  77. }
  78. }
  79. }
  80. ?>