cache_forumrecommend.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_forumrecommend.php 24152 2011-08-26 10:04:08Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. function build_cache_forumrecommend() {
  12. $data = array();
  13. $fids = C::t('forum_forum')->fetch_all_fids();
  14. foreach($fids as $row) {
  15. require_once libfile('function/group');
  16. $recommendlist = C::t('forum_forum')->fetch_all_recommend_by_fid($row['fid']);
  17. foreach($recommendlist as $info) {
  18. $group = array('fid' => $info['fid'], 'name' => $info['name'], 'threads' => $info['threads'], 'lastpost' => $info['lastpost'], 'icon' => $info['icon'], 'membernum' => $info['membernum'], 'description' => $info['description']);
  19. $group['icon'] = get_groupimg($group['icon'], 'icon');
  20. $lastpost = array(0, 0, '', '');
  21. $group['lastpost'] = is_string($group['lastpost']) ? explode("\t", $group['lastpost']) : $group['lastpost'];
  22. $group['lastpost'] =count($group['lastpost']) != 4 ? $lastpost : $group['lastpost'];
  23. list($lastpost['tid'], $lastpost['subject'], $lastpost['dateline'], $lastpost['author']) = $group['lastpost'];
  24. if($lastpost['tid']) {
  25. $lastpost['dateline'] = dgmdate($lastpost['dateline'], 'Y-m-d H:i:s');
  26. if($lastpost['author']) {
  27. $lastpost['encode_author'] = rawurlencode($lastpost['author']);
  28. }
  29. $group['lastpost'] = $lastpost;
  30. } else {
  31. $group['lastpost'] = '';
  32. }
  33. $data[$row['fid']][] = $group;
  34. }
  35. }
  36. savecache('forumrecommend', $data);
  37. }
  38. ?>