cache.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * 清理缓存
  4. ***/
  5. defined('InShopNC') or exit('Access Invalid!');
  6. class cacheControl extends SystemControl
  7. {
  8. protected $cacheItems = array(
  9. 'setting', // 基本缓存
  10. 'seo', // SEO缓存
  11. 'groupbuy_price', // 抢购价格区间
  12. 'nav', // 底部导航缓存
  13. 'express', // 快递公司
  14. 'store_class', // 店铺分类
  15. 'store_grade', // 店铺等级
  16. 'store_msg_tpl', // 店铺消息
  17. 'member_msg_tpl', // 用户消息
  18. 'consult_type', // 咨询类型
  19. 'circle_level', // 圈子成员等级
  20. );
  21. public function __construct()
  22. {
  23. parent::__construct();
  24. Language::read('cache');
  25. }
  26. /**
  27. * 清理缓存
  28. */
  29. public function clearOp()
  30. {
  31. if (!chksubmit()) {
  32. Tpl::showpage('cache.clear');
  33. return;
  34. }
  35. $lang = Language::getLangContent();
  36. // 清理所有缓存
  37. if ($_POST['cls_full'] == 1) {
  38. foreach ($this->cacheItems as $i) {
  39. dkcache($i);
  40. }
  41. // 表主键
  42. Model::dropTablePkArrayCache();
  43. // 商品分类
  44. dkcache('gc_class');
  45. dkcache('all_categories');
  46. dkcache('goods_class_seo');
  47. dkcache('class_tag');
  48. // 广告
  49. Model('adv')->makeApAllCache();
  50. // 首页
  51. Model('web_config')->getWebHtml('index', 1);
  52. delCacheFile('index');
  53. } else {
  54. $todo = (array) $_POST['cache'];
  55. foreach ($this->cacheItems as $i) {
  56. if (in_array($i, $todo)) {
  57. dkcache($i);
  58. }
  59. }
  60. // 表主键
  61. if (in_array('table', $todo)) {
  62. Model::dropTablePkArrayCache();
  63. }
  64. // 商品分类
  65. if (in_array('goodsclass', $todo)) {
  66. dkcache('gc_class');
  67. dkcache('all_categories');
  68. dkcache('goods_class_seo');
  69. dkcache('class_tag');
  70. }
  71. // 广告
  72. if (in_array('adv', $todo)) {
  73. Model('adv')->makeApAllCache();
  74. }
  75. // 首页
  76. if (in_array('index', $todo)) {
  77. Model('web_config')->getWebHtml('index', 1);
  78. delCacheFile('index');
  79. }
  80. }
  81. $this->log(L('cache_cls_operate'));
  82. showMessage($lang['cache_cls_ok']);
  83. }
  84. }