cache_heats.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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: cache_heats.php 27425 2012-01-31 06:53:25Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. function build_cache_heats() {
  12. global $_G;
  13. $addsql = '';
  14. $data = array();
  15. if(discuz_process::islocked('update_heats_list')) {
  16. return false;
  17. }
  18. if($_G['setting']['indexhot']['status']) {
  19. require_once libfile('function/post');
  20. $_G['setting']['indexhot'] = array(
  21. 'status' => 1,
  22. 'limit' => intval($_G['setting']['indexhot']['limit'] ? $_G['setting']['indexhot']['limit'] : 10),
  23. 'days' => intval($_G['setting']['indexhot']['days'] ? $_G['setting']['indexhot']['days'] : 7),
  24. 'expiration' => intval($_G['setting']['indexhot']['expiration'] ? $_G['setting']['indexhot']['expiration'] : 900),
  25. 'messagecut' => intval($_G['setting']['indexhot']['messagecut'] ? $_G['setting']['indexhot']['messagecut'] : 200)
  26. );
  27. $messageitems = 2;
  28. $limit = $_G['setting']['indexhot']['limit'];
  29. foreach(C::t('forum_thread')->fetch_all_heats() as $heat) {
  30. $post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($heat['tid']);
  31. $heat = array_merge($heat, (array)$post);
  32. if($limit == 0) {
  33. break;
  34. }
  35. if($messageitems > 0) {
  36. $heat['message'] = !$heat['price'] ? messagecutstr($heat['message'], $_G['setting']['indexhot']['messagecut']) : '';
  37. $data['message'][$heat['tid']] = $heat;
  38. } else {
  39. unset($heat['message']);
  40. $data['subject'][$heat['tid']] = $heat;
  41. }
  42. $messageitems--;
  43. $limit--;
  44. }
  45. $data['expiration'] = TIMESTAMP + $_G['setting']['indexhot']['expiration'];
  46. }
  47. savecache('heats', $data);
  48. discuz_process::unlock('update_heats_list');
  49. }
  50. ?>