cache_stamps.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_stamps.php 25773 2011-11-22 04:22:39Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. function build_cache_stamps() {
  12. $data = array();
  13. $fillarray = range(0, 99);
  14. $count = 0;
  15. $repeats = $stampicon = array();
  16. foreach(C::t('common_smiley')->fetch_all_by_type(array('stamp','stamplist')) as $stamp) {
  17. if(isset($fillarray[$stamp['displayorder']])) {
  18. unset($fillarray[$stamp['displayorder']]);
  19. } else {
  20. $repeats[] = $stamp['id'];
  21. }
  22. $count++;
  23. }
  24. foreach($repeats as $id) {
  25. reset($fillarray);
  26. $displayorder = current($fillarray);
  27. unset($fillarray[$displayorder]);
  28. C::t('common_smiley')->update($id, array('displayorder'=>$displayorder));
  29. }
  30. foreach(C::t('common_smiley')->fetch_all_by_type('stamplist') as $stamp) {
  31. if($stamp['typeid'] < 1) {
  32. continue;
  33. }
  34. $row = C::t('common_smiley')->fetch_by_id_type($stamp['typeid'], 'stamp');
  35. $stampicon[$row['displayorder']] = $stamp['displayorder'];
  36. }
  37. foreach(C::t('common_smiley')->fetch_all_by_type(array('stamp','stamplist')) as $stamp) {
  38. $icon = $stamp['type'] == 'stamp' ? (isset($stampicon[$stamp['displayorder']]) ? $stampicon[$stamp['displayorder']] : 0) :
  39. ($stamp['type'] == 'stamplist' && !in_array($stamp['displayorder'], $stampicon) ? 1 : 0);
  40. $data[$stamp['displayorder']] = array('url' => $stamp['url'], 'text' => $stamp['code'], 'type' => $stamp['type'], 'icon' => $icon);
  41. }
  42. savecache('stamps', $data);
  43. }
  44. ?>