cache.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. 'area', // 省市区地址
  21. 'home_goods', // 首页商品数据
  22. );
  23. public function __construct()
  24. {
  25. parent::__construct();
  26. Language::read('cache');
  27. }
  28. /**
  29. * 清理缓存
  30. */
  31. public function clearOp()
  32. {
  33. if (!chksubmit()) {
  34. Tpl::showpage('cache.clear');
  35. return;
  36. }
  37. $lang = Language::getLangContent();
  38. // 清理所有缓存
  39. if ($_POST['cls_full'] == 1) {
  40. foreach ($this->cacheItems as $i) {
  41. dkcache($i);
  42. }
  43. // 表主键
  44. Model::dropTablePkArrayCache();
  45. // 商品分类
  46. dkcache('gc_class');
  47. dkcache('all_categories');
  48. dkcache('goods_class_seo');
  49. dkcache('class_tag');
  50. // 广告
  51. Model('adv')->makeApAllCache();
  52. // 首页
  53. Model('web_config')->getWebHtml('index', 1);
  54. delCacheFile('index');
  55. } else {
  56. $todo = (array) $_POST['cache'];
  57. foreach ($this->cacheItems as $i) {
  58. if (in_array($i, $todo)) {
  59. dkcache($i);
  60. }
  61. }
  62. // 表主键
  63. if (in_array('table', $todo)) {
  64. Model::dropTablePkArrayCache();
  65. }
  66. // 商品分类
  67. if (in_array('goodsclass', $todo)) {
  68. dkcache('gc_class');
  69. dkcache('all_categories');
  70. dkcache('goods_class_seo');
  71. dkcache('class_tag');
  72. }
  73. // 广告
  74. if (in_array('adv', $todo)) {
  75. Model('adv')->makeApAllCache();
  76. }
  77. // 首页
  78. if (in_array('index', $todo)) {
  79. Model('web_config')->getWebHtml('index', 1);
  80. delCacheFile('index');
  81. }
  82. // 省市区地址
  83. if (in_array('area', $todo)) {
  84. dkcache('area');
  85. dkcache('area_toplevelareas'); // 省级别缓存处理
  86. dkcache('area_cityprovince'); // 市级别缓存处理
  87. }
  88. }
  89. $this->log(L('cache_cls_operate'));
  90. showMessage($lang['cache_cls_ok']);
  91. }
  92. }